X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b49229f98012d7c08ce02b8d28dbcc165c8a6c53..4f1152fbdd0506d3d07449bedb2479f2938bcf73:/services/keepstore/unix_volume_test.go?ds=inline diff --git a/services/keepstore/unix_volume_test.go b/services/keepstore/unix_volume_test.go index a60aa416a9..7777363b9d 100644 --- a/services/keepstore/unix_volume_test.go +++ b/services/keepstore/unix_volume_test.go @@ -13,7 +13,6 @@ import ( "io" "io/ioutil" "os" - "strings" "sync" "syscall" "time" @@ -168,11 +167,10 @@ func (s *UnixVolumeSuite) TestPutBadVolume(c *check.C) { v := s.newTestableUnixVolume(c, s.cluster, arvados.Volume{Replication: 1}, s.metrics, false) defer v.Teardown() - os.Chmod(v.Root, 000) - err := v.Put(context.Background(), TestHash, TestBlock) - if err == nil { - c.Error("Write should have failed") - } + err := os.RemoveAll(v.Root) + c.Assert(err, check.IsNil) + err = v.Put(context.Background(), TestHash, TestBlock) + c.Check(err, check.IsNil) } func (s *UnixVolumeSuite) TestUnixVolumeReadonly(c *check.C) { @@ -330,11 +328,14 @@ func (s *UnixVolumeSuite) TestUnixVolumeCompare(c *check.C) { c.Errorf("Got err %q, expected %q", err, DiskHashError) } - p := fmt.Sprintf("%s/%s/%s", v.Root, TestHash[:3], TestHash) - os.Chmod(p, 000) - err = v.Compare(context.Background(), TestHash, TestBlock) - if err == nil || strings.Index(err.Error(), "permission denied") < 0 { - c.Errorf("Got err %q, expected %q", err, "permission denied") + if os.Getuid() == 0 { + c.Log("skipping 'permission denied' check when running as root") + } else { + p := fmt.Sprintf("%s/%s/%s", v.Root, TestHash[:3], TestHash) + err = os.Chmod(p, 000) + c.Assert(err, check.IsNil) + err = v.Compare(context.Background(), TestHash, TestBlock) + c.Check(err, check.ErrorMatches, ".*permission denied.*") } }