17395: Add tests. Don't include storage classes in full text search
authorPeter Amstutz <peter.amstutz@curii.com>
Tue, 29 Jun 2021 20:10:47 +0000 (16:10 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Tue, 29 Jun 2021 20:10:47 +0000 (16:10 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

lib/crunchrun/crunchrun_test.go
services/api/app/models/container.rb
services/api/app/models/container_request.rb

index 3539a3f65612cacbb2c2bf4e4b4a58935f6d9ef1..4b1bf8425533e0aaaecdcf3229835edbfbaaef47 100644 (file)
@@ -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"))
index a844fbaf773249e784ebe5a0f588771a8e3bdb31..ddae4581892dd8f1bbe727ff0b67b04addb4c0a0 100644 (file)
@@ -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
index f47fff792ffeaeb26394b4306d6c84ae7b74ab97..1de71102c61befff8e0aabef5885e7396405a237 100644 (file)
@@ -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