[ARVADOS] updated: 1.1.1-232-g08edbfd

Git user git at public.curoverse.com
Wed Dec 13 17:14:29 EST 2017


Summary of changes:
 services/crunch-run/crunchrun_test.go | 59 +++++++++++++++++++++++++++++++++++
 services/crunch-run/git_mount.go      |  3 ++
 services/crunch-run/git_mount_test.go | 30 +++++++++++++-----
 3 files changed, 84 insertions(+), 8 deletions(-)

       via  08edbfda915126a1e142fd72d81be17318e59889 (commit)
      from  f96fbd63314748dbe389ccb1b5b37f3fae4688ac (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 08edbfda915126a1e142fd72d81be17318e59889
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date:   Wed Dec 13 17:13:42 2017 -0500

    8311: Try some git_tree mounts in TestSetupMounts.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>

diff --git a/services/crunch-run/crunchrun_test.go b/services/crunch-run/crunchrun_test.go
index e1d9fed..4d76e34 100644
--- a/services/crunch-run/crunchrun_test.go
+++ b/services/crunch-run/crunchrun_test.go
@@ -28,6 +28,7 @@ import (
 
 	"git.curoverse.com/arvados.git/sdk/go/arvados"
 	"git.curoverse.com/arvados.git/sdk/go/arvadosclient"
+	"git.curoverse.com/arvados.git/sdk/go/arvadostest"
 	"git.curoverse.com/arvados.git/sdk/go/manifest"
 
 	dockertypes "github.com/docker/docker/api/types"
@@ -1263,6 +1264,64 @@ func (s *TestSuite) TestSetupMounts(c *C) {
 		cr.CleanupDirs()
 		checkEmpty()
 	}
+
+	// git_tree mounts
+	{
+		i = 0
+		cr.ArvMountPoint = ""
+		(*GitMountSuite)(nil).useTestGitServer(c)
+		cr.Container.Mounts = make(map[string]arvados.Mount)
+		cr.Container.Mounts = map[string]arvados.Mount{
+			"/tip": {
+				Kind:   "git_tree",
+				UUID:   arvadostest.Repository2UUID,
+				Commit: "fd3531f42995344f36c30b79f55f27b502f3d344",
+				Path:   "/",
+			},
+			"/non-tip": {
+				Kind:     "git_tree",
+				UUID:     arvadostest.Repository2UUID,
+				Commit:   "5ebfab0522851df01fec11ec55a6d0f4877b542e",
+				Path:     "/",
+				Writable: true,
+			},
+		}
+		cr.OutputPath = "/tmp"
+
+		err := cr.SetupMounts()
+		c.Check(err, IsNil)
+
+		// dirMap[mountpoint] == tmpdir
+		dirMap := make(map[string]string)
+		for _, bind := range cr.Binds {
+			tokens := strings.Split(bind, ":")
+			dirMap[tokens[1]] = tokens[0]
+
+			if cr.Container.Mounts[tokens[1]].Writable {
+				c.Check(len(tokens), Equals, 2)
+			} else {
+				c.Check(len(tokens), Equals, 3)
+				c.Check(tokens[2], Equals, "ro")
+			}
+		}
+
+		data, err := ioutil.ReadFile(dirMap["/tip"] + "/dir1/dir2/file with mode 0644")
+		c.Check(err, IsNil)
+		c.Check(string(data), Equals, "\000\001\002\003")
+		_, err = ioutil.ReadFile(dirMap["/tip"] + "/file only on testbranch")
+		c.Check(err, FitsTypeOf, &os.PathError{})
+		c.Check(os.IsNotExist(err), Equals, true)
+
+		data, err = ioutil.ReadFile(dirMap["/non-tip"] + "/dir1/dir2/file with mode 0644")
+		c.Check(err, IsNil)
+		c.Check(string(data), Equals, "\000\001\002\003")
+		data, err = ioutil.ReadFile(dirMap["/non-tip"] + "/file only on testbranch")
+		c.Check(err, IsNil)
+		c.Check(string(data), Equals, "testfile\n")
+
+		cr.CleanupDirs()
+		checkEmpty()
+	}
 }
 
 func (s *TestSuite) TestStdout(c *C) {
diff --git a/services/crunch-run/git_mount.go b/services/crunch-run/git_mount.go
index a792741..110a81b 100644
--- a/services/crunch-run/git_mount.go
+++ b/services/crunch-run/git_mount.go
@@ -33,7 +33,10 @@ func (gm gitMount) extractTree(ac IArvadosClient, dir string) error {
 	baseURL, err := ac.Discovery("gitUrl")
 	if err != nil {
 		return fmt.Errorf("discover gitUrl from API: %s", err)
+	} else if _, ok := baseURL.(string); !ok {
+		return fmt.Errorf("discover gitUrl from API: expected string, found %T", baseURL)
 	}
+
 	u, err := url.Parse(baseURL.(string))
 	if err != nil {
 		return fmt.Errorf("parse gitUrl %q: %s", baseURL, err)
diff --git a/services/crunch-run/git_mount_test.go b/services/crunch-run/git_mount_test.go
index 4c6ce7f..e984000 100644
--- a/services/crunch-run/git_mount_test.go
+++ b/services/crunch-run/git_mount_test.go
@@ -22,15 +22,10 @@ type GitMountSuite struct {
 
 var _ = check.Suite(&GitMountSuite{})
 
-func (s *GitMountSuite) SetUpSuite(c *check.C) {
-	git_client.InstallProtocol("https", git_http.NewClient(arvados.InsecureHTTPClient))
-}
-
 func (s *GitMountSuite) SetUpTest(c *check.C) {
-	port, err := ioutil.ReadFile("../../tmp/arv-git-httpd-ssl.port")
-	c.Assert(err, check.IsNil)
-	discoveryMap["gitUrl"] = "https://localhost:" + string(port)
+	s.useTestGitServer(c)
 
+	var err error
 	s.tmpdir, err = ioutil.TempDir("", "")
 	c.Assert(err, check.IsNil)
 }
@@ -117,6 +112,17 @@ func (s *GitMountSuite) TestNonexistentCommit(c *check.C) {
 	s.checkTmpdirContents(c, []string{})
 }
 
+func (s *GitMountSuite) TestGitUrlDiscoveryFails(c *check.C) {
+	delete(discoveryMap, "gitUrl")
+	gm := gitMount{
+		Path:   "/",
+		UUID:   arvadostest.Repository2UUID,
+		Commit: "5ebfab0522851df01fec11ec55a6d0f4877b542e",
+	}
+	err := gm.extractTree(&ArvTestClient{}, s.tmpdir)
+	c.Check(err, check.ErrorMatches, ".*gitUrl.*")
+}
+
 func (s *GitMountSuite) TestInvalid(c *check.C) {
 	for _, trial := range []struct {
 		gm      gitMount
@@ -150,7 +156,7 @@ func (s *GitMountSuite) TestInvalid(c *check.C) {
 		c.Check(err, check.NotNil)
 		s.checkTmpdirContents(c, []string{})
 
-		err := trial.gm.validate()
+		err = trial.gm.validate()
 		c.Check(err, check.ErrorMatches, trial.matcher)
 	}
 }
@@ -162,3 +168,11 @@ func (s *GitMountSuite) checkTmpdirContents(c *check.C, expect []string) {
 	c.Check(err, check.IsNil)
 	c.Check(names, check.DeepEquals, expect)
 }
+
+func (*GitMountSuite) useTestGitServer(c *check.C) {
+	git_client.InstallProtocol("https", git_http.NewClient(arvados.InsecureHTTPClient))
+
+	port, err := ioutil.ReadFile("../../tmp/arv-git-httpd-ssl.port")
+	c.Assert(err, check.IsNil)
+	discoveryMap["gitUrl"] = "https://localhost:" + string(port)
+}

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list