Merge branch '12167-arvput-log-on-signals'
[arvados.git] / services / crunch-run / crunchrun_test.go
index 8a7139fb59aeb33f12f999ccc8cb9b3789106123..48da8edd86c521b007e0ba127136fb050e4c2773 100644 (file)
@@ -13,10 +13,10 @@ import (
        "fmt"
        "io"
        "io/ioutil"
+       "log"
        "net"
        "os"
        "os/exec"
-       "path/filepath"
        "runtime/pprof"
        "sort"
        "strings"
@@ -58,7 +58,8 @@ type ArvTestClient struct {
        Calls   int
        Content []arvadosclient.Dict
        arvados.Container
-       Logs map[string]*bytes.Buffer
+       secretMounts []byte
+       Logs         map[string]*bytes.Buffer
        sync.Mutex
        WasSetRunning bool
        callraw       bool
@@ -241,6 +242,12 @@ func (client *ArvTestClient) Call(method, resourceType, uuid, action string, par
                        "uuid": "`+fakeAuthUUID+`",
                        "api_token": "`+fakeAuthToken+`"
                        }`), output)
+       case method == "GET" && resourceType == "containers" && action == "secret_mounts":
+               if client.secretMounts != nil {
+                       return json.Unmarshal(client.secretMounts, output)
+               } else {
+                       return json.Unmarshal([]byte(`{"secret_mounts":{}}`), output)
+               }
        default:
                return fmt.Errorf("Not found")
        }
@@ -357,6 +364,10 @@ func (client *KeepTestClient) PutHB(hash string, buf []byte) (string, int, error
 func (*KeepTestClient) ClearBlockCache() {
 }
 
+func (client *KeepTestClient) Close() {
+       client.Content = nil
+}
+
 type FileWrapper struct {
        io.ReadCloser
        len int64
@@ -401,6 +412,7 @@ func (client *KeepTestClient) ManifestFileReader(m manifest.Manifest, filename s
 
 func (s *TestSuite) TestLoadImage(c *C) {
        kc := &KeepTestClient{}
+       defer kc.Close()
        cr := NewContainerRunner(&ArvTestClient{}, kc, s.docker, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
 
        _, err := cr.Docker.ImageRemove(nil, hwImageId, dockertypes.ImageRemoveOptions{})
@@ -507,7 +519,9 @@ func (KeepReadErrorTestClient) ManifestFileReader(m manifest.Manifest, filename
 
 func (s *TestSuite) TestLoadImageArvError(c *C) {
        // (1) Arvados error
-       cr := NewContainerRunner(ArvErrorTestClient{}, &KeepTestClient{}, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
+       kc := &KeepTestClient{}
+       defer kc.Close()
+       cr := NewContainerRunner(ArvErrorTestClient{}, kc, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
        cr.Container.ContainerImage = hwPDH
 
        err := cr.LoadImage()
@@ -578,7 +592,9 @@ func (s *TestSuite) TestRunContainer(c *C) {
                t.logWriter.Write(dockerLog(1, "Hello world\n"))
                t.logWriter.Close()
        }
-       cr := NewContainerRunner(&ArvTestClient{}, &KeepTestClient{}, s.docker, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
+       kc := &KeepTestClient{}
+       defer kc.Close()
+       cr := NewContainerRunner(&ArvTestClient{}, kc, s.docker, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
 
        var logs TestLogs
        cr.NewLogWriter = logs.NewTestLoggingWriter
@@ -603,6 +619,7 @@ func (s *TestSuite) TestRunContainer(c *C) {
 func (s *TestSuite) TestCommitLogs(c *C) {
        api := &ArvTestClient{}
        kc := &KeepTestClient{}
+       defer kc.Close()
        cr := NewContainerRunner(api, kc, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
        cr.CrunchLog.Timestamper = (&TestTimestamper{}).Timestamp
 
@@ -623,6 +640,7 @@ func (s *TestSuite) TestCommitLogs(c *C) {
 func (s *TestSuite) TestUpdateContainerRunning(c *C) {
        api := &ArvTestClient{}
        kc := &KeepTestClient{}
+       defer kc.Close()
        cr := NewContainerRunner(api, kc, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
 
        err := cr.UpdateContainerRunning()
@@ -634,6 +652,7 @@ func (s *TestSuite) TestUpdateContainerRunning(c *C) {
 func (s *TestSuite) TestUpdateContainerComplete(c *C) {
        api := &ArvTestClient{}
        kc := &KeepTestClient{}
+       defer kc.Close()
        cr := NewContainerRunner(api, kc, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
 
        cr.LogsPDH = new(string)
@@ -654,6 +673,7 @@ func (s *TestSuite) TestUpdateContainerComplete(c *C) {
 func (s *TestSuite) TestUpdateContainerCancelled(c *C) {
        api := &ArvTestClient{}
        kc := &KeepTestClient{}
+       defer kc.Close()
        cr := NewContainerRunner(api, kc, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
        cr.cCancelled = true
        cr.finalState = "Cancelled"
@@ -673,13 +693,24 @@ func (s *TestSuite) fullRunHelper(c *C, record string, extraMounts []string, exi
        err := json.Unmarshal([]byte(record), &rec)
        c.Check(err, IsNil)
 
+       var sm struct {
+               SecretMounts map[string]arvados.Mount `json:"secret_mounts"`
+       }
+       err = json.Unmarshal([]byte(record), &sm)
+       c.Check(err, IsNil)
+       secretMounts, err := json.Marshal(sm)
+       log.Printf("%q %q", sm, secretMounts)
+       c.Check(err, IsNil)
+
        s.docker.exitCode = exitCode
        s.docker.fn = fn
        s.docker.ImageRemove(nil, hwImageId, dockertypes.ImageRemoveOptions{})
 
        api = &ArvTestClient{Container: rec}
        s.docker.api = api
-       cr = NewContainerRunner(api, &KeepTestClient{}, s.docker, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
+       kc := &KeepTestClient{}
+       defer kc.Close()
+       cr = NewContainerRunner(api, kc, s.docker, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
        cr.statInterval = 100 * time.Millisecond
        am := &ArvMountCmdLine{}
        cr.RunArvMount = am.ArvMountTest
@@ -701,6 +732,9 @@ func (s *TestSuite) fullRunHelper(c *C, record string, extraMounts []string, exi
                }
                return d, err
        }
+       cr.MkArvClient = func(token string) (IArvadosClient, error) {
+               return &ArvTestClient{secretMounts: secretMounts}, nil
+       }
 
        if extraMounts != nil && len(extraMounts) > 0 {
                err := cr.SetupArvMountPoint("keep")
@@ -952,8 +986,13 @@ func (s *TestSuite) testStopContainer(c *C, setup func(cr *ContainerRunner)) {
        s.docker.ImageRemove(nil, hwImageId, dockertypes.ImageRemoveOptions{})
 
        api := &ArvTestClient{Container: rec}
-       cr := NewContainerRunner(api, &KeepTestClient{}, s.docker, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
+       kc := &KeepTestClient{}
+       defer kc.Close()
+       cr := NewContainerRunner(api, kc, s.docker, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
        cr.RunArvMount = func([]string, string) (*exec.Cmd, error) { return nil, nil }
+       cr.MkArvClient = func(token string) (IArvadosClient, error) {
+               return &ArvTestClient{}, nil
+       }
        setup(cr)
 
        done := make(chan error)
@@ -1019,6 +1058,7 @@ func stubCert(temp string) string {
 func (s *TestSuite) TestSetupMounts(c *C) {
        api := &ArvTestClient{}
        kc := &KeepTestClient{}
+       defer kc.Close()
        cr := NewContainerRunner(api, kc, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
        am := &ArvMountCmdLine{}
        cr.RunArvMount = am.ArvMountTest
@@ -1029,6 +1069,8 @@ func (s *TestSuite) TestSetupMounts(c *C) {
        c.Assert(err, IsNil)
        stubCertPath := stubCert(certTemp)
 
+       cr.parentTemp = realTemp
+
        defer os.RemoveAll(realTemp)
        defer os.RemoveAll(certTemp)
 
@@ -1045,11 +1087,12 @@ func (s *TestSuite) TestSetupMounts(c *C) {
        }
 
        checkEmpty := func() {
-               filepath.Walk(realTemp, func(path string, _ os.FileInfo, err error) error {
-                       c.Check(path, Equals, realTemp)
-                       c.Check(err, IsNil)
-                       return nil
-               })
+               // Should be deleted.
+               _, err := os.Stat(realTemp)
+               c.Assert(os.IsNotExist(err), Equals, true)
+
+               // Now recreate it for the next test.
+               c.Assert(os.Mkdir(realTemp, 0777), IsNil)
        }
 
        {
@@ -1064,7 +1107,7 @@ func (s *TestSuite) TestSetupMounts(c *C) {
                c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--allow-other",
                        "--read-write", "--crunchstat-interval=5",
                        "--mount-by-pdh", "by_id", realTemp + "/keep1"})
-               c.Check(cr.Binds, DeepEquals, []string{realTemp + "/2:/tmp"})
+               c.Check(cr.Binds, DeepEquals, []string{realTemp + "/tmp2:/tmp"})
                os.RemoveAll(cr.ArvMountPoint)
                cr.CleanupDirs()
                checkEmpty()
@@ -1083,7 +1126,7 @@ func (s *TestSuite) TestSetupMounts(c *C) {
                c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--allow-other",
                        "--read-write", "--crunchstat-interval=5",
                        "--mount-by-pdh", "by_id", realTemp + "/keep1"})
-               c.Check(cr.Binds, DeepEquals, []string{realTemp + "/2:/out", realTemp + "/3:/tmp"})
+               c.Check(cr.Binds, DeepEquals, []string{realTemp + "/tmp2:/out", realTemp + "/tmp3:/tmp"})
                os.RemoveAll(cr.ArvMountPoint)
                cr.CleanupDirs()
                checkEmpty()
@@ -1104,7 +1147,7 @@ func (s *TestSuite) TestSetupMounts(c *C) {
                c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--allow-other",
                        "--read-write", "--crunchstat-interval=5",
                        "--mount-by-pdh", "by_id", realTemp + "/keep1"})
-               c.Check(cr.Binds, DeepEquals, []string{realTemp + "/2:/tmp", stubCertPath + ":/etc/arvados/ca-certificates.crt:ro"})
+               c.Check(cr.Binds, DeepEquals, []string{realTemp + "/tmp2:/tmp", stubCertPath + ":/etc/arvados/ca-certificates.crt:ro"})
                os.RemoveAll(cr.ArvMountPoint)
                cr.CleanupDirs()
                checkEmpty()
@@ -1200,8 +1243,8 @@ func (s *TestSuite) TestSetupMounts(c *C) {
                err := cr.SetupMounts()
                c.Check(err, IsNil)
                sort.StringSlice(cr.Binds).Sort()
-               c.Check(cr.Binds, DeepEquals, []string{realTemp + "/2/mountdata.json:/mnt/test.json:ro"})
-               content, err := ioutil.ReadFile(realTemp + "/2/mountdata.json")
+               c.Check(cr.Binds, DeepEquals, []string{realTemp + "/json2/mountdata.json:/mnt/test.json:ro"})
+               content, err := ioutil.ReadFile(realTemp + "/json2/mountdata.json")
                c.Check(err, IsNil)
                c.Check(content, DeepEquals, []byte(test.out))
                os.RemoveAll(cr.ArvMountPoint)
@@ -1209,6 +1252,35 @@ func (s *TestSuite) TestSetupMounts(c *C) {
                checkEmpty()
        }
 
+       for _, test := range []struct {
+               in  interface{}
+               out string
+       }{
+               {in: "foo", out: `foo`},
+               {in: nil, out: "error"},
+               {in: map[string]int64{"foo": 123456789123456789}, out: "error"},
+       } {
+               i = 0
+               cr.ArvMountPoint = ""
+               cr.Container.Mounts = map[string]arvados.Mount{
+                       "/mnt/test.txt": {Kind: "text", Content: test.in},
+               }
+               err := cr.SetupMounts()
+               if test.out == "error" {
+                       c.Check(err.Error(), Equals, "content for mount \"/mnt/test.txt\" must be a string")
+               } else {
+                       c.Check(err, IsNil)
+                       sort.StringSlice(cr.Binds).Sort()
+                       c.Check(cr.Binds, DeepEquals, []string{realTemp + "/text2/mountdata.text:/mnt/test.txt:ro"})
+                       content, err := ioutil.ReadFile(realTemp + "/text2/mountdata.text")
+                       c.Check(err, IsNil)
+                       c.Check(content, DeepEquals, []byte(test.out))
+               }
+               os.RemoveAll(cr.ArvMountPoint)
+               cr.CleanupDirs()
+               checkEmpty()
+       }
+
        // Read-only mount points are allowed underneath output_dir mount point
        {
                i = 0
@@ -1227,7 +1299,7 @@ func (s *TestSuite) TestSetupMounts(c *C) {
                c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--allow-other",
                        "--read-write", "--crunchstat-interval=5",
                        "--file-cache", "512", "--mount-tmp", "tmp0", "--mount-by-pdh", "by_id", realTemp + "/keep1"})
-               c.Check(cr.Binds, DeepEquals, []string{realTemp + "/2:/tmp", realTemp + "/keep1/tmp0:/tmp/foo:ro"})
+               c.Check(cr.Binds, DeepEquals, []string{realTemp + "/tmp2:/tmp", realTemp + "/keep1/tmp0:/tmp/foo:ro"})
                os.RemoveAll(cr.ArvMountPoint)
                cr.CleanupDirs()
                checkEmpty()
@@ -1253,7 +1325,7 @@ func (s *TestSuite) TestSetupMounts(c *C) {
                os.MkdirAll(realTemp+"/keep1/by_id/59389a8f9ee9d399be35462a0f92541c+53", os.ModePerm)
                os.MkdirAll(realTemp+"/keep1/by_id/59389a8f9ee9d399be35462a0f92541d+53/baz", os.ModePerm)
 
-               rf, _ := os.Create(realTemp+"/keep1/by_id/59389a8f9ee9d399be35462a0f92541d+53/baz/quux")
+               rf, _ := os.Create(realTemp + "/keep1/by_id/59389a8f9ee9d399be35462a0f92541d+53/baz/quux")
                rf.Write([]byte("bar"))
                rf.Close()
 
@@ -1275,13 +1347,13 @@ func (s *TestSuite) TestSetupMounts(c *C) {
                cr.Container.Mounts = make(map[string]arvados.Mount)
                cr.Container.Mounts = map[string]arvados.Mount{
                        "/tmp":     {Kind: "tmp"},
-                       "/tmp/foo": {Kind: "json"},
+                       "/tmp/foo": {Kind: "tmp"},
                }
                cr.OutputPath = "/tmp"
 
                err := cr.SetupMounts()
                c.Check(err, NotNil)
-               c.Check(err, ErrorMatches, `Only mount points of kind 'collection' are supported underneath the output_path.*`)
+               c.Check(err, ErrorMatches, `Only mount points of kind 'collection', 'text' or 'json' are supported underneath the output_path.*`)
                os.RemoveAll(cr.ArvMountPoint)
                cr.CleanupDirs()
                checkEmpty()
@@ -1395,9 +1467,14 @@ func (s *TestSuite) stdoutErrorRunHelper(c *C, record string, fn func(t *TestDoc
        s.docker.ImageRemove(nil, hwImageId, dockertypes.ImageRemoveOptions{})
 
        api = &ArvTestClient{Container: rec}
-       cr = NewContainerRunner(api, &KeepTestClient{}, s.docker, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
+       kc := &KeepTestClient{}
+       defer kc.Close()
+       cr = NewContainerRunner(api, kc, s.docker, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
        am := &ArvMountCmdLine{}
        cr.RunArvMount = am.ArvMountTest
+       cr.MkArvClient = func(token string) (IArvadosClient, error) {
+               return &ArvTestClient{}, nil
+       }
 
        err = cr.Run()
        return
@@ -1539,7 +1616,7 @@ func (s *TestSuite) TestStdoutWithMultipleMountPointsUnderOutputDir(c *C) {
                t.logWriter.Close()
        })
 
-       c.Check(runner.Binds, DeepEquals, []string{realtemp + "/2:/tmp",
+       c.Check(runner.Binds, DeepEquals, []string{realtemp + "/tmp2:/tmp",
                realtemp + "/keep1/by_id/a0def87f80dd594d4675809e83bd4f15+367/file2_in_main.txt:/tmp/foo/bar:ro",
                realtemp + "/keep1/by_id/a0def87f80dd594d4675809e83bd4f15+367/subdir1/subdir2/file2_in_subdir2.txt:/tmp/foo/baz/sub2file2:ro",
                realtemp + "/keep1/by_id/a0def87f80dd594d4675809e83bd4f15+367/subdir1:/tmp/foo/sub1:ro",
@@ -1628,11 +1705,11 @@ func (s *TestSuite) TestOutputSymlinkToInput(c *C) {
        }
 
        api, _, _ := s.fullRunHelper(c, helperRecord, extraMounts, 0, func(t *TestDockerClient) {
-               os.Symlink("/keep/foo/sub1file2", t.realTemp+"/2/baz")
-               os.Symlink("/keep/foo2/subdir1/file2_in_subdir1.txt", t.realTemp+"/2/baz2")
-               os.Symlink("/keep/foo2/subdir1", t.realTemp+"/2/baz3")
-               os.Mkdir(t.realTemp+"/2/baz4", 0700)
-               os.Symlink("/keep/foo2/subdir1/file2_in_subdir1.txt", t.realTemp+"/2/baz4/baz5")
+               os.Symlink("/keep/foo/sub1file2", t.realTemp+"/tmp2/baz")
+               os.Symlink("/keep/foo2/subdir1/file2_in_subdir1.txt", t.realTemp+"/tmp2/baz2")
+               os.Symlink("/keep/foo2/subdir1", t.realTemp+"/tmp2/baz3")
+               os.Mkdir(t.realTemp+"/tmp2/baz4", 0700)
+               os.Symlink("/keep/foo2/subdir1/file2_in_subdir1.txt", t.realTemp+"/tmp2/baz4/baz5")
                t.logWriter.Close()
        })
 
@@ -1670,7 +1747,7 @@ func (s *TestSuite) TestOutputError(c *C) {
        extraMounts := []string{}
 
        api, _, _ := s.fullRunHelper(c, helperRecord, extraMounts, 0, func(t *TestDockerClient) {
-               os.Symlink("/etc/hosts", t.realTemp+"/2/baz")
+               os.Symlink("/etc/hosts", t.realTemp+"/tmp2/baz")
                t.logWriter.Close()
        })
 
@@ -1694,21 +1771,21 @@ func (s *TestSuite) TestOutputSymlinkToOutput(c *C) {
        extraMounts := []string{}
 
        api, _, _ := s.fullRunHelper(c, helperRecord, extraMounts, 0, func(t *TestDockerClient) {
-               rf, _ := os.Create(t.realTemp + "/2/realfile")
+               rf, _ := os.Create(t.realTemp + "/tmp2/realfile")
                rf.Write([]byte("foo"))
                rf.Close()
 
-               os.Mkdir(t.realTemp+"/2/realdir", 0700)
-               rf, _ = os.Create(t.realTemp + "/2/realdir/subfile")
+               os.Mkdir(t.realTemp+"/tmp2/realdir", 0700)
+               rf, _ = os.Create(t.realTemp + "/tmp2/realdir/subfile")
                rf.Write([]byte("bar"))
                rf.Close()
 
-               os.Symlink("/tmp/realfile", t.realTemp+"/2/file1")
-               os.Symlink("realfile", t.realTemp+"/2/file2")
-               os.Symlink("/tmp/file1", t.realTemp+"/2/file3")
-               os.Symlink("file2", t.realTemp+"/2/file4")
-               os.Symlink("realdir", t.realTemp+"/2/dir1")
-               os.Symlink("/tmp/realdir", t.realTemp+"/2/dir2")
+               os.Symlink("/tmp/realfile", t.realTemp+"/tmp2/file1")
+               os.Symlink("realfile", t.realTemp+"/tmp2/file2")
+               os.Symlink("/tmp/file1", t.realTemp+"/tmp2/file3")
+               os.Symlink("file2", t.realTemp+"/tmp2/file4")
+               os.Symlink("realdir", t.realTemp+"/tmp2/dir1")
+               os.Symlink("/tmp/realdir", t.realTemp+"/tmp2/dir2")
                t.logWriter.Close()
        })
 
@@ -1831,7 +1908,9 @@ func (s *TestSuite) TestStderrMount(c *C) {
 }
 
 func (s *TestSuite) TestNumberRoundTrip(c *C) {
-       cr := NewContainerRunner(&ArvTestClient{callraw: true}, &KeepTestClient{}, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
+       kc := &KeepTestClient{}
+       defer kc.Close()
+       cr := NewContainerRunner(&ArvTestClient{callraw: true}, kc, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
        cr.fetchContainerRecord()
 
        jsondata, err := json.Marshal(cr.Container.Mounts["/json"].Content)
@@ -1841,7 +1920,9 @@ func (s *TestSuite) TestNumberRoundTrip(c *C) {
 }
 
 func (s *TestSuite) TestEvalSymlinks(c *C) {
-       cr := NewContainerRunner(&ArvTestClient{callraw: true}, &KeepTestClient{}, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
+       kc := &KeepTestClient{}
+       defer kc.Close()
+       cr := NewContainerRunner(&ArvTestClient{callraw: true}, kc, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
 
        realTemp, err := ioutil.TempDir("", "crunchrun_test-")
        c.Assert(err, IsNil)
@@ -1871,7 +1952,9 @@ func (s *TestSuite) TestEvalSymlinks(c *C) {
 }
 
 func (s *TestSuite) TestEvalSymlinkDir(c *C) {
-       cr := NewContainerRunner(&ArvTestClient{callraw: true}, &KeepTestClient{}, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
+       kc := &KeepTestClient{}
+       defer kc.Close()
+       cr := NewContainerRunner(&ArvTestClient{callraw: true}, kc, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
 
        realTemp, err := ioutil.TempDir("", "crunchrun_test-")
        c.Assert(err, IsNil)
@@ -2033,3 +2116,61 @@ func (s *TestSuite) TestBadCommand3(c *C) {
        c.Check(api.CalledWith("container.state", "Cancelled"), NotNil)
        c.Check(api.Logs["crunch-run"].String(), Matches, "(?ms).*Possible causes:.*is missing.*")
 }
+
+func (s *TestSuite) TestSecretTextMountPoint(c *C) {
+       // under normal mounts, gets captured in output, oops
+       helperRecord := `{
+               "command": ["true"],
+               "container_image": "d4ab34d3d4f8a72f5c4973051ae69fab+122",
+               "cwd": "/bin",
+               "mounts": {
+                    "/tmp": {"kind": "tmp"},
+                    "/tmp/secret.conf": {"kind": "text", "content": "mypassword"}
+                },
+                "secret_mounts": {
+                },
+               "output_path": "/tmp",
+               "priority": 1,
+               "runtime_constraints": {}
+       }`
+
+       api, _, _ := s.fullRunHelper(c, helperRecord, nil, 0, func(t *TestDockerClient) {
+               content, err := ioutil.ReadFile(t.realTemp + "/tmp2/secret.conf")
+               c.Check(err, IsNil)
+               c.Check(content, DeepEquals, []byte("mypassword"))
+               t.logWriter.Close()
+       })
+
+       c.Check(api.CalledWith("container.exit_code", 0), NotNil)
+       c.Check(api.CalledWith("container.state", "Complete"), NotNil)
+       c.Check(api.CalledWith("collection.manifest_text", ". 34819d7beeabb9260a5c854bc85b3e44+10 0:10:secret.conf\n"), NotNil)
+       c.Check(api.CalledWith("collection.manifest_text", ""), IsNil)
+
+       // under secret mounts, not captured in output
+       helperRecord = `{
+               "command": ["true"],
+               "container_image": "d4ab34d3d4f8a72f5c4973051ae69fab+122",
+               "cwd": "/bin",
+               "mounts": {
+                    "/tmp": {"kind": "tmp"}
+                },
+                "secret_mounts": {
+                    "/tmp/secret.conf": {"kind": "text", "content": "mypassword"}
+                },
+               "output_path": "/tmp",
+               "priority": 1,
+               "runtime_constraints": {}
+       }`
+
+       api, _, _ = s.fullRunHelper(c, helperRecord, nil, 0, func(t *TestDockerClient) {
+               content, err := ioutil.ReadFile(t.realTemp + "/tmp2/secret.conf")
+               c.Check(err, IsNil)
+               c.Check(content, DeepEquals, []byte("mypassword"))
+               t.logWriter.Close()
+       })
+
+       c.Check(api.CalledWith("container.exit_code", 0), NotNil)
+       c.Check(api.CalledWith("container.state", "Complete"), NotNil)
+       c.Check(api.CalledWith("collection.manifest_text", ". 34819d7beeabb9260a5c854bc85b3e44+10 0:10:secret.conf\n"), IsNil)
+       c.Check(api.CalledWith("collection.manifest_text", ""), NotNil)
+}