14360: Use nonblocking mode when checking for stale lock.
[arvados.git] / services / crunch-run / git_mount_test.go
index 82dce3ac26b57d44b2d902c13a859e12f3c2db41..4dc95bc3dfae529069595cc996ef23ab1b83cb09 100644 (file)
@@ -42,7 +42,7 @@ func (s *GitMountSuite) TestextractTree(c *check.C) {
                UUID:   arvadostest.Repository2UUID,
                Commit: "fd3531f42995344f36c30b79f55f27b502f3d344",
        }
-       err := gm.extractTree(&ArvTestClient{}, s.tmpdir)
+       err := gm.extractTree(&ArvTestClient{}, s.tmpdir, arvadostest.ActiveToken)
        c.Check(err, check.IsNil)
 
        fnm := filepath.Join(s.tmpdir, "dir1/dir2/file with mode 0644")
@@ -67,6 +67,12 @@ func (s *GitMountSuite) TestextractTree(c *check.C) {
 
        // Ensure there's no extra stuff like a ".git" dir
        s.checkTmpdirContents(c, []string{"dir1"})
+
+       // Ensure tmpdir is world-readable and world-executable so the
+       // UID inside the container can use it.
+       fi, err = os.Stat(s.tmpdir)
+       c.Check(err, check.IsNil)
+       c.Check(fi.Mode()&os.ModePerm, check.Equals, os.FileMode(0755))
 }
 
 // Commit 5ebfab0 is not the tip of any branch or tag, but is
@@ -76,7 +82,7 @@ func (s *GitMountSuite) TestExtractNonTipCommit(c *check.C) {
                UUID:   arvadostest.Repository2UUID,
                Commit: "5ebfab0522851df01fec11ec55a6d0f4877b542e",
        }
-       err := gm.extractTree(&ArvTestClient{}, s.tmpdir)
+       err := gm.extractTree(&ArvTestClient{}, s.tmpdir, arvadostest.ActiveToken)
        c.Check(err, check.IsNil)
 
        fnm := filepath.Join(s.tmpdir, "file only on testbranch")
@@ -91,7 +97,7 @@ func (s *GitMountSuite) TestNonexistentRepository(c *check.C) {
                UUID:   "zzzzz-s0uqq-nonexistentrepo",
                Commit: "5ebfab0522851df01fec11ec55a6d0f4877b542e",
        }
-       err := gm.extractTree(&ArvTestClient{}, s.tmpdir)
+       err := gm.extractTree(&ArvTestClient{}, s.tmpdir, arvadostest.ActiveToken)
        c.Check(err, check.NotNil)
        c.Check(err, check.ErrorMatches, ".*repository not found.*")
 
@@ -104,7 +110,7 @@ func (s *GitMountSuite) TestNonexistentCommit(c *check.C) {
                UUID:   arvadostest.Repository2UUID,
                Commit: "bb66b6bb6b6bbb6b6b6b66b6b6b6b6b6b6b6b66b",
        }
-       err := gm.extractTree(&ArvTestClient{}, s.tmpdir)
+       err := gm.extractTree(&ArvTestClient{}, s.tmpdir, arvadostest.ActiveToken)
        c.Check(err, check.NotNil)
        c.Check(err, check.ErrorMatches, ".*object not found.*")
 
@@ -118,7 +124,7 @@ func (s *GitMountSuite) TestGitUrlDiscoveryFails(c *check.C) {
                UUID:   arvadostest.Repository2UUID,
                Commit: "5ebfab0522851df01fec11ec55a6d0f4877b542e",
        }
-       err := gm.extractTree(&ArvTestClient{}, s.tmpdir)
+       err := gm.extractTree(&ArvTestClient{}, s.tmpdir, arvadostest.ActiveToken)
        c.Check(err, check.ErrorMatches, ".*gitUrl.*")
 }
 
@@ -167,8 +173,17 @@ func (s *GitMountSuite) TestInvalid(c *check.C) {
                        },
                        matcher: ".*UUID.*",
                },
+               {
+                       gm: gitMount{
+                               Path:     "/",
+                               UUID:     arvadostest.Repository2UUID,
+                               Commit:   "5ebfab0522851df01fec11ec55a6d0f4877b542e",
+                               Writable: true,
+                       },
+                       matcher: ".*writable.*",
+               },
        } {
-               err := trial.gm.extractTree(&ArvTestClient{}, s.tmpdir)
+               err := trial.gm.extractTree(&ArvTestClient{}, s.tmpdir, arvadostest.ActiveToken)
                c.Check(err, check.NotNil)
                s.checkTmpdirContents(c, []string{})