From 7f80639c3641ca9fa500789121c537477f856379 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Tue, 29 Jun 2021 16:10:47 -0400 Subject: [PATCH] 17395: Add tests. Don't include storage classes in full text search Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- lib/crunchrun/crunchrun_test.go | 33 +++++++++++++++++--- services/api/app/models/container.rb | 4 +-- services/api/app/models/container_request.rb | 2 +- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/lib/crunchrun/crunchrun_test.go b/lib/crunchrun/crunchrun_test.go index 3539a3f656..4b1bf84255 100644 --- a/lib/crunchrun/crunchrun_test.go +++ b/lib/crunchrun/crunchrun_test.go @@ -547,8 +547,6 @@ func (s *TestSuite) TestRunContainer(c *C) { c.Check(logs.Stdout.String(), Matches, ".*Hello world\n") c.Check(logs.Stderr.String(), Equals, "") - c.Check(s.testDispatcherKeepClient, Equals, []string{"default"}) - c.Check(s.testContainerKeepClient, Equals, []string{"default"}) } func (s *TestSuite) TestCommitLogs(c *C) { @@ -664,7 +662,7 @@ func (s *TestSuite) fullRunHelper(c *C, record string, extraMounts []string, exi return d, err } s.runner.MkArvClient = func(token string) (IArvadosClient, IKeepClient, *arvados.Client, error) { - return &ArvTestClient{secretMounts: secretMounts}, &KeepTestClient{}, nil, nil + return &ArvTestClient{secretMounts: secretMounts}, &s.testContainerKeepClient, nil, nil } if extraMounts != nil && len(extraMounts) > 0 { @@ -715,7 +713,8 @@ func (s *TestSuite) TestFullRunHello(c *C) { "output_path": "/tmp", "priority": 1, "runtime_constraints": {"vcpus":1,"ram":1000000}, - "state": "Locked" + "state": "Locked", + "output_storage_classes": ["default"] }`, nil, 0, func() { c.Check(s.executor.created.Command, DeepEquals, []string{"echo", "hello world"}) c.Check(s.executor.created.Image, Equals, "sha256:d8309758b8fe2c81034ffc8a10c36460b77db7bc5e7b448c4e5b684f9d95a678") @@ -730,7 +729,8 @@ func (s *TestSuite) TestFullRunHello(c *C) { c.Check(s.api.CalledWith("container.exit_code", 0), NotNil) c.Check(s.api.CalledWith("container.state", "Complete"), NotNil) c.Check(s.api.Logs["stdout"].String(), Matches, ".*hello world\n") - + c.Check(s.testDispatcherKeepClient.StorageClasses, DeepEquals, []string{"default"}) + c.Check(s.testContainerKeepClient.StorageClasses, DeepEquals, []string{"default"}) } func (s *TestSuite) TestRunAlreadyRunning(c *C) { @@ -947,6 +947,29 @@ func (s *TestSuite) TestFullRunSetCwd(c *C) { c.Check(s.api.Logs["stdout"].String(), Matches, ".*/bin\n") } +func (s *TestSuite) TestFullRunSetOutputStorageClasses(c *C) { + s.fullRunHelper(c, `{ + "command": ["pwd"], + "container_image": "`+arvadostest.DockerImage112PDH+`", + "cwd": "/bin", + "environment": {}, + "mounts": {"/tmp": {"kind": "tmp"} }, + "output_path": "/tmp", + "priority": 1, + "runtime_constraints": {}, + "state": "Locked", + "output_storage_classes": ["foo", "bar"] +}`, nil, 0, func() { + fmt.Fprintln(s.executor.created.Stdout, s.executor.created.WorkingDir) + }) + + c.Check(s.api.CalledWith("container.exit_code", 0), NotNil) + c.Check(s.api.CalledWith("container.state", "Complete"), NotNil) + c.Check(s.api.Logs["stdout"].String(), Matches, ".*/bin\n") + c.Check(s.testDispatcherKeepClient.StorageClasses, DeepEquals, []string{"foo", "bar"}) + c.Check(s.testContainerKeepClient.StorageClasses, DeepEquals, []string{"foo", "bar"}) +} + func (s *TestSuite) TestStopOnSignal(c *C) { s.executor.runFunc = func() { s.executor.created.Stdout.Write([]byte("foo\n")) diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb index a844fbaf77..ddae458189 100644 --- a/services/api/app/models/container.rb +++ b/services/api/app/models/container.rb @@ -106,11 +106,11 @@ class Container < ArvadosModel end def self.full_text_searchable_columns - super - ["secret_mounts", "secret_mounts_md5", "runtime_token", "gateway_address"] + super - ["secret_mounts", "secret_mounts_md5", "runtime_token", "gateway_address", "output_storage_classes"] end def self.searchable_columns *args - super - ["secret_mounts_md5", "runtime_token", "gateway_address"] + super - ["secret_mounts_md5", "runtime_token", "gateway_address", "output_storage_classes"] end def logged_attributes diff --git a/services/api/app/models/container_request.rb b/services/api/app/models/container_request.rb index f47fff792f..1de71102c6 100644 --- a/services/api/app/models/container_request.rb +++ b/services/api/app/models/container_request.rb @@ -243,7 +243,7 @@ class ContainerRequest < ArvadosModel end def self.full_text_searchable_columns - super - ["mounts", "secret_mounts", "secret_mounts_md5", "runtime_token"] + super - ["mounts", "secret_mounts", "secret_mounts_md5", "runtime_token", "output_storage_classes"] end protected -- 2.39.5