1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
25 "git.arvados.org/arvados.git/sdk/go/arvados"
26 "git.arvados.org/arvados.git/sdk/go/arvadosclient"
27 "git.arvados.org/arvados.git/sdk/go/arvadostest"
28 "git.arvados.org/arvados.git/sdk/go/manifest"
29 "golang.org/x/net/context"
34 // Gocheck boilerplate
35 func TestCrunchExec(t *testing.T) {
39 var _ = Suite(&TestSuite{})
41 type TestSuite struct {
42 client *arvados.Client
44 runner *ContainerRunner
45 executor *stubExecutor
47 testDispatcherKeepClient KeepTestClient
48 testContainerKeepClient KeepTestClient
51 func (s *TestSuite) SetUpTest(c *C) {
53 s.client = arvados.NewClientFromEnv()
54 s.executor = &stubExecutor{}
56 s.api = &ArvTestClient{}
57 s.runner, err = NewContainerRunner(s.client, s.api, &s.testDispatcherKeepClient, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
59 s.runner.executor = s.executor
60 s.runner.MkArvClient = func(token string) (IArvadosClient, IKeepClient, *arvados.Client, error) {
61 return s.api, &s.testContainerKeepClient, s.client, nil
63 s.runner.RunArvMount = func(cmd []string, tok string) (*exec.Cmd, error) {
64 s.runner.ArvMountPoint = s.keepmount
67 s.keepmount = c.MkDir()
68 err = os.Mkdir(s.keepmount+"/by_id", 0755)
70 err = os.Mkdir(s.keepmount+"/by_id/"+arvadostest.DockerImage112PDH, 0755)
72 err = ioutil.WriteFile(s.keepmount+"/by_id/"+arvadostest.DockerImage112PDH+"/"+arvadostest.DockerImage112Filename, []byte("#notarealtarball"), 0644)
73 err = os.Mkdir(s.keepmount+"/by_id/"+fakeInputCollectionPDH, 0755)
75 err = ioutil.WriteFile(s.keepmount+"/by_id/"+fakeInputCollectionPDH+"/input.json", []byte(`{"input":true}`), 0644)
77 s.runner.ArvMountPoint = s.keepmount
80 type ArvTestClient struct {
83 Content []arvadosclient.Dict
86 Logs map[string]*bytes.Buffer
92 type KeepTestClient struct {
95 StorageClasses []string
98 type stubExecutor struct {
104 created containerSpec
106 waitSleep time.Duration
115 func (e *stubExecutor) LoadImage(imageId string, tarball string, container arvados.Container, keepMount string,
116 containerClient *arvados.Client) error {
120 func (e *stubExecutor) Create(spec containerSpec) error { e.created = spec; return e.createErr }
121 func (e *stubExecutor) Start() error { e.exit = make(chan int, 1); go e.runFunc(); return e.startErr }
122 func (e *stubExecutor) CgroupID() string { return "cgroupid" }
123 func (e *stubExecutor) Stop() error { e.stopped = true; go func() { e.exit <- -1 }(); return e.stopErr }
124 func (e *stubExecutor) Close() { e.closed = true }
125 func (e *stubExecutor) Wait(context.Context) (int, error) {
126 return <-e.exit, e.waitErr
129 const fakeInputCollectionPDH = "ffffffffaaaaaaaa88888888eeeeeeee+1234"
131 var hwManifest = ". 82ab40c24fc8df01798e57ba66795bb1+841216+Aa124ac75e5168396c73c0a18eda641a4f41791c0@569fa8c3 0:841216:9c31ee32b3d15268a0754e8edc74d4f815ee014b693bc5109058e431dd5caea7.tar\n"
132 var hwPDH = "a45557269dcb65a6b78f9ac061c0850b+120"
133 var hwImageID = "9c31ee32b3d15268a0754e8edc74d4f815ee014b693bc5109058e431dd5caea7"
135 var otherManifest = ". 68a84f561b1d1708c6baff5e019a9ab3+46+Ae5d0af96944a3690becb1decdf60cc1c937f556d@5693216f 0:46:md5sum.txt\n"
136 var otherPDH = "a3e8f74c6f101eae01fa08bfb4e49b3a+54"
138 var normalizedManifestWithSubdirs = `. 3e426d509afffb85e06c4c96a7c15e91+27+Aa124ac75e5168396c73c0abcdefgh11234567890@569fa8c3 0:9:file1_in_main.txt 9:18:file2_in_main.txt 0:27:zzzzz-8i9sb-bcdefghijkdhvnk.log.txt
139 ./subdir1 3e426d509afffb85e06c4c96a7c15e91+27+Aa124ac75e5168396cabcdefghij6419876543234@569fa8c4 0:9:file1_in_subdir1.txt 9:18:file2_in_subdir1.txt
140 ./subdir1/subdir2 3e426d509afffb85e06c4c96a7c15e91+27+Aa124ac75e5168396c73c0bcdefghijk544332211@569fa8c5 0:9:file1_in_subdir2.txt 9:18:file2_in_subdir2.txt
143 var normalizedWithSubdirsPDH = "a0def87f80dd594d4675809e83bd4f15+367"
145 var denormalizedManifestWithSubdirs = ". 3e426d509afffb85e06c4c96a7c15e91+27+Aa124ac75e5168396c73c0abcdefgh11234567890@569fa8c3 0:9:file1_in_main.txt 9:18:file2_in_main.txt 0:27:zzzzz-8i9sb-bcdefghijkdhvnk.log.txt 0:10:subdir1/file1_in_subdir1.txt 10:17:subdir1/file2_in_subdir1.txt\n"
146 var denormalizedWithSubdirsPDH = "b0def87f80dd594d4675809e83bd4f15+367"
148 var fakeAuthUUID = "zzzzz-gj3su-55pqoyepgi2glem"
149 var fakeAuthToken = "a3ltuwzqcu2u4sc0q7yhpc2w7s00fdcqecg5d6e0u3pfohmbjt"
151 func (client *ArvTestClient) Create(resourceType string,
152 parameters arvadosclient.Dict,
153 output interface{}) error {
156 defer client.Mutex.Unlock()
159 client.Content = append(client.Content, parameters)
161 if resourceType == "logs" {
162 et := parameters["log"].(arvadosclient.Dict)["event_type"].(string)
163 if client.Logs == nil {
164 client.Logs = make(map[string]*bytes.Buffer)
166 if client.Logs[et] == nil {
167 client.Logs[et] = &bytes.Buffer{}
169 client.Logs[et].Write([]byte(parameters["log"].(arvadosclient.Dict)["properties"].(map[string]string)["text"]))
172 if resourceType == "collections" && output != nil {
173 mt := parameters["collection"].(arvadosclient.Dict)["manifest_text"].(string)
174 outmap := output.(*arvados.Collection)
175 outmap.PortableDataHash = fmt.Sprintf("%x+%d", md5.Sum([]byte(mt)), len(mt))
176 outmap.UUID = fmt.Sprintf("zzzzz-4zz18-%15.15x", md5.Sum([]byte(mt)))
182 func (client *ArvTestClient) Call(method, resourceType, uuid, action string, parameters arvadosclient.Dict, output interface{}) error {
184 case method == "GET" && resourceType == "containers" && action == "auth":
185 return json.Unmarshal([]byte(`{
186 "kind": "arvados#api_client_authorization",
187 "uuid": "`+fakeAuthUUID+`",
188 "api_token": "`+fakeAuthToken+`"
190 case method == "GET" && resourceType == "containers" && action == "secret_mounts":
191 if client.secretMounts != nil {
192 return json.Unmarshal(client.secretMounts, output)
194 return json.Unmarshal([]byte(`{"secret_mounts":{}}`), output)
196 return fmt.Errorf("Not found")
200 func (client *ArvTestClient) CallRaw(method, resourceType, uuid, action string,
201 parameters arvadosclient.Dict) (reader io.ReadCloser, err error) {
203 if method == "GET" && resourceType == "nodes" && uuid == "" && action == "" {
205 "kind": "arvados#nodeList",
207 "uuid": "zzzzz-7ekkf-2z3mc76g2q73aio",
208 "hostname": "compute2",
209 "properties": {"total_cpu_cores": 16}
211 } else if method == "GET" && resourceType == "containers" && action == "" && !client.callraw {
213 j, err = json.Marshal(map[string]interface{}{
214 "items": []interface{}{client.Container},
215 "kind": "arvados#nodeList",
218 j, err = json.Marshal(client.Container)
222 "command": ["sleep", "1"],
223 "container_image": "` + arvadostest.DockerImage112PDH + `",
226 "mounts": {"/tmp": {"kind": "tmp"}, "/json": {"kind": "json", "content": {"number": 123456789123456789}}},
227 "output_path": "/tmp",
229 "runtime_constraints": {}
232 return ioutil.NopCloser(bytes.NewReader(j)), err
235 func (client *ArvTestClient) Get(resourceType string, uuid string, parameters arvadosclient.Dict, output interface{}) error {
236 if resourceType == "collections" {
238 output.(*arvados.Collection).ManifestText = hwManifest
239 } else if uuid == otherPDH {
240 output.(*arvados.Collection).ManifestText = otherManifest
241 } else if uuid == normalizedWithSubdirsPDH {
242 output.(*arvados.Collection).ManifestText = normalizedManifestWithSubdirs
243 } else if uuid == denormalizedWithSubdirsPDH {
244 output.(*arvados.Collection).ManifestText = denormalizedManifestWithSubdirs
247 if resourceType == "containers" {
248 (*output.(*arvados.Container)) = client.Container
253 func (client *ArvTestClient) Update(resourceType string, uuid string, parameters arvadosclient.Dict, output interface{}) (err error) {
255 defer client.Mutex.Unlock()
257 client.Content = append(client.Content, parameters)
258 if resourceType == "containers" {
259 if parameters["container"].(arvadosclient.Dict)["state"] == "Running" {
260 client.WasSetRunning = true
262 } else if resourceType == "collections" {
263 mt := parameters["collection"].(arvadosclient.Dict)["manifest_text"].(string)
264 output.(*arvados.Collection).UUID = uuid
265 output.(*arvados.Collection).PortableDataHash = fmt.Sprintf("%x", md5.Sum([]byte(mt)))
270 var discoveryMap = map[string]interface{}{
271 "defaultTrashLifetime": float64(1209600),
272 "crunchLimitLogBytesPerJob": float64(67108864),
273 "crunchLogThrottleBytes": float64(65536),
274 "crunchLogThrottlePeriod": float64(60),
275 "crunchLogThrottleLines": float64(1024),
276 "crunchLogPartialLineThrottlePeriod": float64(5),
277 "crunchLogBytesPerEvent": float64(4096),
278 "crunchLogSecondsBetweenEvents": float64(1),
281 func (client *ArvTestClient) Discovery(key string) (interface{}, error) {
282 return discoveryMap[key], nil
285 // CalledWith returns the parameters from the first API call whose
286 // parameters match jpath/string. E.g., CalledWith(c, "foo.bar",
287 // "baz") returns parameters with parameters["foo"]["bar"]=="baz". If
288 // no call matches, it returns nil.
289 func (client *ArvTestClient) CalledWith(jpath string, expect interface{}) arvadosclient.Dict {
291 for _, content := range client.Content {
292 var v interface{} = content
293 for _, k := range strings.Split(jpath, ".") {
294 if dict, ok := v.(arvadosclient.Dict); !ok {
307 func (client *KeepTestClient) LocalLocator(locator string) (string, error) {
311 func (client *KeepTestClient) BlockWrite(_ context.Context, opts arvados.BlockWriteOptions) (arvados.BlockWriteResponse, error) {
312 client.Content = opts.Data
313 return arvados.BlockWriteResponse{
314 Locator: fmt.Sprintf("%x+%d", md5.Sum(opts.Data), len(opts.Data)),
318 func (client *KeepTestClient) ReadAt(string, []byte, int) (int, error) {
319 return 0, errors.New("not implemented")
322 func (client *KeepTestClient) ClearBlockCache() {
325 func (client *KeepTestClient) Close() {
329 func (client *KeepTestClient) SetStorageClasses(sc []string) {
330 client.StorageClasses = sc
333 type FileWrapper struct {
338 func (fw FileWrapper) Readdir(n int) ([]os.FileInfo, error) {
339 return nil, errors.New("not implemented")
342 func (fw FileWrapper) Seek(int64, int) (int64, error) {
343 return 0, errors.New("not implemented")
346 func (fw FileWrapper) Size() int64 {
350 func (fw FileWrapper) Stat() (os.FileInfo, error) {
351 return nil, errors.New("not implemented")
354 func (fw FileWrapper) Truncate(int64) error {
355 return errors.New("not implemented")
358 func (fw FileWrapper) Write([]byte) (int, error) {
359 return 0, errors.New("not implemented")
362 func (fw FileWrapper) Sync() error {
363 return errors.New("not implemented")
366 func (client *KeepTestClient) ManifestFileReader(m manifest.Manifest, filename string) (arvados.File, error) {
367 if filename == hwImageID+".tar" {
368 rdr := ioutil.NopCloser(&bytes.Buffer{})
370 return FileWrapper{rdr, 1321984}, nil
371 } else if filename == "/file1_in_main.txt" {
372 rdr := ioutil.NopCloser(strings.NewReader("foo"))
374 return FileWrapper{rdr, 3}, nil
379 func (s *TestSuite) TestLoadImage(c *C) {
380 s.runner.Container.ContainerImage = arvadostest.DockerImage112PDH
381 s.runner.Container.Mounts = map[string]arvados.Mount{
382 "/out": {Kind: "tmp", Writable: true},
384 s.runner.Container.OutputPath = "/out"
386 _, err := s.runner.SetupMounts()
389 imageID, err := s.runner.LoadImage()
391 c.Check(s.executor.loaded, Matches, ".*"+regexp.QuoteMeta(arvadostest.DockerImage112Filename))
392 c.Check(imageID, Equals, strings.TrimSuffix(arvadostest.DockerImage112Filename, ".tar"))
394 s.runner.Container.ContainerImage = arvadostest.DockerImage112PDH
395 s.executor.imageLoaded = false
396 s.executor.loaded = ""
397 s.executor.loadErr = errors.New("bork")
398 imageID, err = s.runner.LoadImage()
399 c.Check(err, ErrorMatches, ".*bork")
400 c.Check(s.executor.loaded, Matches, ".*"+regexp.QuoteMeta(arvadostest.DockerImage112Filename))
402 s.runner.Container.ContainerImage = fakeInputCollectionPDH
403 s.executor.imageLoaded = false
404 s.executor.loaded = ""
405 s.executor.loadErr = nil
406 imageID, err = s.runner.LoadImage()
407 c.Check(err, ErrorMatches, "image collection does not include a \\.tar image file")
408 c.Check(s.executor.loaded, Equals, "")
411 type ArvErrorTestClient struct{}
413 func (ArvErrorTestClient) Create(resourceType string,
414 parameters arvadosclient.Dict,
415 output interface{}) error {
419 func (ArvErrorTestClient) Call(method, resourceType, uuid, action string, parameters arvadosclient.Dict, output interface{}) error {
420 if method == "GET" && resourceType == "containers" && action == "auth" {
423 return errors.New("ArvError")
426 func (ArvErrorTestClient) CallRaw(method, resourceType, uuid, action string,
427 parameters arvadosclient.Dict) (reader io.ReadCloser, err error) {
428 return nil, errors.New("ArvError")
431 func (ArvErrorTestClient) Get(resourceType string, uuid string, parameters arvadosclient.Dict, output interface{}) error {
432 return errors.New("ArvError")
435 func (ArvErrorTestClient) Update(resourceType string, uuid string, parameters arvadosclient.Dict, output interface{}) (err error) {
439 func (ArvErrorTestClient) Discovery(key string) (interface{}, error) {
440 return discoveryMap[key], nil
443 type KeepErrorTestClient struct {
447 func (*KeepErrorTestClient) ManifestFileReader(manifest.Manifest, string) (arvados.File, error) {
448 return nil, errors.New("KeepError")
451 func (*KeepErrorTestClient) BlockWrite(context.Context, arvados.BlockWriteOptions) (arvados.BlockWriteResponse, error) {
452 return arvados.BlockWriteResponse{}, errors.New("KeepError")
455 func (*KeepErrorTestClient) LocalLocator(string) (string, error) {
456 return "", errors.New("KeepError")
459 type KeepReadErrorTestClient struct {
463 func (*KeepReadErrorTestClient) ReadAt(string, []byte, int) (int, error) {
464 return 0, errors.New("KeepError")
467 type ErrorReader struct {
471 func (ErrorReader) Read(p []byte) (n int, err error) {
472 return 0, errors.New("ErrorReader")
475 func (ErrorReader) Seek(int64, int) (int64, error) {
476 return 0, errors.New("ErrorReader")
479 func (KeepReadErrorTestClient) ManifestFileReader(m manifest.Manifest, filename string) (arvados.File, error) {
480 return ErrorReader{}, nil
483 type ClosableBuffer struct {
487 func (*ClosableBuffer) Close() error {
491 type TestLogs struct {
492 Stdout ClosableBuffer
493 Stderr ClosableBuffer
496 func (tl *TestLogs) NewTestLoggingWriter(logstr string) (io.WriteCloser, error) {
497 if logstr == "stdout" {
498 return &tl.Stdout, nil
500 if logstr == "stderr" {
501 return &tl.Stderr, nil
503 return nil, errors.New("???")
506 func dockerLog(fd byte, msg string) []byte {
508 header := make([]byte, 8+len(by))
510 header[7] = byte(len(by))
515 func (s *TestSuite) TestRunContainer(c *C) {
516 s.executor.runFunc = func() {
517 fmt.Fprintf(s.executor.created.Stdout, "Hello world\n")
522 s.runner.NewLogWriter = logs.NewTestLoggingWriter
523 s.runner.Container.ContainerImage = arvadostest.DockerImage112PDH
524 s.runner.Container.Command = []string{"./hw"}
525 s.runner.Container.OutputStorageClasses = []string{"default"}
527 imageID, err := s.runner.LoadImage()
530 err = s.runner.CreateContainer(imageID, nil)
533 err = s.runner.StartContainer()
536 err = s.runner.WaitFinish()
539 c.Check(logs.Stdout.String(), Matches, ".*Hello world\n")
540 c.Check(logs.Stderr.String(), Equals, "")
543 func (s *TestSuite) TestCommitLogs(c *C) {
544 api := &ArvTestClient{}
545 kc := &KeepTestClient{}
547 cr, err := NewContainerRunner(s.client, api, kc, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
549 cr.CrunchLog.Timestamper = (&TestTimestamper{}).Timestamp
551 cr.CrunchLog.Print("Hello world!")
552 cr.CrunchLog.Print("Goodbye")
553 cr.finalState = "Complete"
555 err = cr.CommitLogs()
558 c.Check(api.Calls, Equals, 2)
559 c.Check(api.Content[1]["ensure_unique_name"], Equals, true)
560 c.Check(api.Content[1]["collection"].(arvadosclient.Dict)["name"], Equals, "logs for zzzzz-zzzzz-zzzzzzzzzzzzzzz")
561 c.Check(api.Content[1]["collection"].(arvadosclient.Dict)["manifest_text"], Equals, ". 744b2e4553123b02fa7b452ec5c18993+123 0:123:crunch-run.txt\n")
562 c.Check(*cr.LogsPDH, Equals, "63da7bdacf08c40f604daad80c261e9a+60")
565 func (s *TestSuite) TestUpdateContainerRunning(c *C) {
566 api := &ArvTestClient{}
567 kc := &KeepTestClient{}
569 cr, err := NewContainerRunner(s.client, api, kc, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
572 err = cr.UpdateContainerRunning()
575 c.Check(api.Content[0]["container"].(arvadosclient.Dict)["state"], Equals, "Running")
578 func (s *TestSuite) TestUpdateContainerComplete(c *C) {
579 api := &ArvTestClient{}
580 kc := &KeepTestClient{}
582 cr, err := NewContainerRunner(s.client, api, kc, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
585 cr.LogsPDH = new(string)
586 *cr.LogsPDH = "d3a229d2fe3690c2c3e75a71a153c6a3+60"
588 cr.ExitCode = new(int)
590 cr.finalState = "Complete"
592 err = cr.UpdateContainerFinal()
595 c.Check(api.Content[0]["container"].(arvadosclient.Dict)["log"], Equals, *cr.LogsPDH)
596 c.Check(api.Content[0]["container"].(arvadosclient.Dict)["exit_code"], Equals, *cr.ExitCode)
597 c.Check(api.Content[0]["container"].(arvadosclient.Dict)["state"], Equals, "Complete")
600 func (s *TestSuite) TestUpdateContainerCancelled(c *C) {
601 api := &ArvTestClient{}
602 kc := &KeepTestClient{}
604 cr, err := NewContainerRunner(s.client, api, kc, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
607 cr.finalState = "Cancelled"
609 err = cr.UpdateContainerFinal()
612 c.Check(api.Content[0]["container"].(arvadosclient.Dict)["log"], IsNil)
613 c.Check(api.Content[0]["container"].(arvadosclient.Dict)["exit_code"], IsNil)
614 c.Check(api.Content[0]["container"].(arvadosclient.Dict)["state"], Equals, "Cancelled")
617 // Used by the TestFullRun*() test below to DRY up boilerplate setup to do full
618 // dress rehearsal of the Run() function, starting from a JSON container record.
619 func (s *TestSuite) fullRunHelper(c *C, record string, extraMounts []string, exitCode int, fn func()) (*ArvTestClient, *ContainerRunner, string) {
620 err := json.Unmarshal([]byte(record), &s.api.Container)
622 initialState := s.api.Container.State
625 SecretMounts map[string]arvados.Mount `json:"secret_mounts"`
627 err = json.Unmarshal([]byte(record), &sm)
629 secretMounts, err := json.Marshal(sm)
631 c.Logf("SecretMounts decoded %v json %q", sm, secretMounts)
633 s.executor.runFunc = func() {
635 s.executor.exit <- exitCode
638 s.runner.statInterval = 100 * time.Millisecond
639 s.runner.containerWatchdogInterval = time.Second
640 am := &ArvMountCmdLine{}
641 s.runner.RunArvMount = am.ArvMountTest
643 realTemp := c.MkDir()
645 s.runner.MkTempDir = func(_, prefix string) (string, error) {
647 d := fmt.Sprintf("%s/%s%d", realTemp, prefix, tempcount)
648 err := os.Mkdir(d, os.ModePerm)
649 if err != nil && strings.Contains(err.Error(), ": file exists") {
650 // Test case must have pre-populated the tempdir
655 s.runner.MkArvClient = func(token string) (IArvadosClient, IKeepClient, *arvados.Client, error) {
656 return &ArvTestClient{secretMounts: secretMounts}, &s.testContainerKeepClient, nil, nil
659 if extraMounts != nil && len(extraMounts) > 0 {
660 err := s.runner.SetupArvMountPoint("keep")
663 for _, m := range extraMounts {
664 os.MkdirAll(s.runner.ArvMountPoint+"/by_id/"+m, os.ModePerm)
669 if s.api.CalledWith("container.state", "Complete") != nil {
672 if s.executor.loadErr == nil && s.executor.createErr == nil && initialState != "Running" {
673 c.Check(s.api.WasSetRunning, Equals, true)
674 var lastupdate arvadosclient.Dict
675 for _, content := range s.api.Content {
676 if content["container"] != nil {
677 lastupdate = content["container"].(arvadosclient.Dict)
680 if lastupdate["log"] == nil {
681 c.Errorf("no container update with non-nil log -- updates were: %v", s.api.Content)
686 for k, v := range s.api.Logs {
692 return s.api, s.runner, realTemp
695 func (s *TestSuite) TestFullRunHello(c *C) {
696 s.runner.enableMemoryLimit = true
697 s.runner.networkMode = "default"
698 s.fullRunHelper(c, `{
699 "command": ["echo", "hello world"],
700 "container_image": "`+arvadostest.DockerImage112PDH+`",
702 "environment": {"foo":"bar","baz":"waz"},
703 "mounts": {"/tmp": {"kind": "tmp"} },
704 "output_path": "/tmp",
706 "runtime_constraints": {"vcpus":1,"ram":1000000},
708 "output_storage_classes": ["default"]
710 c.Check(s.executor.created.Command, DeepEquals, []string{"echo", "hello world"})
711 c.Check(s.executor.created.Image, Equals, "sha256:d8309758b8fe2c81034ffc8a10c36460b77db7bc5e7b448c4e5b684f9d95a678")
712 c.Check(s.executor.created.Env, DeepEquals, map[string]string{"foo": "bar", "baz": "waz"})
713 c.Check(s.executor.created.VCPUs, Equals, 1)
714 c.Check(s.executor.created.RAM, Equals, int64(1000000))
715 c.Check(s.executor.created.NetworkMode, Equals, "default")
716 c.Check(s.executor.created.EnableNetwork, Equals, false)
717 fmt.Fprintln(s.executor.created.Stdout, "hello world")
720 c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
721 c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
722 c.Check(s.api.Logs["stdout"].String(), Matches, ".*hello world\n")
723 c.Check(s.testDispatcherKeepClient.StorageClasses, DeepEquals, []string{"default"})
724 c.Check(s.testContainerKeepClient.StorageClasses, DeepEquals, []string{"default"})
727 func (s *TestSuite) TestRunAlreadyRunning(c *C) {
729 s.fullRunHelper(c, `{
730 "command": ["sleep", "3"],
731 "container_image": "`+arvadostest.DockerImage112PDH+`",
734 "mounts": {"/tmp": {"kind": "tmp"} },
735 "output_path": "/tmp",
737 "runtime_constraints": {},
738 "scheduling_parameters":{"max_run_time": 1},
743 c.Check(s.api.CalledWith("container.state", "Cancelled"), IsNil)
744 c.Check(s.api.CalledWith("container.state", "Complete"), IsNil)
745 c.Check(ran, Equals, false)
748 func (s *TestSuite) TestRunTimeExceeded(c *C) {
749 s.fullRunHelper(c, `{
750 "command": ["sleep", "3"],
751 "container_image": "`+arvadostest.DockerImage112PDH+`",
754 "mounts": {"/tmp": {"kind": "tmp"} },
755 "output_path": "/tmp",
757 "runtime_constraints": {},
758 "scheduling_parameters":{"max_run_time": 1},
761 time.Sleep(3 * time.Second)
764 c.Check(s.api.CalledWith("container.state", "Cancelled"), NotNil)
765 c.Check(s.api.Logs["crunch-run"].String(), Matches, "(?ms).*maximum run time exceeded.*")
768 func (s *TestSuite) TestContainerWaitFails(c *C) {
769 s.fullRunHelper(c, `{
770 "command": ["sleep", "3"],
771 "container_image": "`+arvadostest.DockerImage112PDH+`",
773 "mounts": {"/tmp": {"kind": "tmp"} },
774 "output_path": "/tmp",
778 s.executor.waitErr = errors.New("Container is not running")
781 c.Check(s.api.CalledWith("container.state", "Cancelled"), NotNil)
782 c.Check(s.api.Logs["crunch-run"].String(), Matches, "(?ms).*Container is not running.*")
785 func (s *TestSuite) TestCrunchstat(c *C) {
786 s.fullRunHelper(c, `{
787 "command": ["sleep", "1"],
788 "container_image": "`+arvadostest.DockerImage112PDH+`",
791 "mounts": {"/tmp": {"kind": "tmp"} },
792 "output_path": "/tmp",
794 "runtime_constraints": {},
797 time.Sleep(time.Second)
800 c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
801 c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
803 // We didn't actually start a container, so crunchstat didn't
804 // find accounting files and therefore didn't log any stats.
805 // It should have logged a "can't find accounting files"
806 // message after one poll interval, though, so we can confirm
808 c.Assert(s.api.Logs["crunchstat"], NotNil)
809 c.Check(s.api.Logs["crunchstat"].String(), Matches, `(?ms).*cgroup stats files have not appeared after 100ms.*`)
811 // The "files never appeared" log assures us that we called
812 // (*crunchstat.Reporter)Stop(), and that we set it up with
813 // the correct container ID "abcde":
814 c.Check(s.api.Logs["crunchstat"].String(), Matches, `(?ms).*cgroup stats files never appeared for cgroupid\n`)
817 func (s *TestSuite) TestNodeInfoLog(c *C) {
818 os.Setenv("SLURMD_NODENAME", "compute2")
819 s.fullRunHelper(c, `{
820 "command": ["sleep", "1"],
821 "container_image": "`+arvadostest.DockerImage112PDH+`",
824 "mounts": {"/tmp": {"kind": "tmp"} },
825 "output_path": "/tmp",
827 "runtime_constraints": {},
831 time.Sleep(time.Second)
834 c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
835 c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
837 c.Assert(s.api.Logs["node"], NotNil)
838 json := s.api.Logs["node"].String()
839 c.Check(json, Matches, `(?ms).*"uuid": *"zzzzz-7ekkf-2z3mc76g2q73aio".*`)
840 c.Check(json, Matches, `(?ms).*"total_cpu_cores": *16.*`)
841 c.Check(json, Not(Matches), `(?ms).*"info":.*`)
843 c.Assert(s.api.Logs["node-info"], NotNil)
844 json = s.api.Logs["node-info"].String()
845 c.Check(json, Matches, `(?ms).*Host Information.*`)
846 c.Check(json, Matches, `(?ms).*CPU Information.*`)
847 c.Check(json, Matches, `(?ms).*Memory Information.*`)
848 c.Check(json, Matches, `(?ms).*Disk Space.*`)
849 c.Check(json, Matches, `(?ms).*Disk INodes.*`)
852 func (s *TestSuite) TestContainerRecordLog(c *C) {
853 s.fullRunHelper(c, `{
854 "command": ["sleep", "1"],
855 "container_image": "`+arvadostest.DockerImage112PDH+`",
858 "mounts": {"/tmp": {"kind": "tmp"} },
859 "output_path": "/tmp",
861 "runtime_constraints": {},
865 time.Sleep(time.Second)
868 c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
869 c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
871 c.Assert(s.api.Logs["container"], NotNil)
872 c.Check(s.api.Logs["container"].String(), Matches, `(?ms).*container_image.*`)
875 func (s *TestSuite) TestFullRunStderr(c *C) {
876 s.fullRunHelper(c, `{
877 "command": ["/bin/sh", "-c", "echo hello ; echo world 1>&2 ; exit 1"],
878 "container_image": "`+arvadostest.DockerImage112PDH+`",
881 "mounts": {"/tmp": {"kind": "tmp"} },
882 "output_path": "/tmp",
884 "runtime_constraints": {},
887 fmt.Fprintln(s.executor.created.Stdout, "hello")
888 fmt.Fprintln(s.executor.created.Stderr, "world")
891 final := s.api.CalledWith("container.state", "Complete")
892 c.Assert(final, NotNil)
893 c.Check(final["container"].(arvadosclient.Dict)["exit_code"], Equals, 1)
894 c.Check(final["container"].(arvadosclient.Dict)["log"], NotNil)
896 c.Check(s.api.Logs["stdout"].String(), Matches, ".*hello\n")
897 c.Check(s.api.Logs["stderr"].String(), Matches, ".*world\n")
900 func (s *TestSuite) TestFullRunDefaultCwd(c *C) {
901 s.fullRunHelper(c, `{
903 "container_image": "`+arvadostest.DockerImage112PDH+`",
906 "mounts": {"/tmp": {"kind": "tmp"} },
907 "output_path": "/tmp",
909 "runtime_constraints": {},
912 fmt.Fprintf(s.executor.created.Stdout, "workdir=%q", s.executor.created.WorkingDir)
915 c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
916 c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
917 c.Log(s.api.Logs["stdout"])
918 c.Check(s.api.Logs["stdout"].String(), Matches, `.*workdir=""\n`)
921 func (s *TestSuite) TestFullRunSetCwd(c *C) {
922 s.fullRunHelper(c, `{
924 "container_image": "`+arvadostest.DockerImage112PDH+`",
927 "mounts": {"/tmp": {"kind": "tmp"} },
928 "output_path": "/tmp",
930 "runtime_constraints": {},
933 fmt.Fprintln(s.executor.created.Stdout, s.executor.created.WorkingDir)
936 c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
937 c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
938 c.Check(s.api.Logs["stdout"].String(), Matches, ".*/bin\n")
941 func (s *TestSuite) TestFullRunSetOutputStorageClasses(c *C) {
942 s.fullRunHelper(c, `{
944 "container_image": "`+arvadostest.DockerImage112PDH+`",
947 "mounts": {"/tmp": {"kind": "tmp"} },
948 "output_path": "/tmp",
950 "runtime_constraints": {},
952 "output_storage_classes": ["foo", "bar"]
954 fmt.Fprintln(s.executor.created.Stdout, s.executor.created.WorkingDir)
957 c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
958 c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
959 c.Check(s.api.Logs["stdout"].String(), Matches, ".*/bin\n")
960 c.Check(s.testDispatcherKeepClient.StorageClasses, DeepEquals, []string{"foo", "bar"})
961 c.Check(s.testContainerKeepClient.StorageClasses, DeepEquals, []string{"foo", "bar"})
964 func (s *TestSuite) TestStopOnSignal(c *C) {
965 s.executor.runFunc = func() {
966 s.executor.created.Stdout.Write([]byte("foo\n"))
967 s.runner.SigChan <- syscall.SIGINT
969 s.testStopContainer(c)
972 func (s *TestSuite) TestStopOnArvMountDeath(c *C) {
973 s.executor.runFunc = func() {
974 s.executor.created.Stdout.Write([]byte("foo\n"))
975 s.runner.ArvMountExit <- nil
976 close(s.runner.ArvMountExit)
978 s.runner.ArvMountExit = make(chan error)
979 s.testStopContainer(c)
982 func (s *TestSuite) testStopContainer(c *C) {
984 "command": ["/bin/sh", "-c", "echo foo && sleep 30 && echo bar"],
985 "container_image": "` + arvadostest.DockerImage112PDH + `",
988 "mounts": {"/tmp": {"kind": "tmp"} },
989 "output_path": "/tmp",
991 "runtime_constraints": {},
995 err := json.Unmarshal([]byte(record), &s.api.Container)
998 s.runner.RunArvMount = func([]string, string) (*exec.Cmd, error) { return nil, nil }
999 s.runner.MkArvClient = func(token string) (IArvadosClient, IKeepClient, *arvados.Client, error) {
1000 return &ArvTestClient{}, &KeepTestClient{}, nil, nil
1003 done := make(chan error)
1005 done <- s.runner.Run()
1008 case <-time.After(20 * time.Second):
1009 pprof.Lookup("goroutine").WriteTo(os.Stderr, 1)
1010 c.Fatal("timed out")
1014 for k, v := range s.api.Logs {
1016 c.Log(v.String(), "\n")
1019 c.Check(s.api.CalledWith("container.log", nil), NotNil)
1020 c.Check(s.api.CalledWith("container.state", "Cancelled"), NotNil)
1021 c.Check(s.api.Logs["stdout"].String(), Matches, "(?ms).*foo\n$")
1024 func (s *TestSuite) TestFullRunSetEnv(c *C) {
1025 s.fullRunHelper(c, `{
1026 "command": ["/bin/sh", "-c", "echo $FROBIZ"],
1027 "container_image": "`+arvadostest.DockerImage112PDH+`",
1029 "environment": {"FROBIZ": "bilbo"},
1030 "mounts": {"/tmp": {"kind": "tmp"} },
1031 "output_path": "/tmp",
1033 "runtime_constraints": {},
1035 }`, nil, 0, func() {
1036 fmt.Fprintf(s.executor.created.Stdout, "%v", s.executor.created.Env)
1039 c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
1040 c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
1041 c.Check(s.api.Logs["stdout"].String(), Matches, `.*map\[FROBIZ:bilbo\]\n`)
1044 type ArvMountCmdLine struct {
1049 func (am *ArvMountCmdLine) ArvMountTest(c []string, token string) (*exec.Cmd, error) {
1055 func stubCert(temp string) string {
1056 path := temp + "/ca-certificates.crt"
1057 crt, _ := os.Create(path)
1059 arvadosclient.CertFiles = []string{path}
1063 func (s *TestSuite) TestSetupMounts(c *C) {
1065 am := &ArvMountCmdLine{}
1066 cr.RunArvMount = am.ArvMountTest
1067 cr.ContainerArvClient = &ArvTestClient{}
1068 cr.ContainerKeepClient = &KeepTestClient{}
1069 cr.Container.OutputStorageClasses = []string{"default"}
1071 realTemp := c.MkDir()
1072 certTemp := c.MkDir()
1073 stubCertPath := stubCert(certTemp)
1074 cr.parentTemp = realTemp
1077 cr.MkTempDir = func(_ string, prefix string) (string, error) {
1079 d := fmt.Sprintf("%s/%s%d", realTemp, prefix, i)
1080 err := os.Mkdir(d, os.ModePerm)
1081 if err != nil && strings.Contains(err.Error(), ": file exists") {
1082 // Test case must have pre-populated the tempdir
1088 checkEmpty := func() {
1089 // Should be deleted.
1090 _, err := os.Stat(realTemp)
1091 c.Assert(os.IsNotExist(err), Equals, true)
1093 // Now recreate it for the next test.
1094 c.Assert(os.Mkdir(realTemp, 0777), IsNil)
1099 cr.ArvMountPoint = ""
1100 cr.Container.Mounts = make(map[string]arvados.Mount)
1101 cr.Container.Mounts["/tmp"] = arvados.Mount{Kind: "tmp"}
1102 cr.Container.OutputPath = "/tmp"
1103 cr.statInterval = 5 * time.Second
1104 bindmounts, err := cr.SetupMounts()
1106 c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--allow-other",
1107 "--read-write", "--storage-classes", "default", "--crunchstat-interval=5",
1108 "--mount-by-pdh", "by_id", "--mount-by-id", "by_uuid", realTemp + "/keep1"})
1109 c.Check(bindmounts, DeepEquals, map[string]bindmount{"/tmp": {realTemp + "/tmp2", false}})
1110 os.RemoveAll(cr.ArvMountPoint)
1117 cr.ArvMountPoint = ""
1118 cr.Container.Mounts = make(map[string]arvados.Mount)
1119 cr.Container.Mounts["/out"] = arvados.Mount{Kind: "tmp"}
1120 cr.Container.Mounts["/tmp"] = arvados.Mount{Kind: "tmp"}
1121 cr.Container.OutputPath = "/out"
1122 cr.Container.OutputStorageClasses = []string{"foo", "bar"}
1124 bindmounts, err := cr.SetupMounts()
1126 c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--allow-other",
1127 "--read-write", "--storage-classes", "foo,bar", "--crunchstat-interval=5",
1128 "--mount-by-pdh", "by_id", "--mount-by-id", "by_uuid", realTemp + "/keep1"})
1129 c.Check(bindmounts, DeepEquals, map[string]bindmount{"/out": {realTemp + "/tmp2", false}, "/tmp": {realTemp + "/tmp3", false}})
1130 os.RemoveAll(cr.ArvMountPoint)
1137 cr.ArvMountPoint = ""
1138 cr.Container.Mounts = make(map[string]arvados.Mount)
1139 cr.Container.Mounts["/tmp"] = arvados.Mount{Kind: "tmp"}
1140 cr.Container.OutputPath = "/tmp"
1141 cr.Container.RuntimeConstraints.API = true
1142 cr.Container.OutputStorageClasses = []string{"default"}
1144 bindmounts, err := cr.SetupMounts()
1146 c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--allow-other",
1147 "--read-write", "--storage-classes", "default", "--crunchstat-interval=5",
1148 "--mount-by-pdh", "by_id", "--mount-by-id", "by_uuid", realTemp + "/keep1"})
1149 c.Check(bindmounts, DeepEquals, map[string]bindmount{"/tmp": {realTemp + "/tmp2", false}, "/etc/arvados/ca-certificates.crt": {stubCertPath, true}})
1150 os.RemoveAll(cr.ArvMountPoint)
1154 cr.Container.RuntimeConstraints.API = false
1159 cr.ArvMountPoint = ""
1160 cr.Container.Mounts = map[string]arvados.Mount{
1161 "/keeptmp": {Kind: "collection", Writable: true},
1163 cr.Container.OutputPath = "/keeptmp"
1165 os.MkdirAll(realTemp+"/keep1/tmp0", os.ModePerm)
1167 bindmounts, err := cr.SetupMounts()
1169 c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--allow-other",
1170 "--read-write", "--storage-classes", "default", "--crunchstat-interval=5",
1171 "--mount-tmp", "tmp0", "--mount-by-pdh", "by_id", "--mount-by-id", "by_uuid", realTemp + "/keep1"})
1172 c.Check(bindmounts, DeepEquals, map[string]bindmount{"/keeptmp": {realTemp + "/keep1/tmp0", false}})
1173 os.RemoveAll(cr.ArvMountPoint)
1180 cr.ArvMountPoint = ""
1181 cr.Container.Mounts = map[string]arvados.Mount{
1182 "/keepinp": {Kind: "collection", PortableDataHash: "59389a8f9ee9d399be35462a0f92541c+53"},
1183 "/keepout": {Kind: "collection", Writable: true},
1185 cr.Container.OutputPath = "/keepout"
1187 os.MkdirAll(realTemp+"/keep1/by_id/59389a8f9ee9d399be35462a0f92541c+53", os.ModePerm)
1188 os.MkdirAll(realTemp+"/keep1/tmp0", os.ModePerm)
1190 bindmounts, err := cr.SetupMounts()
1192 c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--allow-other",
1193 "--read-write", "--storage-classes", "default", "--crunchstat-interval=5",
1194 "--mount-tmp", "tmp0", "--mount-by-pdh", "by_id", "--mount-by-id", "by_uuid", realTemp + "/keep1"})
1195 c.Check(bindmounts, DeepEquals, map[string]bindmount{
1196 "/keepinp": {realTemp + "/keep1/by_id/59389a8f9ee9d399be35462a0f92541c+53", true},
1197 "/keepout": {realTemp + "/keep1/tmp0", false},
1199 os.RemoveAll(cr.ArvMountPoint)
1206 cr.ArvMountPoint = ""
1207 cr.Container.RuntimeConstraints.KeepCacheRAM = 512
1208 cr.Container.Mounts = map[string]arvados.Mount{
1209 "/keepinp": {Kind: "collection", PortableDataHash: "59389a8f9ee9d399be35462a0f92541c+53"},
1210 "/keepout": {Kind: "collection", Writable: true},
1212 cr.Container.OutputPath = "/keepout"
1214 os.MkdirAll(realTemp+"/keep1/by_id/59389a8f9ee9d399be35462a0f92541c+53", os.ModePerm)
1215 os.MkdirAll(realTemp+"/keep1/tmp0", os.ModePerm)
1217 bindmounts, err := cr.SetupMounts()
1219 c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--allow-other",
1220 "--read-write", "--storage-classes", "default", "--crunchstat-interval=5",
1221 "--file-cache", "512", "--mount-tmp", "tmp0", "--mount-by-pdh", "by_id", "--mount-by-id", "by_uuid", realTemp + "/keep1"})
1222 c.Check(bindmounts, DeepEquals, map[string]bindmount{
1223 "/keepinp": {realTemp + "/keep1/by_id/59389a8f9ee9d399be35462a0f92541c+53", true},
1224 "/keepout": {realTemp + "/keep1/tmp0", false},
1226 os.RemoveAll(cr.ArvMountPoint)
1231 for _, test := range []struct {
1235 {in: "foo", out: `"foo"`},
1236 {in: nil, out: `null`},
1237 {in: map[string]int64{"foo": 123456789123456789}, out: `{"foo":123456789123456789}`},
1240 cr.ArvMountPoint = ""
1241 cr.Container.Mounts = map[string]arvados.Mount{
1242 "/mnt/test.json": {Kind: "json", Content: test.in},
1244 bindmounts, err := cr.SetupMounts()
1246 c.Check(bindmounts, DeepEquals, map[string]bindmount{
1247 "/mnt/test.json": {realTemp + "/json2/mountdata.json", true},
1249 content, err := ioutil.ReadFile(realTemp + "/json2/mountdata.json")
1251 c.Check(content, DeepEquals, []byte(test.out))
1252 os.RemoveAll(cr.ArvMountPoint)
1257 for _, test := range []struct {
1261 {in: "foo", out: `foo`},
1262 {in: nil, out: "error"},
1263 {in: map[string]int64{"foo": 123456789123456789}, out: "error"},
1266 cr.ArvMountPoint = ""
1267 cr.Container.Mounts = map[string]arvados.Mount{
1268 "/mnt/test.txt": {Kind: "text", Content: test.in},
1270 bindmounts, err := cr.SetupMounts()
1271 if test.out == "error" {
1272 c.Check(err.Error(), Equals, "content for mount \"/mnt/test.txt\" must be a string")
1275 c.Check(bindmounts, DeepEquals, map[string]bindmount{
1276 "/mnt/test.txt": {realTemp + "/text2/mountdata.text", true},
1278 content, err := ioutil.ReadFile(realTemp + "/text2/mountdata.text")
1280 c.Check(content, DeepEquals, []byte(test.out))
1282 os.RemoveAll(cr.ArvMountPoint)
1287 // Read-only mount points are allowed underneath output_dir mount point
1290 cr.ArvMountPoint = ""
1291 cr.Container.Mounts = make(map[string]arvados.Mount)
1292 cr.Container.Mounts = map[string]arvados.Mount{
1293 "/tmp": {Kind: "tmp"},
1294 "/tmp/foo": {Kind: "collection"},
1296 cr.Container.OutputPath = "/tmp"
1298 os.MkdirAll(realTemp+"/keep1/tmp0", os.ModePerm)
1300 bindmounts, err := cr.SetupMounts()
1302 c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--allow-other",
1303 "--read-write", "--storage-classes", "default", "--crunchstat-interval=5",
1304 "--file-cache", "512", "--mount-tmp", "tmp0", "--mount-by-pdh", "by_id", "--mount-by-id", "by_uuid", realTemp + "/keep1"})
1305 c.Check(bindmounts, DeepEquals, map[string]bindmount{
1306 "/tmp": {realTemp + "/tmp2", false},
1307 "/tmp/foo": {realTemp + "/keep1/tmp0", true},
1309 os.RemoveAll(cr.ArvMountPoint)
1314 // Writable mount points copied to output_dir mount point
1317 cr.ArvMountPoint = ""
1318 cr.Container.Mounts = make(map[string]arvados.Mount)
1319 cr.Container.Mounts = map[string]arvados.Mount{
1320 "/tmp": {Kind: "tmp"},
1321 "/tmp/foo": {Kind: "collection",
1322 PortableDataHash: "59389a8f9ee9d399be35462a0f92541c+53",
1324 "/tmp/bar": {Kind: "collection",
1325 PortableDataHash: "59389a8f9ee9d399be35462a0f92541d+53",
1329 cr.Container.OutputPath = "/tmp"
1331 os.MkdirAll(realTemp+"/keep1/by_id/59389a8f9ee9d399be35462a0f92541c+53", os.ModePerm)
1332 os.MkdirAll(realTemp+"/keep1/by_id/59389a8f9ee9d399be35462a0f92541d+53/baz", os.ModePerm)
1334 rf, _ := os.Create(realTemp + "/keep1/by_id/59389a8f9ee9d399be35462a0f92541d+53/baz/quux")
1335 rf.Write([]byte("bar"))
1338 _, err := cr.SetupMounts()
1340 _, err = os.Stat(cr.HostOutputDir + "/foo")
1342 _, err = os.Stat(cr.HostOutputDir + "/bar/quux")
1344 os.RemoveAll(cr.ArvMountPoint)
1349 // Only mount points of kind 'collection' are allowed underneath output_dir mount point
1352 cr.ArvMountPoint = ""
1353 cr.Container.Mounts = make(map[string]arvados.Mount)
1354 cr.Container.Mounts = map[string]arvados.Mount{
1355 "/tmp": {Kind: "tmp"},
1356 "/tmp/foo": {Kind: "tmp"},
1358 cr.Container.OutputPath = "/tmp"
1360 _, err := cr.SetupMounts()
1361 c.Check(err, NotNil)
1362 c.Check(err, ErrorMatches, `only mount points of kind 'collection', 'text' or 'json' are supported underneath the output_path.*`)
1363 os.RemoveAll(cr.ArvMountPoint)
1368 // Only mount point of kind 'collection' is allowed for stdin
1371 cr.ArvMountPoint = ""
1372 cr.Container.Mounts = make(map[string]arvados.Mount)
1373 cr.Container.Mounts = map[string]arvados.Mount{
1374 "stdin": {Kind: "tmp"},
1377 _, err := cr.SetupMounts()
1378 c.Check(err, NotNil)
1379 c.Check(err, ErrorMatches, `unsupported mount kind 'tmp' for stdin.*`)
1380 os.RemoveAll(cr.ArvMountPoint)
1388 cr.ArvMountPoint = ""
1389 (*GitMountSuite)(nil).useTestGitServer(c)
1390 cr.token = arvadostest.ActiveToken
1391 cr.Container.Mounts = make(map[string]arvados.Mount)
1392 cr.Container.Mounts = map[string]arvados.Mount{
1395 UUID: arvadostest.Repository2UUID,
1396 Commit: "fd3531f42995344f36c30b79f55f27b502f3d344",
1401 UUID: arvadostest.Repository2UUID,
1402 Commit: "5ebfab0522851df01fec11ec55a6d0f4877b542e",
1406 cr.Container.OutputPath = "/tmp"
1408 bindmounts, err := cr.SetupMounts()
1411 for path, mount := range bindmounts {
1412 c.Check(mount.ReadOnly, Equals, !cr.Container.Mounts[path].Writable, Commentf("%s %#v", path, mount))
1415 data, err := ioutil.ReadFile(bindmounts["/tip"].HostPath + "/dir1/dir2/file with mode 0644")
1417 c.Check(string(data), Equals, "\000\001\002\003")
1418 _, err = ioutil.ReadFile(bindmounts["/tip"].HostPath + "/file only on testbranch")
1419 c.Check(err, FitsTypeOf, &os.PathError{})
1420 c.Check(os.IsNotExist(err), Equals, true)
1422 data, err = ioutil.ReadFile(bindmounts["/non-tip"].HostPath + "/dir1/dir2/file with mode 0644")
1424 c.Check(string(data), Equals, "\000\001\002\003")
1425 data, err = ioutil.ReadFile(bindmounts["/non-tip"].HostPath + "/file only on testbranch")
1427 c.Check(string(data), Equals, "testfile\n")
1434 func (s *TestSuite) TestStdout(c *C) {
1436 "command": ["/bin/sh", "-c", "echo $FROBIZ"],
1437 "container_image": "` + arvadostest.DockerImage112PDH + `",
1439 "environment": {"FROBIZ": "bilbo"},
1440 "mounts": {"/tmp": {"kind": "tmp"}, "stdout": {"kind": "file", "path": "/tmp/a/b/c.out"} },
1441 "output_path": "/tmp",
1443 "runtime_constraints": {},
1447 s.fullRunHelper(c, helperRecord, nil, 0, func() {
1448 fmt.Fprintln(s.executor.created.Stdout, s.executor.created.Env["FROBIZ"])
1451 c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
1452 c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
1453 c.Check(s.runner.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", "./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out\n"), NotNil)
1456 // Used by the TestStdoutWithWrongPath*()
1457 func (s *TestSuite) stdoutErrorRunHelper(c *C, record string, fn func()) (*ArvTestClient, *ContainerRunner, error) {
1458 err := json.Unmarshal([]byte(record), &s.api.Container)
1459 c.Assert(err, IsNil)
1460 s.executor.runFunc = fn
1461 s.runner.RunArvMount = (&ArvMountCmdLine{}).ArvMountTest
1462 s.runner.MkArvClient = func(token string) (IArvadosClient, IKeepClient, *arvados.Client, error) {
1463 return s.api, &KeepTestClient{}, nil, nil
1465 return s.api, s.runner, s.runner.Run()
1468 func (s *TestSuite) TestStdoutWithWrongPath(c *C) {
1469 _, _, err := s.stdoutErrorRunHelper(c, `{
1470 "mounts": {"/tmp": {"kind": "tmp"}, "stdout": {"kind": "file", "path":"/tmpa.out"} },
1471 "output_path": "/tmp",
1474 c.Check(err, ErrorMatches, ".*Stdout path does not start with OutputPath.*")
1477 func (s *TestSuite) TestStdoutWithWrongKindTmp(c *C) {
1478 _, _, err := s.stdoutErrorRunHelper(c, `{
1479 "mounts": {"/tmp": {"kind": "tmp"}, "stdout": {"kind": "tmp", "path":"/tmp/a.out"} },
1480 "output_path": "/tmp",
1483 c.Check(err, ErrorMatches, ".*unsupported mount kind 'tmp' for stdout.*")
1486 func (s *TestSuite) TestStdoutWithWrongKindCollection(c *C) {
1487 _, _, err := s.stdoutErrorRunHelper(c, `{
1488 "mounts": {"/tmp": {"kind": "tmp"}, "stdout": {"kind": "collection", "path":"/tmp/a.out"} },
1489 "output_path": "/tmp",
1492 c.Check(err, ErrorMatches, ".*unsupported mount kind 'collection' for stdout.*")
1495 func (s *TestSuite) TestFullRunWithAPI(c *C) {
1496 s.fullRunHelper(c, `{
1497 "command": ["/bin/sh", "-c", "true $ARVADOS_API_HOST"],
1498 "container_image": "`+arvadostest.DockerImage112PDH+`",
1501 "mounts": {"/tmp": {"kind": "tmp"} },
1502 "output_path": "/tmp",
1504 "runtime_constraints": {"API": true},
1506 }`, nil, 0, func() {
1507 c.Check(s.executor.created.Env["ARVADOS_API_HOST"], Equals, os.Getenv("ARVADOS_API_HOST"))
1508 s.executor.exit <- 3
1510 c.Check(s.api.CalledWith("container.exit_code", 3), NotNil)
1511 c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
1514 func (s *TestSuite) TestFullRunSetOutput(c *C) {
1515 defer os.Setenv("ARVADOS_API_HOST", os.Getenv("ARVADOS_API_HOST"))
1516 os.Setenv("ARVADOS_API_HOST", "test.arvados.org")
1517 s.fullRunHelper(c, `{
1518 "command": ["/bin/sh", "-c", "echo $ARVADOS_API_HOST"],
1519 "container_image": "`+arvadostest.DockerImage112PDH+`",
1522 "mounts": {"/tmp": {"kind": "tmp"} },
1523 "output_path": "/tmp",
1525 "runtime_constraints": {"API": true},
1527 }`, nil, 0, func() {
1528 s.api.Container.Output = arvadostest.DockerImage112PDH
1531 c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
1532 c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
1533 c.Check(s.api.CalledWith("container.output", arvadostest.DockerImage112PDH), NotNil)
1536 func (s *TestSuite) TestStdoutWithExcludeFromOutputMountPointUnderOutputDir(c *C) {
1538 "command": ["/bin/sh", "-c", "echo $FROBIZ"],
1539 "container_image": "` + arvadostest.DockerImage112PDH + `",
1541 "environment": {"FROBIZ": "bilbo"},
1543 "/tmp": {"kind": "tmp"},
1544 "/tmp/foo": {"kind": "collection",
1545 "portable_data_hash": "a3e8f74c6f101eae01fa08bfb4e49b3a+54",
1546 "exclude_from_output": true
1548 "stdout": {"kind": "file", "path": "/tmp/a/b/c.out"}
1550 "output_path": "/tmp",
1552 "runtime_constraints": {},
1556 extraMounts := []string{"a3e8f74c6f101eae01fa08bfb4e49b3a+54"}
1558 s.fullRunHelper(c, helperRecord, extraMounts, 0, func() {
1559 fmt.Fprintln(s.executor.created.Stdout, s.executor.created.Env["FROBIZ"])
1562 c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
1563 c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
1564 c.Check(s.runner.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", "./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out\n"), NotNil)
1567 func (s *TestSuite) TestStdoutWithMultipleMountPointsUnderOutputDir(c *C) {
1569 "command": ["/bin/sh", "-c", "echo $FROBIZ"],
1570 "container_image": "` + arvadostest.DockerImage112PDH + `",
1572 "environment": {"FROBIZ": "bilbo"},
1574 "/tmp": {"kind": "tmp"},
1575 "/tmp/foo/bar": {"kind": "collection", "portable_data_hash": "a0def87f80dd594d4675809e83bd4f15+367", "path":"/file2_in_main.txt"},
1576 "/tmp/foo/sub1": {"kind": "collection", "portable_data_hash": "a0def87f80dd594d4675809e83bd4f15+367", "path":"/subdir1"},
1577 "/tmp/foo/sub1file2": {"kind": "collection", "portable_data_hash": "a0def87f80dd594d4675809e83bd4f15+367", "path":"/subdir1/file2_in_subdir1.txt"},
1578 "/tmp/foo/baz/sub2file2": {"kind": "collection", "portable_data_hash": "a0def87f80dd594d4675809e83bd4f15+367", "path":"/subdir1/subdir2/file2_in_subdir2.txt"},
1579 "stdout": {"kind": "file", "path": "/tmp/a/b/c.out"}
1581 "output_path": "/tmp",
1583 "runtime_constraints": {},
1587 extraMounts := []string{
1588 "a0def87f80dd594d4675809e83bd4f15+367/file2_in_main.txt",
1589 "a0def87f80dd594d4675809e83bd4f15+367/subdir1/file2_in_subdir1.txt",
1590 "a0def87f80dd594d4675809e83bd4f15+367/subdir1/subdir2/file2_in_subdir2.txt",
1593 api, _, realtemp := s.fullRunHelper(c, helperRecord, extraMounts, 0, func() {
1594 fmt.Fprintln(s.executor.created.Stdout, s.executor.created.Env["FROBIZ"])
1597 c.Check(s.executor.created.BindMounts, DeepEquals, map[string]bindmount{
1598 "/tmp": {realtemp + "/tmp1", false},
1599 "/tmp/foo/bar": {s.keepmount + "/by_id/a0def87f80dd594d4675809e83bd4f15+367/file2_in_main.txt", true},
1600 "/tmp/foo/baz/sub2file2": {s.keepmount + "/by_id/a0def87f80dd594d4675809e83bd4f15+367/subdir1/subdir2/file2_in_subdir2.txt", true},
1601 "/tmp/foo/sub1": {s.keepmount + "/by_id/a0def87f80dd594d4675809e83bd4f15+367/subdir1", true},
1602 "/tmp/foo/sub1file2": {s.keepmount + "/by_id/a0def87f80dd594d4675809e83bd4f15+367/subdir1/file2_in_subdir1.txt", true},
1605 c.Check(api.CalledWith("container.exit_code", 0), NotNil)
1606 c.Check(api.CalledWith("container.state", "Complete"), NotNil)
1607 for _, v := range api.Content {
1608 if v["collection"] != nil {
1609 c.Check(v["ensure_unique_name"], Equals, true)
1610 collection := v["collection"].(arvadosclient.Dict)
1611 if strings.Index(collection["name"].(string), "output") == 0 {
1612 manifest := collection["manifest_text"].(string)
1614 c.Check(manifest, Equals, `./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out
1615 ./foo 3e426d509afffb85e06c4c96a7c15e91+27+Aa124ac75e5168396c73c0abcdefgh11234567890@569fa8c3 3e426d509afffb85e06c4c96a7c15e91+27+Aa124ac75e5168396cabcdefghij6419876543234@569fa8c4 9:18:bar 36:18:sub1file2
1616 ./foo/baz 3e426d509afffb85e06c4c96a7c15e91+27+Aa124ac75e5168396c73c0bcdefghijk544332211@569fa8c5 9:18:sub2file2
1617 ./foo/sub1 3e426d509afffb85e06c4c96a7c15e91+27+Aa124ac75e5168396cabcdefghij6419876543234@569fa8c4 0:9:file1_in_subdir1.txt 9:18:file2_in_subdir1.txt
1618 ./foo/sub1/subdir2 3e426d509afffb85e06c4c96a7c15e91+27+Aa124ac75e5168396c73c0bcdefghijk544332211@569fa8c5 0:9:file1_in_subdir2.txt 9:18:file2_in_subdir2.txt
1625 func (s *TestSuite) TestStdoutWithMountPointsUnderOutputDirDenormalizedManifest(c *C) {
1627 "command": ["/bin/sh", "-c", "echo $FROBIZ"],
1628 "container_image": "` + arvadostest.DockerImage112PDH + `",
1630 "environment": {"FROBIZ": "bilbo"},
1632 "/tmp": {"kind": "tmp"},
1633 "/tmp/foo/bar": {"kind": "collection", "portable_data_hash": "b0def87f80dd594d4675809e83bd4f15+367", "path": "/subdir1/file2_in_subdir1.txt"},
1634 "stdout": {"kind": "file", "path": "/tmp/a/b/c.out"}
1636 "output_path": "/tmp",
1638 "runtime_constraints": {},
1642 extraMounts := []string{
1643 "b0def87f80dd594d4675809e83bd4f15+367/subdir1/file2_in_subdir1.txt",
1646 s.fullRunHelper(c, helperRecord, extraMounts, 0, func() {
1647 fmt.Fprintln(s.executor.created.Stdout, s.executor.created.Env["FROBIZ"])
1650 c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
1651 c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
1652 for _, v := range s.api.Content {
1653 if v["collection"] != nil {
1654 collection := v["collection"].(arvadosclient.Dict)
1655 if strings.Index(collection["name"].(string), "output") == 0 {
1656 manifest := collection["manifest_text"].(string)
1658 c.Check(manifest, Equals, `./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out
1659 ./foo 3e426d509afffb85e06c4c96a7c15e91+27+Aa124ac75e5168396c73c0abcdefgh11234567890@569fa8c3 10:17:bar
1666 func (s *TestSuite) TestOutputError(c *C) {
1668 "command": ["/bin/sh", "-c", "echo $FROBIZ"],
1669 "container_image": "` + arvadostest.DockerImage112PDH + `",
1671 "environment": {"FROBIZ": "bilbo"},
1673 "/tmp": {"kind": "tmp"}
1675 "output_path": "/tmp",
1677 "runtime_constraints": {},
1680 s.fullRunHelper(c, helperRecord, nil, 0, func() {
1681 os.Symlink("/etc/hosts", s.runner.HostOutputDir+"/baz")
1684 c.Check(s.api.CalledWith("container.state", "Cancelled"), NotNil)
1687 func (s *TestSuite) TestStdinCollectionMountPoint(c *C) {
1689 "command": ["/bin/sh", "-c", "echo $FROBIZ"],
1690 "container_image": "` + arvadostest.DockerImage112PDH + `",
1692 "environment": {"FROBIZ": "bilbo"},
1694 "/tmp": {"kind": "tmp"},
1695 "stdin": {"kind": "collection", "portable_data_hash": "b0def87f80dd594d4675809e83bd4f15+367", "path": "/file1_in_main.txt"},
1696 "stdout": {"kind": "file", "path": "/tmp/a/b/c.out"}
1698 "output_path": "/tmp",
1700 "runtime_constraints": {},
1704 extraMounts := []string{
1705 "b0def87f80dd594d4675809e83bd4f15+367/file1_in_main.txt",
1708 api, _, _ := s.fullRunHelper(c, helperRecord, extraMounts, 0, func() {
1709 fmt.Fprintln(s.executor.created.Stdout, s.executor.created.Env["FROBIZ"])
1712 c.Check(api.CalledWith("container.exit_code", 0), NotNil)
1713 c.Check(api.CalledWith("container.state", "Complete"), NotNil)
1714 for _, v := range api.Content {
1715 if v["collection"] != nil {
1716 collection := v["collection"].(arvadosclient.Dict)
1717 if strings.Index(collection["name"].(string), "output") == 0 {
1718 manifest := collection["manifest_text"].(string)
1719 c.Check(manifest, Equals, `./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out
1726 func (s *TestSuite) TestStdinJsonMountPoint(c *C) {
1728 "command": ["/bin/sh", "-c", "echo $FROBIZ"],
1729 "container_image": "` + arvadostest.DockerImage112PDH + `",
1731 "environment": {"FROBIZ": "bilbo"},
1733 "/tmp": {"kind": "tmp"},
1734 "stdin": {"kind": "json", "content": "foo"},
1735 "stdout": {"kind": "file", "path": "/tmp/a/b/c.out"}
1737 "output_path": "/tmp",
1739 "runtime_constraints": {},
1743 api, _, _ := s.fullRunHelper(c, helperRecord, nil, 0, func() {
1744 fmt.Fprintln(s.executor.created.Stdout, s.executor.created.Env["FROBIZ"])
1747 c.Check(api.CalledWith("container.exit_code", 0), NotNil)
1748 c.Check(api.CalledWith("container.state", "Complete"), NotNil)
1749 for _, v := range api.Content {
1750 if v["collection"] != nil {
1751 collection := v["collection"].(arvadosclient.Dict)
1752 if strings.Index(collection["name"].(string), "output") == 0 {
1753 manifest := collection["manifest_text"].(string)
1754 c.Check(manifest, Equals, `./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out
1761 func (s *TestSuite) TestStderrMount(c *C) {
1762 api, cr, _ := s.fullRunHelper(c, `{
1763 "command": ["/bin/sh", "-c", "echo hello;exit 1"],
1764 "container_image": "`+arvadostest.DockerImage112PDH+`",
1767 "mounts": {"/tmp": {"kind": "tmp"},
1768 "stdout": {"kind": "file", "path": "/tmp/a/out.txt"},
1769 "stderr": {"kind": "file", "path": "/tmp/b/err.txt"}},
1770 "output_path": "/tmp",
1772 "runtime_constraints": {},
1774 }`, nil, 1, func() {
1775 fmt.Fprintln(s.executor.created.Stdout, "hello")
1776 fmt.Fprintln(s.executor.created.Stderr, "oops")
1779 final := api.CalledWith("container.state", "Complete")
1780 c.Assert(final, NotNil)
1781 c.Check(final["container"].(arvadosclient.Dict)["exit_code"], Equals, 1)
1782 c.Check(final["container"].(arvadosclient.Dict)["log"], NotNil)
1784 c.Check(cr.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", "./a b1946ac92492d2347c6235b4d2611184+6 0:6:out.txt\n./b 38af5c54926b620264ab1501150cf189+5 0:5:err.txt\n"), NotNil)
1787 func (s *TestSuite) TestNumberRoundTrip(c *C) {
1788 s.api.callraw = true
1789 err := s.runner.fetchContainerRecord()
1790 c.Assert(err, IsNil)
1791 jsondata, err := json.Marshal(s.runner.Container.Mounts["/json"].Content)
1792 c.Logf("%#v", s.runner.Container)
1794 c.Check(string(jsondata), Equals, `{"number":123456789123456789}`)
1797 func (s *TestSuite) TestFullBrokenDocker(c *C) {
1799 for _, setup := range []func(){
1801 c.Log("// waitErr = ocl runtime error")
1802 s.executor.waitErr = errors.New(`Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "process_linux.go:359: container init caused \"rootfs_linux.go:54: mounting \\\"/tmp/keep453790790/by_id/99999999999999999999999999999999+99999/myGenome\\\" to rootfs \\\"/tmp/docker/overlay2/9999999999999999999999999999999999999999999999999999999999999999/merged\\\" at \\\"/tmp/docker/overlay2/9999999999999999999999999999999999999999999999999999999999999999/merged/keep/99999999999999999999999999999999+99999/myGenome\\\" caused \\\"no such file or directory\\\"\""`)
1803 nextState = "Cancelled"
1806 c.Log("// loadErr = cannot connect")
1807 s.executor.loadErr = errors.New("Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?")
1808 *brokenNodeHook = c.MkDir() + "/broken-node-hook"
1809 err := ioutil.WriteFile(*brokenNodeHook, []byte("#!/bin/sh\nexec echo killme\n"), 0700)
1810 c.Assert(err, IsNil)
1811 nextState = "Queued"
1816 s.fullRunHelper(c, `{
1817 "command": ["echo", "hello world"],
1818 "container_image": "`+arvadostest.DockerImage112PDH+`",
1821 "mounts": {"/tmp": {"kind": "tmp"} },
1822 "output_path": "/tmp",
1824 "runtime_constraints": {},
1826 }`, nil, 0, func() {})
1827 c.Check(s.api.CalledWith("container.state", nextState), NotNil)
1828 c.Check(s.api.Logs["crunch-run"].String(), Matches, "(?ms).*unable to run containers.*")
1829 if *brokenNodeHook != "" {
1830 c.Check(s.api.Logs["crunch-run"].String(), Matches, "(?ms).*Running broken node hook.*")
1831 c.Check(s.api.Logs["crunch-run"].String(), Matches, "(?ms).*killme.*")
1832 c.Check(s.api.Logs["crunch-run"].String(), Not(Matches), "(?ms).*Writing /var/lock/crunch-run-broken to mark node as broken.*")
1834 c.Check(s.api.Logs["crunch-run"].String(), Matches, "(?ms).*Writing /var/lock/crunch-run-broken to mark node as broken.*")
1839 func (s *TestSuite) TestBadCommand(c *C) {
1840 for _, startError := range []string{
1841 `panic: standard_init_linux.go:175: exec user process caused "no such file or directory"`,
1842 `Error response from daemon: Cannot start container 41f26cbc43bcc1280f4323efb1830a394ba8660c9d1c2b564ba42bf7f7694845: [8] System error: no such file or directory`,
1843 `Error response from daemon: Cannot start container 58099cd76c834f3dc2a4fb76c8028f049ae6d4fdf0ec373e1f2cfea030670c2d: [8] System error: exec: "foobar": executable file not found in $PATH`,
1846 s.executor.startErr = errors.New(startError)
1847 s.fullRunHelper(c, `{
1848 "command": ["echo", "hello world"],
1849 "container_image": "`+arvadostest.DockerImage112PDH+`",
1852 "mounts": {"/tmp": {"kind": "tmp"} },
1853 "output_path": "/tmp",
1855 "runtime_constraints": {},
1857 }`, nil, 0, func() {})
1858 c.Check(s.api.CalledWith("container.state", "Cancelled"), NotNil)
1859 c.Check(s.api.Logs["crunch-run"].String(), Matches, "(?ms).*Possible causes:.*is missing.*")
1863 func (s *TestSuite) TestSecretTextMountPoint(c *C) {
1865 "command": ["true"],
1866 "container_image": "` + arvadostest.DockerImage112PDH + `",
1869 "/tmp": {"kind": "tmp"},
1870 "/tmp/secret.conf": {"kind": "text", "content": "mypassword"}
1874 "output_path": "/tmp",
1876 "runtime_constraints": {},
1880 s.fullRunHelper(c, helperRecord, nil, 0, func() {
1881 content, err := ioutil.ReadFile(s.runner.HostOutputDir + "/secret.conf")
1883 c.Check(string(content), Equals, "mypassword")
1886 c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
1887 c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
1888 c.Check(s.runner.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", ". 34819d7beeabb9260a5c854bc85b3e44+10 0:10:secret.conf\n"), NotNil)
1889 c.Check(s.runner.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", ""), IsNil)
1891 // under secret mounts, not captured in output
1893 "command": ["true"],
1894 "container_image": "` + arvadostest.DockerImage112PDH + `",
1897 "/tmp": {"kind": "tmp"}
1900 "/tmp/secret.conf": {"kind": "text", "content": "mypassword"}
1902 "output_path": "/tmp",
1904 "runtime_constraints": {},
1909 s.fullRunHelper(c, helperRecord, nil, 0, func() {
1910 content, err := ioutil.ReadFile(s.runner.HostOutputDir + "/secret.conf")
1912 c.Check(string(content), Equals, "mypassword")
1915 c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
1916 c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
1917 c.Check(s.runner.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", ". 34819d7beeabb9260a5c854bc85b3e44+10 0:10:secret.conf\n"), IsNil)
1918 c.Check(s.runner.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", ""), NotNil)
1921 type FakeProcess struct {
1925 func (fp FakeProcess) CmdlineSlice() ([]string, error) {
1926 return fp.cmdLine, nil