[ARVADOS] updated: 8499ff832a8b7d072f0ac2dd91e97991ab82579f
git at public.curoverse.com
git at public.curoverse.com
Sun Feb 14 22:58:03 EST 2016
Summary of changes:
services/crunch-run/crunchrun.go | 13 +++++---
services/crunch-run/crunchrun_test.go | 59 +++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 4 deletions(-)
via 8499ff832a8b7d072f0ac2dd91e97991ab82579f (commit)
via b13366d7446cd9ba67a0cf2d436d1a18f8b993b5 (commit)
from 4e676bd941adc7c4751a3ef03aed8f145d432c0c (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 8499ff832a8b7d072f0ac2dd91e97991ab82579f
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Sun Feb 14 22:58:00 2016 -0500
8015: Expand arv-mount command line tests
diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go
index a6d23ab..e90ede6 100644
--- a/services/crunch-run/crunchrun.go
+++ b/services/crunch-run/crunchrun.go
@@ -242,6 +242,7 @@ func (runner *ContainerRunner) SetupMounts() (err error) {
tmpcount := 0
arvMountCmd := []string{"--foreground"}
collectionPaths := []string{}
+ runner.Binds = nil
for bind, mnt := range runner.ContainerRecord.Mounts {
if mnt.Kind == "collection" {
@@ -261,9 +262,9 @@ func (runner *ContainerRunner) SetupMounts() (err error) {
}
src = fmt.Sprintf("%s/by_id/%s", runner.ArvMountPoint, mnt.PortableDataHash)
} else {
- src = fmt.Sprintf("%s/tmp%i", runner.ArvMountPoint, tmpcount)
+ src = fmt.Sprintf("%s/tmp%d", runner.ArvMountPoint, tmpcount)
arvMountCmd = append(arvMountCmd, "--mount-tmp")
- arvMountCmd = append(arvMountCmd, fmt.Sprintf("tmp%i", tmpcount))
+ arvMountCmd = append(arvMountCmd, fmt.Sprintf("tmp%d", tmpcount))
tmpcount += 1
}
if mnt.Writable {
diff --git a/services/crunch-run/crunchrun_test.go b/services/crunch-run/crunchrun_test.go
index bdc2413..72e09b1 100644
--- a/services/crunch-run/crunchrun_test.go
+++ b/services/crunch-run/crunchrun_test.go
@@ -13,6 +13,7 @@ import (
. "gopkg.in/check.v1"
"io"
"io/ioutil"
+ "os"
"os/exec"
"strings"
"syscall"
@@ -674,7 +675,7 @@ func (s *TestSuite) TestSetupMounts(c *C) {
i := 0
cr.MkTempDir = func(string, string) (string, error) {
i += 1
- return fmt.Sprintf("/tmp/mktmpdir%v", i), nil
+ return fmt.Sprintf("/tmp/mktmpdir%d", i), nil
}
cr.ContainerRecord.Mounts = make(map[string]Mount)
@@ -685,4 +686,29 @@ func (s *TestSuite) TestSetupMounts(c *C) {
c.Check(err, IsNil)
c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--mount-by-pdh", "by_id", "/tmp/mktmpdir1"})
c.Check(cr.Binds, DeepEquals, []string{"/tmp/mktmpdir2:/tmp"})
+
+ i = 0
+ cr.ContainerRecord.Mounts = make(map[string]Mount)
+ cr.ContainerRecord.Mounts["/keeptmp"] = Mount{Kind: "collection", Writable: true}
+ cr.OutputPath = "/keeptmp"
+
+ os.MkdirAll("/tmp/mktmpdir1/tmp0", os.ModePerm)
+
+ err = cr.SetupMounts()
+ c.Check(err, IsNil)
+ c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--mount-tmp", "tmp0", "--mount-by-pdh", "by_id", "/tmp/mktmpdir1"})
+ c.Check(cr.Binds, DeepEquals, []string{"/tmp/mktmpdir1/tmp0:/keeptmp"})
+
+ i = 0
+ cr.ContainerRecord.Mounts = make(map[string]Mount)
+ cr.ContainerRecord.Mounts["/keepinp"] = Mount{Kind: "collection", PortableDataHash: "59389a8f9ee9d399be35462a0f92541c+53"}
+ cr.ContainerRecord.Mounts["/keeptmp"] = Mount{Kind: "collection", Writable: true}
+ cr.OutputPath = "/keeptmp"
+
+ os.MkdirAll("/tmp/mktmpdir1/by_id/59389a8f9ee9d399be35462a0f92541c+53", os.ModePerm)
+
+ err = cr.SetupMounts()
+ c.Check(err, IsNil)
+ c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--mount-tmp", "tmp0", "--mount-by-pdh", "by_id", "/tmp/mktmpdir1"})
+ c.Check(cr.Binds, DeepEquals, []string{"/tmp/mktmpdir1/by_id/59389a8f9ee9d399be35462a0f92541c+53:/keepinp:ro", "/tmp/mktmpdir1/tmp0:/keeptmp"})
}
commit b13366d7446cd9ba67a0cf2d436d1a18f8b993b5
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Sun Feb 14 22:27:24 2016 -0500
8015: Add arv-mount command line test
diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go
index 665f107..a6d23ab 100644
--- a/services/crunch-run/crunchrun.go
+++ b/services/crunch-run/crunchrun.go
@@ -72,6 +72,8 @@ type NewLogWriter func(name string) io.WriteCloser
type RunArvMount func([]string) (*exec.Cmd, error)
+type MkTempDir func(string, string) (string, error)
+
// ThinDockerClient is the minimal Docker client interface used by crunch-run.
type ThinDockerClient interface {
StopContainer(id string, timeout int) error
@@ -102,6 +104,7 @@ type ContainerRunner struct {
LogCollection *CollectionWriter
LogsPDH *string
RunArvMount
+ MkTempDir
ArvMount *exec.Cmd
ArvMountPoint string
HostOutputDir string
@@ -230,7 +233,7 @@ func (runner *ContainerRunner) ArvMountCmd(arvMountCmd []string) (c *exec.Cmd, e
}
func (runner *ContainerRunner) SetupMounts() (err error) {
- runner.ArvMountPoint, err = ioutil.TempDir("", "keep")
+ runner.ArvMountPoint, err = runner.MkTempDir("", "keep")
if err != nil {
return fmt.Errorf("While creating keep mount temp dir: %v", err)
}
@@ -274,7 +277,7 @@ func (runner *ContainerRunner) SetupMounts() (err error) {
collectionPaths = append(collectionPaths, src)
} else if mnt.Kind == "tmp" {
if bind == runner.ContainerRecord.OutputPath {
- runner.HostOutputDir, err = ioutil.TempDir("", "")
+ runner.HostOutputDir, err = runner.MkTempDir("", "")
if err != nil {
return fmt.Errorf("While creating mount temp dir: %v", err)
}
@@ -640,6 +643,7 @@ func NewContainerRunner(api IArvadosClient,
cr := &ContainerRunner{ArvClient: api, Kc: kc, Docker: docker}
cr.NewLogWriter = cr.NewArvLogWriter
cr.RunArvMount = cr.ArvMountCmd
+ cr.MkTempDir = ioutil.TempDir
cr.LogCollection = &CollectionWriter{kc, nil, sync.Mutex{}}
cr.ContainerRecord.UUID = containerUUID
cr.CrunchLog = NewThrottledLogger(cr.NewLogWriter("crunch-run"))
diff --git a/services/crunch-run/crunchrun_test.go b/services/crunch-run/crunchrun_test.go
index 48c22a3..bdc2413 100644
--- a/services/crunch-run/crunchrun_test.go
+++ b/services/crunch-run/crunchrun_test.go
@@ -13,6 +13,7 @@ import (
. "gopkg.in/check.v1"
"io"
"io/ioutil"
+ "os/exec"
"strings"
"syscall"
"testing"
@@ -653,3 +654,35 @@ func (s *TestSuite) TestFullRunSetEnv(c *C) {
c.Check(strings.HasSuffix(api.Logs["stdout"].String(), "bilbo\n"), Equals, true)
}
+
+type ArvMountCmdLine struct {
+ Cmd []string
+}
+
+func (am *ArvMountCmdLine) ArvMountTest(c []string) (*exec.Cmd, error) {
+ am.Cmd = c
+ return nil, nil
+}
+
+func (s *TestSuite) TestSetupMounts(c *C) {
+ api := &ArvTestClient{}
+ kc := &KeepTestClient{}
+ cr := NewContainerRunner(api, kc, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
+ am := &ArvMountCmdLine{}
+ cr.RunArvMount = am.ArvMountTest
+
+ i := 0
+ cr.MkTempDir = func(string, string) (string, error) {
+ i += 1
+ return fmt.Sprintf("/tmp/mktmpdir%v", i), nil
+ }
+
+ cr.ContainerRecord.Mounts = make(map[string]Mount)
+ cr.ContainerRecord.Mounts["/tmp"] = Mount{Kind: "tmp"}
+ cr.OutputPath = "/tmp"
+
+ err := cr.SetupMounts()
+ c.Check(err, IsNil)
+ c.Check(am.Cmd, DeepEquals, []string{"--foreground", "--mount-by-pdh", "by_id", "/tmp/mktmpdir1"})
+ c.Check(cr.Binds, DeepEquals, []string{"/tmp/mktmpdir2:/tmp"})
+}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list