20318: Fix tests that expect Get to work on bare hashes.
[arvados.git] / sdk / go / keepclient / keepclient_test.go
index a6e0a11d510b6f5c79a510a1db22633cc775a134..fe133fe2cbd08f69abdf74efcc93838943d2f2f5 100644 (file)
@@ -41,8 +41,16 @@ type ServerRequiredSuite struct{}
 // Standalone tests
 type StandaloneSuite struct{}
 
+var origHOME = os.Getenv("HOME")
+
 func (s *StandaloneSuite) SetUpTest(c *C) {
        RefreshServiceDiscovery()
+       // Prevent cache state from leaking between test cases
+       os.Setenv("HOME", c.MkDir())
+}
+
+func (s *StandaloneSuite) TearDownTest(c *C) {
+       os.Setenv("HOME", origHOME)
 }
 
 func pythonDir() string {
@@ -56,19 +64,22 @@ func (s *ServerRequiredSuite) SetUpSuite(c *C) {
 
 func (s *ServerRequiredSuite) TearDownSuite(c *C) {
        arvadostest.StopKeep(2)
+       os.Setenv("HOME", origHOME)
 }
 
 func (s *ServerRequiredSuite) SetUpTest(c *C) {
        RefreshServiceDiscovery()
+       // Prevent cache state from leaking between test cases
+       os.Setenv("HOME", c.MkDir())
 }
 
 func (s *ServerRequiredSuite) TestMakeKeepClient(c *C) {
        arv, err := arvadosclient.MakeArvadosClient()
-       c.Assert(err, Equals, nil)
+       c.Assert(err, IsNil)
 
        kc, err := MakeKeepClient(arv)
 
-       c.Assert(err, Equals, nil)
+       c.Assert(err, IsNil)
        c.Check(len(kc.LocalRoots()), Equals, 2)
        for _, root := range kc.LocalRoots() {
                c.Check(root, Matches, "http://localhost:\\d+")
@@ -129,7 +140,7 @@ func (sph *StubPutHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request
                sph.c.Check(req.Header.Get("X-Keep-Storage-Classes"), Equals, sph.expectStorageClass)
        }
        body, err := ioutil.ReadAll(req.Body)
-       sph.c.Check(err, Equals, nil)
+       sph.c.Check(err, IsNil)
        sph.c.Check(body, DeepEquals, []byte(sph.expectBody))
        resp.Header().Set("X-Keep-Replicas-Stored", "1")
        if sph.returnStorageClasses != "" {
@@ -519,7 +530,7 @@ func (s *StandaloneSuite) TestPutB(c *C) {
 }
 
 func (s *StandaloneSuite) TestPutHR(c *C) {
-       hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
+       hash := fmt.Sprintf("%x+3", md5.Sum([]byte("foo")))
 
        st := &StubPutHandler{
                c:                    c,
@@ -618,7 +629,7 @@ func (s *StandaloneSuite) TestPutWithFail(c *C) {
 
        <-fh.handled
 
-       c.Check(err, Equals, nil)
+       c.Check(err, IsNil)
        c.Check(phash, Equals, "")
        c.Check(replicas, Equals, 2)
 
@@ -697,7 +708,7 @@ func (sgh StubGetHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request)
 }
 
 func (s *StandaloneSuite) TestGet(c *C) {
-       hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
+       hash := fmt.Sprintf("%x+3", md5.Sum([]byte("foo")))
 
        st := StubGetHandler{
                c,
@@ -715,19 +726,18 @@ func (s *StandaloneSuite) TestGet(c *C) {
        arv.ApiToken = "abc123"
        kc.SetServiceRoots(map[string]string{"x": ks.url}, nil, nil)
 
-       r, n, url2, err := kc.Get(hash)
-       defer r.Close()
-       c.Check(err, Equals, nil)
+       r, n, _, err := kc.Get(hash)
+       c.Assert(err, IsNil)
        c.Check(n, Equals, int64(3))
-       c.Check(url2, Equals, fmt.Sprintf("%s/%s", ks.url, hash))
 
        content, err2 := ioutil.ReadAll(r)
-       c.Check(err2, Equals, nil)
+       c.Check(err2, IsNil)
        c.Check(content, DeepEquals, []byte("foo"))
+       c.Check(r.Close(), IsNil)
 }
 
 func (s *StandaloneSuite) TestGet404(c *C) {
-       hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
+       hash := fmt.Sprintf("%x+3", md5.Sum([]byte("foo")))
 
        st := Error404Handler{make(chan string, 1)}
 
@@ -740,11 +750,10 @@ func (s *StandaloneSuite) TestGet404(c *C) {
        arv.ApiToken = "abc123"
        kc.SetServiceRoots(map[string]string{"x": ks.url}, nil, nil)
 
-       r, n, url2, err := kc.Get(hash)
+       r, n, _, err := kc.Get(hash)
        c.Check(err, Equals, BlockNotFound)
        c.Check(n, Equals, int64(0))
-       c.Check(url2, Equals, "")
-       c.Check(r, Equals, nil)
+       c.Check(r, IsNil)
 }
 
 func (s *StandaloneSuite) TestGetEmptyBlock(c *C) {
@@ -759,18 +768,18 @@ func (s *StandaloneSuite) TestGetEmptyBlock(c *C) {
        arv.ApiToken = "abc123"
        kc.SetServiceRoots(map[string]string{"x": ks.url}, nil, nil)
 
-       r, n, url2, err := kc.Get("d41d8cd98f00b204e9800998ecf8427e+0")
+       r, n, _, err := kc.Get("d41d8cd98f00b204e9800998ecf8427e+0")
        c.Check(err, IsNil)
        c.Check(n, Equals, int64(0))
-       c.Check(url2, Equals, "")
        c.Assert(r, NotNil)
        buf, err := ioutil.ReadAll(r)
        c.Check(err, IsNil)
        c.Check(buf, DeepEquals, []byte{})
+       c.Check(r.Close(), IsNil)
 }
 
 func (s *StandaloneSuite) TestGetFail(c *C) {
-       hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
+       hash := fmt.Sprintf("%x+3", md5.Sum([]byte("foo")))
 
        st := FailHandler{make(chan string, 1)}
 
@@ -784,18 +793,18 @@ func (s *StandaloneSuite) TestGetFail(c *C) {
        kc.SetServiceRoots(map[string]string{"x": ks.url}, nil, nil)
        kc.Retries = 0
 
-       r, n, url2, err := kc.Get(hash)
+       r, n, _, err := kc.Get(hash)
        errNotFound, _ := err.(*ErrNotFound)
-       c.Check(errNotFound, NotNil)
-       c.Check(strings.Contains(errNotFound.Error(), "HTTP 500"), Equals, true)
-       c.Check(errNotFound.Temporary(), Equals, true)
+       if c.Check(errNotFound, NotNil) {
+               c.Check(strings.Contains(errNotFound.Error(), "HTTP 500"), Equals, true)
+               c.Check(errNotFound.Temporary(), Equals, true)
+       }
        c.Check(n, Equals, int64(0))
-       c.Check(url2, Equals, "")
-       c.Check(r, Equals, nil)
+       c.Check(r, IsNil)
 }
 
 func (s *StandaloneSuite) TestGetFailRetry(c *C) {
-       hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
+       hash := fmt.Sprintf("%x+3", md5.Sum([]byte("foo")))
 
        st := &FailThenSucceedHandler{
                handled: make(chan string, 1),
@@ -815,15 +824,14 @@ func (s *StandaloneSuite) TestGetFailRetry(c *C) {
        arv.ApiToken = "abc123"
        kc.SetServiceRoots(map[string]string{"x": ks.url}, nil, nil)
 
-       r, n, url2, err := kc.Get(hash)
-       defer r.Close()
-       c.Check(err, Equals, nil)
+       r, n, _, err := kc.Get(hash)
+       c.Assert(err, IsNil)
        c.Check(n, Equals, int64(3))
-       c.Check(url2, Equals, fmt.Sprintf("%s/%s", ks.url, hash))
 
-       content, err2 := ioutil.ReadAll(r)
-       c.Check(err2, Equals, nil)
+       content, err := ioutil.ReadAll(r)
+       c.Check(err, IsNil)
        c.Check(content, DeepEquals, []byte("foo"))
+       c.Check(r.Close(), IsNil)
 
        c.Logf("%q", st.reqIDs)
        c.Assert(len(st.reqIDs) > 1, Equals, true)
@@ -834,7 +842,7 @@ func (s *StandaloneSuite) TestGetFailRetry(c *C) {
 }
 
 func (s *StandaloneSuite) TestGetNetError(c *C) {
-       hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
+       hash := fmt.Sprintf("%x+3", md5.Sum([]byte("foo")))
 
        arv, err := arvadosclient.MakeArvadosClient()
        c.Check(err, IsNil)
@@ -842,19 +850,19 @@ func (s *StandaloneSuite) TestGetNetError(c *C) {
        arv.ApiToken = "abc123"
        kc.SetServiceRoots(map[string]string{"x": "http://localhost:62222"}, nil, nil)
 
-       r, n, url2, err := kc.Get(hash)
+       r, n, _, err := kc.Get(hash)
        errNotFound, _ := err.(*ErrNotFound)
-       c.Check(errNotFound, NotNil)
-       c.Check(strings.Contains(errNotFound.Error(), "connection refused"), Equals, true)
-       c.Check(errNotFound.Temporary(), Equals, true)
+       if c.Check(errNotFound, NotNil) {
+               c.Check(strings.Contains(errNotFound.Error(), "connection refused"), Equals, true)
+               c.Check(errNotFound.Temporary(), Equals, true)
+       }
        c.Check(n, Equals, int64(0))
-       c.Check(url2, Equals, "")
-       c.Check(r, Equals, nil)
+       c.Check(r, IsNil)
 }
 
 func (s *StandaloneSuite) TestGetWithServiceHint(c *C) {
        uuid := "zzzzz-bi6l4-123451234512345"
-       hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
+       hash := fmt.Sprintf("%x+3", md5.Sum([]byte("foo")))
 
        // This one shouldn't be used:
        ks0 := RunFakeKeepServer(StubGetHandler{
@@ -882,22 +890,21 @@ func (s *StandaloneSuite) TestGetWithServiceHint(c *C) {
                nil,
                map[string]string{uuid: ks.url})
 
-       r, n, uri, err := kc.Get(hash + "+K@" + uuid)
-       defer r.Close()
-       c.Check(err, Equals, nil)
+       r, n, _, err := kc.Get(hash + "+K@" + uuid)
+       c.Assert(err, IsNil)
        c.Check(n, Equals, int64(3))
-       c.Check(uri, Equals, fmt.Sprintf("%s/%s", ks.url, hash+"+K@"+uuid))
 
        content, err := ioutil.ReadAll(r)
-       c.Check(err, Equals, nil)
+       c.Check(err, IsNil)
        c.Check(content, DeepEquals, []byte("foo"))
+       c.Check(r.Close(), IsNil)
 }
 
 // Use a service hint to fetch from a local disk service, overriding
 // rendezvous probe order.
 func (s *StandaloneSuite) TestGetWithLocalServiceHint(c *C) {
        uuid := "zzzzz-bi6l4-zzzzzzzzzzzzzzz"
-       hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
+       hash := fmt.Sprintf("%x+3", md5.Sum([]byte("foo")))
 
        // This one shouldn't be used, although it appears first in
        // rendezvous probe order:
@@ -905,8 +912,8 @@ func (s *StandaloneSuite) TestGetWithLocalServiceHint(c *C) {
                c,
                "error if used",
                "abc123",
-               http.StatusOK,
-               []byte("foo")})
+               http.StatusBadGateway,
+               nil})
        defer ks0.listener.Close()
        // This one should be used:
        ks := RunFakeKeepServer(StubGetHandler{
@@ -935,20 +942,19 @@ func (s *StandaloneSuite) TestGetWithLocalServiceHint(c *C) {
                        uuid:                          ks.url},
        )
 
-       r, n, uri, err := kc.Get(hash + "+K@" + uuid)
-       defer r.Close()
-       c.Check(err, Equals, nil)
+       r, n, _, err := kc.Get(hash + "+K@" + uuid)
+       c.Assert(err, IsNil)
        c.Check(n, Equals, int64(3))
-       c.Check(uri, Equals, fmt.Sprintf("%s/%s", ks.url, hash+"+K@"+uuid))
 
        content, err := ioutil.ReadAll(r)
-       c.Check(err, Equals, nil)
+       c.Check(err, IsNil)
        c.Check(content, DeepEquals, []byte("foo"))
+       c.Check(r.Close(), IsNil)
 }
 
 func (s *StandaloneSuite) TestGetWithServiceHintFailoverToLocals(c *C) {
        uuid := "zzzzz-bi6l4-123451234512345"
-       hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
+       hash := fmt.Sprintf("%x+3", md5.Sum([]byte("foo")))
 
        ksLocal := RunFakeKeepServer(StubGetHandler{
                c,
@@ -974,15 +980,14 @@ func (s *StandaloneSuite) TestGetWithServiceHintFailoverToLocals(c *C) {
                nil,
                map[string]string{uuid: ksGateway.url})
 
-       r, n, uri, err := kc.Get(hash + "+K@" + uuid)
-       c.Assert(err, Equals, nil)
-       defer r.Close()
+       r, n, _, err := kc.Get(hash + "+K@" + uuid)
+       c.Assert(err, IsNil)
        c.Check(n, Equals, int64(3))
-       c.Check(uri, Equals, fmt.Sprintf("%s/%s", ksLocal.url, hash+"+K@"+uuid))
 
        content, err := ioutil.ReadAll(r)
-       c.Check(err, Equals, nil)
+       c.Check(err, IsNil)
        c.Check(content, DeepEquals, []byte("foo"))
+       c.Check(r.Close(), IsNil)
 }
 
 type BarHandler struct {
@@ -995,8 +1000,8 @@ func (h BarHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
 }
 
 func (s *StandaloneSuite) TestChecksum(c *C) {
-       foohash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
-       barhash := fmt.Sprintf("%x", md5.Sum([]byte("bar")))
+       foohash := fmt.Sprintf("%x+3", md5.Sum([]byte("foo")))
+       barhash := fmt.Sprintf("%x+3", md5.Sum([]byte("bar")))
 
        st := BarHandler{make(chan string, 1)}
 
@@ -1010,25 +1015,36 @@ func (s *StandaloneSuite) TestChecksum(c *C) {
        kc.SetServiceRoots(map[string]string{"x": ks.url}, nil, nil)
 
        r, n, _, err := kc.Get(barhash)
-       c.Check(err, IsNil)
-       _, err = ioutil.ReadAll(r)
-       c.Check(n, Equals, int64(3))
-       c.Check(err, Equals, nil)
+       if c.Check(err, IsNil) {
+               _, err = ioutil.ReadAll(r)
+               c.Check(n, Equals, int64(3))
+               c.Check(err, IsNil)
+       }
 
-       <-st.handled
+       select {
+       case <-st.handled:
+       case <-time.After(time.Second):
+               c.Fatal("timed out")
+       }
 
        r, n, _, err = kc.Get(foohash)
-       c.Check(err, IsNil)
-       _, err = ioutil.ReadAll(r)
-       c.Check(n, Equals, int64(3))
+       if err == nil {
+               buf, readerr := ioutil.ReadAll(r)
+               c.Logf("%q", buf)
+               err = readerr
+       }
        c.Check(err, Equals, BadChecksum)
 
-       <-st.handled
+       select {
+       case <-st.handled:
+       case <-time.After(time.Second):
+               c.Fatal("timed out")
+       }
 }
 
 func (s *StandaloneSuite) TestGetWithFailures(c *C) {
        content := []byte("waz")
-       hash := fmt.Sprintf("%x", md5.Sum(content))
+       hash := fmt.Sprintf("%x+3", md5.Sum(content))
 
        fh := Error404Handler{
                make(chan string, 4)}
@@ -1072,16 +1088,20 @@ func (s *StandaloneSuite) TestGetWithFailures(c *C) {
        // an example that passes this Assert.)
        c.Assert(NewRootSorter(localRoots, hash).GetSortedRoots()[0], Not(Equals), ks1[0].url)
 
-       r, n, url2, err := kc.Get(hash)
+       r, n, _, err := kc.Get(hash)
 
-       <-fh.handled
-       c.Check(err, Equals, nil)
+       select {
+       case <-fh.handled:
+       case <-time.After(time.Second):
+               c.Fatal("timed out")
+       }
+       c.Assert(err, IsNil)
        c.Check(n, Equals, int64(3))
-       c.Check(url2, Equals, fmt.Sprintf("%s/%s", ks1[0].url, hash))
 
        readContent, err2 := ioutil.ReadAll(r)
-       c.Check(err2, Equals, nil)
+       c.Check(err2, IsNil)
        c.Check(readContent, DeepEquals, content)
+       c.Check(r.Close(), IsNil)
 }
 
 func (s *ServerRequiredSuite) TestPutGetHead(c *C) {
@@ -1090,9 +1110,9 @@ func (s *ServerRequiredSuite) TestPutGetHead(c *C) {
        arv, err := arvadosclient.MakeArvadosClient()
        c.Check(err, IsNil)
        kc, err := MakeKeepClient(arv)
-       c.Assert(err, Equals, nil)
+       c.Assert(err, IsNil)
 
-       hash := fmt.Sprintf("%x", md5.Sum(content))
+       hash := fmt.Sprintf("%x+%d", md5.Sum(content), len(content))
 
        {
                n, _, err := kc.Ask(hash)
@@ -1101,29 +1121,32 @@ func (s *ServerRequiredSuite) TestPutGetHead(c *C) {
        }
        {
                hash2, replicas, err := kc.PutB(content)
-               c.Check(hash2, Matches, fmt.Sprintf(`%s\+%d\b.*`, hash, len(content)))
+               c.Check(err, IsNil)
+               c.Check(hash2, Matches, `\Q`+hash+`\E\b.*`)
                c.Check(replicas, Equals, 2)
-               c.Check(err, Equals, nil)
        }
        {
-               r, n, url2, err := kc.Get(hash)
-               c.Check(err, Equals, nil)
+               r, n, _, err := kc.Get(hash)
+               c.Check(err, IsNil)
                c.Check(n, Equals, int64(len(content)))
-               c.Check(url2, Matches, fmt.Sprintf("http://localhost:\\d+/%s", hash))
-
-               readContent, err2 := ioutil.ReadAll(r)
-               c.Check(err2, Equals, nil)
-               c.Check(readContent, DeepEquals, content)
+               if c.Check(r, NotNil) {
+                       readContent, err := ioutil.ReadAll(r)
+                       c.Check(err, IsNil)
+                       if c.Check(len(readContent), Equals, len(content)) {
+                               c.Check(readContent, DeepEquals, content)
+                       }
+                       c.Check(r.Close(), IsNil)
+               }
        }
        {
                n, url2, err := kc.Ask(hash)
-               c.Check(err, Equals, nil)
+               c.Check(err, IsNil)
                c.Check(n, Equals, int64(len(content)))
-               c.Check(url2, Matches, fmt.Sprintf("http://localhost:\\d+/%s", hash))
+               c.Check(url2, Matches, "http://localhost:\\d+/\\Q"+hash+"\\E")
        }
        {
                loc, err := kc.LocalLocator(hash)
-               c.Check(err, Equals, nil)
+               c.Check(err, IsNil)
                c.Assert(len(loc) >= 32, Equals, true)
                c.Check(loc[:32], Equals, hash[:32])
        }
@@ -1170,7 +1193,7 @@ func (s *StandaloneSuite) TestPutProxy(c *C) {
        _, replicas, err := kc.PutB([]byte("foo"))
        <-st.handled
 
-       c.Check(err, Equals, nil)
+       c.Check(err, IsNil)
        c.Check(replicas, Equals, 2)
 }
 
@@ -1204,7 +1227,7 @@ func (s *StandaloneSuite) TestPutProxyInsufficientReplicas(c *C) {
 
 func (s *StandaloneSuite) TestMakeLocator(c *C) {
        l, err := MakeLocator("91f372a266fe2bf2823cb8ec7fda31ce+3+Aabcde@12345678")
-       c.Check(err, Equals, nil)
+       c.Check(err, IsNil)
        c.Check(l.Hash, Equals, "91f372a266fe2bf2823cb8ec7fda31ce")
        c.Check(l.Size, Equals, 3)
        c.Check(l.Hints, DeepEquals, []string{"3", "Aabcde@12345678"})
@@ -1212,7 +1235,7 @@ func (s *StandaloneSuite) TestMakeLocator(c *C) {
 
 func (s *StandaloneSuite) TestMakeLocatorNoHints(c *C) {
        l, err := MakeLocator("91f372a266fe2bf2823cb8ec7fda31ce")
-       c.Check(err, Equals, nil)
+       c.Check(err, IsNil)
        c.Check(l.Hash, Equals, "91f372a266fe2bf2823cb8ec7fda31ce")
        c.Check(l.Size, Equals, -1)
        c.Check(l.Hints, DeepEquals, []string{})
@@ -1220,7 +1243,7 @@ func (s *StandaloneSuite) TestMakeLocatorNoHints(c *C) {
 
 func (s *StandaloneSuite) TestMakeLocatorNoSizeHint(c *C) {
        l, err := MakeLocator("91f372a266fe2bf2823cb8ec7fda31ce+Aabcde@12345678")
-       c.Check(err, Equals, nil)
+       c.Check(err, IsNil)
        c.Check(l.Hash, Equals, "91f372a266fe2bf2823cb8ec7fda31ce")
        c.Check(l.Size, Equals, -1)
        c.Check(l.Hints, DeepEquals, []string{"Aabcde@12345678"})
@@ -1229,7 +1252,7 @@ func (s *StandaloneSuite) TestMakeLocatorNoSizeHint(c *C) {
 func (s *StandaloneSuite) TestMakeLocatorPreservesUnrecognizedHints(c *C) {
        str := "91f372a266fe2bf2823cb8ec7fda31ce+3+Unknown+Kzzzzz+Afoobar"
        l, err := MakeLocator(str)
-       c.Check(err, Equals, nil)
+       c.Check(err, IsNil)
        c.Check(l.Hash, Equals, "91f372a266fe2bf2823cb8ec7fda31ce")
        c.Check(l.Size, Equals, 3)
        c.Check(l.Hints, DeepEquals, []string{"3", "Unknown", "Kzzzzz", "Afoobar"})
@@ -1335,14 +1358,14 @@ func (h StubGetIndexHandler) ServeHTTP(resp http.ResponseWriter, req *http.Reque
 }
 
 func (s *StandaloneSuite) TestGetIndexWithNoPrefix(c *C) {
-       hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
+       hash := fmt.Sprintf("%x+3", md5.Sum([]byte("foo")))
 
        st := StubGetIndexHandler{
                c,
                "/index",
                "abc123",
                http.StatusOK,
-               []byte(hash + "+3 1443559274\n\n")}
+               []byte(hash + " 1443559274\n\n")}
 
        ks := RunFakeKeepServer(st)
        defer ks.listener.Close()
@@ -1358,19 +1381,19 @@ func (s *StandaloneSuite) TestGetIndexWithNoPrefix(c *C) {
        c.Check(err, IsNil)
 
        content, err2 := ioutil.ReadAll(r)
-       c.Check(err2, Equals, nil)
+       c.Check(err2, IsNil)
        c.Check(content, DeepEquals, st.body[0:len(st.body)-1])
 }
 
 func (s *StandaloneSuite) TestGetIndexWithPrefix(c *C) {
-       hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
+       hash := fmt.Sprintf("%x+3", md5.Sum([]byte("foo")))
 
        st := StubGetIndexHandler{
                c,
                "/index/" + hash[0:3],
                "abc123",
                http.StatusOK,
-               []byte(hash + "+3 1443559274\n\n")}
+               []byte(hash + " 1443559274\n\n")}
 
        ks := RunFakeKeepServer(st)
        defer ks.listener.Close()
@@ -1382,15 +1405,15 @@ func (s *StandaloneSuite) TestGetIndexWithPrefix(c *C) {
        kc.SetServiceRoots(map[string]string{"x": ks.url}, nil, nil)
 
        r, err := kc.GetIndex("x", hash[0:3])
-       c.Assert(err, Equals, nil)
+       c.Assert(err, IsNil)
 
        content, err2 := ioutil.ReadAll(r)
-       c.Check(err2, Equals, nil)
+       c.Check(err2, IsNil)
        c.Check(content, DeepEquals, st.body[0:len(st.body)-1])
 }
 
 func (s *StandaloneSuite) TestGetIndexIncomplete(c *C) {
-       hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
+       hash := fmt.Sprintf("%x+3", md5.Sum([]byte("foo")))
 
        st := StubGetIndexHandler{
                c,
@@ -1413,7 +1436,7 @@ func (s *StandaloneSuite) TestGetIndexIncomplete(c *C) {
 }
 
 func (s *StandaloneSuite) TestGetIndexWithNoSuchServer(c *C) {
-       hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
+       hash := fmt.Sprintf("%x+3", md5.Sum([]byte("foo")))
 
        st := StubGetIndexHandler{
                c,
@@ -1453,10 +1476,10 @@ func (s *StandaloneSuite) TestGetIndexWithNoSuchPrefix(c *C) {
        kc.SetServiceRoots(map[string]string{"x": ks.url}, nil, nil)
 
        r, err := kc.GetIndex("x", "abcd")
-       c.Check(err, Equals, nil)
+       c.Check(err, IsNil)
 
        content, err2 := ioutil.ReadAll(r)
-       c.Check(err2, Equals, nil)
+       c.Check(err2, IsNil)
        c.Check(content, DeepEquals, st.body[0:len(st.body)-1])
 }
 
@@ -1494,14 +1517,14 @@ func (s *StandaloneSuite) TestPutBRetry(c *C) {
 
        hash, replicas, err := kc.PutB([]byte("foo"))
 
-       c.Check(err, Equals, nil)
+       c.Check(err, IsNil)
        c.Check(hash, Equals, "")
        c.Check(replicas, Equals, 2)
 }
 
 func (s *ServerRequiredSuite) TestMakeKeepClientWithNonDiskTypeService(c *C) {
        arv, err := arvadosclient.MakeArvadosClient()
-       c.Assert(err, Equals, nil)
+       c.Assert(err, IsNil)
 
        // Add an additional "testblobstore" keepservice
        blobKeepService := make(arvadosclient.Dict)
@@ -1511,13 +1534,13 @@ func (s *ServerRequiredSuite) TestMakeKeepClientWithNonDiskTypeService(c *C) {
                        "service_port": "21321",
                        "service_type": "testblobstore"}},
                &blobKeepService)
-       c.Assert(err, Equals, nil)
+       c.Assert(err, IsNil)
        defer func() { arv.Delete("keep_services", blobKeepService["uuid"].(string), nil, nil) }()
        RefreshServiceDiscovery()
 
        // Make a keepclient and ensure that the testblobstore is included
        kc, err := MakeKeepClient(arv)
-       c.Assert(err, Equals, nil)
+       c.Assert(err, IsNil)
 
        // verify kc.LocalRoots
        c.Check(len(kc.LocalRoots()), Equals, 3)