Merge branch '18600-copy-by-ref'
authorTom Clegg <tom@curii.com>
Thu, 17 Feb 2022 17:52:27 +0000 (12:52 -0500)
committerTom Clegg <tom@curii.com>
Thu, 17 Feb 2022 17:52:27 +0000 (12:52 -0500)
refs #18600

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

1  2 
lib/crunchrun/crunchrun_test.go

index 806a83eef9aa789beeefaf5849051281428e8d81,f961ec8f46a93acada5f7f14f07e460f689af3e2..26f78d2bf7d537c7a44f0b8dd57eda4355211b5b
@@@ -44,7 -44,6 +44,7 @@@ type TestSuite struct 
        runner                   *ContainerRunner
        executor                 *stubExecutor
        keepmount                string
 +      keepmountTmp             []string
        testDispatcherKeepClient KeepTestClient
        testContainerKeepClient  KeepTestClient
  }
@@@ -63,20 -62,10 +63,20 @@@ func (s *TestSuite) SetUpTest(c *C) 
        }
        s.runner.RunArvMount = func(cmd []string, tok string) (*exec.Cmd, error) {
                s.runner.ArvMountPoint = s.keepmount
 +              for i, opt := range cmd {
 +                      if opt == "--mount-tmp" {
 +                              err := os.Mkdir(s.keepmount+"/"+cmd[i+1], 0700)
 +                              if err != nil {
 +                                      return nil, err
 +                              }
 +                              s.keepmountTmp = append(s.keepmountTmp, cmd[i+1])
 +                      }
 +              }
                return nil, nil
        }
        s.keepmount = c.MkDir()
        err = os.Mkdir(s.keepmount+"/by_id", 0755)
 +      s.keepmountTmp = nil
        c.Assert(err, IsNil)
        err = os.Mkdir(s.keepmount+"/by_id/"+arvadostest.DockerImage112PDH, 0755)
        c.Assert(err, IsNil)
@@@ -375,6 -364,14 +375,14 @@@ func (fw FileWrapper) Sync() error 
        return errors.New("not implemented")
  }
  
+ func (fw FileWrapper) Snapshot() (*arvados.Subtree, error) {
+       return nil, errors.New("not implemented")
+ }
+ func (fw FileWrapper) Splice(*arvados.Subtree) error {
+       return errors.New("not implemented")
+ }
  func (client *KeepTestClient) ManifestFileReader(m manifest.Manifest, filename string) (arvados.File, error) {
        if filename == hwImageID+".tar" {
                rdr := ioutil.NopCloser(&bytes.Buffer{})
@@@ -649,6 -646,8 +657,6 @@@ func (s *TestSuite) fullRunHelper(c *C
  
        s.runner.statInterval = 100 * time.Millisecond
        s.runner.containerWatchdogInterval = time.Second
 -      am := &ArvMountCmdLine{}
 -      s.runner.RunArvMount = am.ArvMountTest
  
        realTemp := c.MkDir()
        tempcount := 0
@@@ -2016,44 -2015,6 +2024,44 @@@ func (s *TestSuite) TestSecretTextMount
        c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
        c.Check(s.runner.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", ". 34819d7beeabb9260a5c854bc85b3e44+10 0:10:secret.conf\n"), IsNil)
        c.Check(s.runner.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", ""), NotNil)
 +
 +      // under secret mounts, output dir is a collection, not captured in output
 +      helperRecord = `{
 +              "command": ["true"],
 +              "container_image": "` + arvadostest.DockerImage112PDH + `",
 +              "cwd": "/bin",
 +              "mounts": {
 +                    "/tmp": {"kind": "collection", "writable": true}
 +                },
 +                "secret_mounts": {
 +                    "/tmp/secret.conf": {"kind": "text", "content": "mypassword"}
 +                },
 +              "output_path": "/tmp",
 +              "priority": 1,
 +              "runtime_constraints": {},
 +              "state": "Locked"
 +      }`
 +
 +      s.SetUpTest(c)
 +      _, _, realtemp := s.fullRunHelper(c, helperRecord, nil, 0, func() {
 +              // secret.conf should be provisioned as a separate
 +              // bind mount, i.e., it should not appear in the
 +              // (fake) fuse filesystem as viewed from the host.
 +              content, err := ioutil.ReadFile(s.runner.HostOutputDir + "/secret.conf")
 +              if !c.Check(errors.Is(err, os.ErrNotExist), Equals, true) {
 +                      c.Logf("secret.conf: content %q, err %#v", content, err)
 +              }
 +              err = ioutil.WriteFile(s.runner.HostOutputDir+"/.arvados#collection", []byte(`{"manifest_text":". acbd18db4cc2f85cedef654fccc4a4d8+3 0:3:foo.txt\n"}`), 0700)
 +              c.Check(err, IsNil)
 +      })
 +
 +      content, err := ioutil.ReadFile(realtemp + "/text1/mountdata.text")
 +      c.Check(err, IsNil)
 +      c.Check(string(content), Equals, "mypassword")
 +      c.Check(s.executor.created.BindMounts["/tmp/secret.conf"], DeepEquals, bindmount{realtemp + "/text1/mountdata.text", true})
 +      c.Check(s.api.CalledWith("container.exit_code", 0), NotNil)
 +      c.Check(s.api.CalledWith("container.state", "Complete"), NotNil)
 +      c.Check(s.runner.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", ". acbd18db4cc2f85cedef654fccc4a4d8+3 0:3:foo.txt\n"), NotNil)
  }
  
  type FakeProcess struct {