[ARVADOS] updated: 2.1.0-1717-g87a18ef2c

Git user git at public.arvados.org
Mon Dec 13 18:59:52 UTC 2021


Summary of changes:
 lib/crunchrun/crunchrun_test.go   | 37 +++++++++++++++++++++++++++++++++++++
 lib/crunchrun/singularity.go      | 18 +++++++++++-------
 lib/crunchrun/singularity_test.go | 23 +++++++++++++++++++++++
 3 files changed, 71 insertions(+), 7 deletions(-)

       via  87a18ef2c05487c4330e6fb6ce6c7934f6bea5a6 (commit)
      from  dde7a01a8dba17936f6100de09a0203aaf9225b8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 87a18ef2c05487c4330e6fb6ce6c7934f6bea5a6
Author: Tom Clegg <tom at curii.com>
Date:   Mon Dec 13 13:58:13 2021 -0500

    12630: Test containerSpec setup and singularity exec args.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/lib/crunchrun/crunchrun_test.go b/lib/crunchrun/crunchrun_test.go
index c28cf73cb..67b18857b 100644
--- a/lib/crunchrun/crunchrun_test.go
+++ b/lib/crunchrun/crunchrun_test.go
@@ -715,6 +715,7 @@ func (s *TestSuite) TestFullRunHello(c *C) {
 		c.Check(s.executor.created.RAM, Equals, int64(1000000))
 		c.Check(s.executor.created.NetworkMode, Equals, "default")
 		c.Check(s.executor.created.EnableNetwork, Equals, false)
+		c.Check(s.executor.created.CUDADeviceCount, Equals, 0)
 		fmt.Fprintln(s.executor.created.Stdout, "hello world")
 	})
 
@@ -982,6 +983,42 @@ func (s *TestSuite) TestFullRunSetOutputStorageClasses(c *C) {
 	c.Check(s.testContainerKeepClient.StorageClasses, DeepEquals, []string{"foo", "bar"})
 }
 
+func (s *TestSuite) TestEnableCUDADeviceCount(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": {"cuda_device_count": 2},
+    "state": "Locked",
+    "output_storage_classes": ["foo", "bar"]
+}`, nil, 0, func() {
+		fmt.Fprintln(s.executor.created.Stdout, "ok")
+	})
+	c.Check(s.executor.created.CUDADeviceCount, Equals, 2)
+}
+
+func (s *TestSuite) TestEnableCUDAHardwareCapability(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": {"cuda_hardware_capability": "foo"},
+    "state": "Locked",
+    "output_storage_classes": ["foo", "bar"]
+}`, nil, 0, func() {
+		fmt.Fprintln(s.executor.created.Stdout, "ok")
+	})
+	c.Check(s.executor.created.CUDADeviceCount, Equals, 1)
+}
+
 func (s *TestSuite) TestStopOnSignal(c *C) {
 	s.executor.runFunc = func() {
 		s.executor.created.Stdout.Write([]byte("foo\n"))
diff --git a/lib/crunchrun/singularity.go b/lib/crunchrun/singularity.go
index 2128aeb22..cda10aa61 100644
--- a/lib/crunchrun/singularity.go
+++ b/lib/crunchrun/singularity.go
@@ -241,8 +241,8 @@ func (e *singularityExecutor) Create(spec containerSpec) error {
 	return nil
 }
 
-func (e *singularityExecutor) Start() error {
-	args := []string{"singularity", "exec", "--containall", "--cleanenv", "--pwd", e.spec.WorkingDir}
+func (e *singularityExecutor) execCmd(path string) *exec.Cmd {
+	args := []string{path, "exec", "--containall", "--cleanenv", "--pwd", e.spec.WorkingDir}
 	if !e.spec.EnableNetwork {
 		args = append(args, "--net", "--network=none")
 	}
@@ -287,11 +287,7 @@ func (e *singularityExecutor) Start() error {
 	args = append(args, e.imageFilename)
 	args = append(args, e.spec.Command...)
 
-	path, err := exec.LookPath(args[0])
-	if err != nil {
-		return err
-	}
-	child := &exec.Cmd{
+	return &exec.Cmd{
 		Path:   path,
 		Args:   args,
 		Env:    env,
@@ -299,6 +295,14 @@ func (e *singularityExecutor) Start() error {
 		Stdout: e.spec.Stdout,
 		Stderr: e.spec.Stderr,
 	}
+}
+
+func (e *singularityExecutor) Start() error {
+	path, err := exec.LookPath("singularity")
+	if err != nil {
+		return err
+	}
+	child := e.execCmd(path)
 	err = child.Start()
 	if err != nil {
 		return err
diff --git a/lib/crunchrun/singularity_test.go b/lib/crunchrun/singularity_test.go
index a1263da32..cdeafee88 100644
--- a/lib/crunchrun/singularity_test.go
+++ b/lib/crunchrun/singularity_test.go
@@ -27,3 +27,26 @@ func (s *singularitySuite) SetUpSuite(c *C) {
 		c.Assert(err, IsNil)
 	}
 }
+
+var _ = Suite(&singularityStubSuite{})
+
+// singularityStubSuite tests don't really invoke singularity, so we
+// can run them even if singularity is not installed.
+type singularityStubSuite struct{}
+
+func (s *singularityStubSuite) TestSingularityExecArgs(c *C) {
+	e, err := newSingularityExecutor(c.Logf)
+	c.Assert(err, IsNil)
+	err = e.Create(containerSpec{
+		WorkingDir:      "/WorkingDir",
+		Env:             map[string]string{"FOO": "bar"},
+		BindMounts:      map[string]bindmount{"/mnt": {HostPath: "/hostpath", ReadOnly: true}},
+		EnableNetwork:   false,
+		CUDADeviceCount: 3,
+	})
+	c.Check(err, IsNil)
+	e.imageFilename = "/fake/image.sif"
+	cmd := e.execCmd("./singularity")
+	c.Check(cmd.Args, DeepEquals, []string{"./singularity", "exec", "--containall", "--cleanenv", "--pwd", "/WorkingDir", "--net", "--network=none", "--nv", "--bind", "/hostpath:/mnt:ro", "/fake/image.sif"})
+	c.Check(cmd.Env, DeepEquals, []string{"SINGULARITYENV_FOO=bar"})
+}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list