X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8fd18fc4a32797fc3c6255099fc253d7aede12b5..b9b4502bcddeccd794614bf6979d643f9f350877:/services/crunch-run/crunchrun_test.go diff --git a/services/crunch-run/crunchrun_test.go b/services/crunch-run/crunchrun_test.go index f124359fd6..c8427563cb 100644 --- a/services/crunch-run/crunchrun_test.go +++ b/services/crunch-run/crunchrun_test.go @@ -249,7 +249,16 @@ func (client *ArvTestClient) Update(resourceType string, uuid string, parameters return nil } -var discoveryMap = map[string]interface{}{"defaultTrashLifetime": float64(1209600)} +var discoveryMap = map[string]interface{}{ + "defaultTrashLifetime": float64(1209600), + "crunchLimitLogBytesPerJob": float64(67108864), + "crunchLogThrottleBytes": float64(65536), + "crunchLogThrottlePeriod": float64(60), + "crunchLogThrottleLines": float64(1024), + "crunchLogPartialLineThrottlePeriod": float64(5), + "crunchLogBytesPerEvent": float64(4096), + "crunchLogSecondsBetweenEvents": float64(1), +} func (client *ArvTestClient) Discovery(key string) (interface{}, error) { return discoveryMap[key], nil @@ -300,12 +309,7 @@ func (client *KeepTestClient) ManifestFileReader(m manifest.Manifest, filename s rdr := ioutil.NopCloser(&bytes.Buffer{}) client.Called = true return FileWrapper{rdr, 1321984}, nil - } - return nil, nil -} - -func (client *KeepTestClient) CollectionFileReader(collection map[string]interface{}, filename string) (keepclient.Reader, error) { - if filename == "/file1_in_main.txt" { + } else if filename == "/file1_in_main.txt" { rdr := ioutil.NopCloser(strings.NewReader("foo")) client.Called = true return FileWrapper{rdr, 3}, nil @@ -392,10 +396,6 @@ func (KeepErrorTestClient) ManifestFileReader(m manifest.Manifest, filename stri return nil, errors.New("KeepError") } -func (KeepErrorTestClient) CollectionFileReader(c map[string]interface{}, f string) (keepclient.Reader, error) { - return nil, errors.New("KeepError") -} - type KeepReadErrorTestClient struct{} func (KeepReadErrorTestClient) PutHB(hash string, buf []byte) (string, int, error) { @@ -424,10 +424,6 @@ func (KeepReadErrorTestClient) ManifestFileReader(m manifest.Manifest, filename return ErrorReader{}, nil } -func (KeepReadErrorTestClient) CollectionFileReader(c map[string]interface{}, f string) (keepclient.Reader, error) { - return ErrorReader{}, nil -} - func (s *TestSuite) TestLoadImageArvError(c *C) { // (1) Arvados error cr := NewContainerRunner(ArvErrorTestClient{}, &KeepTestClient{}, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz") @@ -981,6 +977,22 @@ func (s *TestSuite) TestSetupMounts(c *C) { checkEmpty() } + { + i = 0 + cr.ArvMountPoint = "" + cr.Container.Mounts = make(map[string]arvados.Mount) + cr.Container.Mounts["/out"] = arvados.Mount{Kind: "tmp"} + cr.Container.Mounts["/tmp"] = arvados.Mount{Kind: "tmp"} + cr.OutputPath = "/out" + + err := cr.SetupMounts() + c.Check(err, IsNil) + c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--allow-other", "--read-write", "--mount-by-pdh", "by_id", realTemp + "/keep1"}) + c.Check(cr.Binds, DeepEquals, []string{realTemp + "/2:/out", realTemp + "/3:/tmp"}) + cr.CleanupDirs() + checkEmpty() + } + { i = 0 cr.ArvMountPoint = "" @@ -1439,7 +1451,6 @@ func (s *TestSuite) TestStdinCollectionMountPoint(c *C) { collection := v["collection"].(arvadosclient.Dict) if strings.Index(collection["name"].(string), "output") == 0 { manifest := collection["manifest_text"].(string) - c.Check(manifest, Equals, `./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out `) } @@ -1475,10 +1486,35 @@ func (s *TestSuite) TestStdinJsonMountPoint(c *C) { collection := v["collection"].(arvadosclient.Dict) if strings.Index(collection["name"].(string), "output") == 0 { manifest := collection["manifest_text"].(string) - c.Check(manifest, Equals, `./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out `) } } } } + +func (s *TestSuite) TestStderrMount(c *C) { + api, _, _ := FullRunHelper(c, `{ + "command": ["/bin/sh", "-c", "echo hello;exit 1"], + "container_image": "d4ab34d3d4f8a72f5c4973051ae69fab+122", + "cwd": ".", + "environment": {}, + "mounts": {"/tmp": {"kind": "tmp"}, + "stdout": {"kind": "file", "path": "/tmp/a/out.txt"}, + "stderr": {"kind": "file", "path": "/tmp/b/err.txt"}}, + "output_path": "/tmp", + "priority": 1, + "runtime_constraints": {} +}`, nil, 1, func(t *TestDockerClient) { + t.logWriter.Write(dockerLog(1, "hello\n")) + t.logWriter.Write(dockerLog(2, "oops\n")) + t.logWriter.Close() + }) + + final := api.CalledWith("container.state", "Complete") + c.Assert(final, NotNil) + c.Check(final["container"].(arvadosclient.Dict)["exit_code"], Equals, 1) + c.Check(final["container"].(arvadosclient.Dict)["log"], NotNil) + + c.Check(api.CalledWith("collection.manifest_text", "./a b1946ac92492d2347c6235b4d2611184+6 0:6:out.txt\n./b 38af5c54926b620264ab1501150cf189+5 0:5:err.txt\n"), NotNil) +}