X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/1237511f9da5ee20588d44be4db5f9e37cfc6400..9325dabcc2b6c32a589ba86cc052946b4875eb1d:/sdk/go/keepclient/keepclient_test.go diff --git a/sdk/go/keepclient/keepclient_test.go b/sdk/go/keepclient/keepclient_test.go index f02f982604..c1088ef8c8 100644 --- a/sdk/go/keepclient/keepclient_test.go +++ b/sdk/go/keepclient/keepclient_test.go @@ -92,25 +92,6 @@ func (s *ServerRequiredSuite) TestMakeKeepClient(c *C) { } } -func (s *StandaloneSuite) TestShuffleServiceRoots(c *C) { - roots := map[string]string{ - "zzzzz-bi6l4-2q7dq8becevdqfb": "http://localhost:1", - "zzzzz-bi6l4-4gbhck2w7lq0d96": "http://localhost:2", - "zzzzz-bi6l4-4bt69dsk0quh7ae": "http://localhost:3", - "zzzzz-bi6l4-62w1fgd0ud2krxl": "http://localhost:4", - } - kc := KeepClient{} - kc.SetServiceRoots(roots) - - // "foo" acbd18db4cc2f85cedef654fccc4a4d8 - foo_shuffle := []string{"http://localhost:4", "http://localhost:1", "http://localhost:3", "http://localhost:2"} - c.Check(kc.shuffledServiceRoots("acbd18db4cc2f85cedef654fccc4a4d8"), DeepEquals, foo_shuffle) - - // "bar" 37b51d194a7513e45b56f6524f2d51f2 - bar_shuffle := []string{"http://localhost:3", "http://localhost:2", "http://localhost:4", "http://localhost:1"} - c.Check(kc.shuffledServiceRoots("37b51d194a7513e45b56f6524f2d51f2"), DeepEquals, bar_shuffle) -} - type StubPutHandler struct { c *C expectPath string @@ -273,7 +254,7 @@ func RunSomeFakeKeepServers(st http.Handler, n int, port int) (ks []KeepServer) func (s *StandaloneSuite) TestPutB(c *C) { log.Printf("TestPutB") - hash := fmt.Sprintf("%x", md5.Sum([]byte("foo"))) + hash := Md5String("foo") st := StubPutHandler{ c, @@ -300,7 +281,8 @@ func (s *StandaloneSuite) TestPutB(c *C) { kc.PutB([]byte("foo")) - shuff := kc.shuffledServiceRoots(fmt.Sprintf("%x", md5.Sum([]byte("foo")))) + shuff := NewRootSorter( + kc.ServiceRoots(), Md5String("foo")).GetSortedRoots() s1 := <-st.handled s2 := <-st.handled @@ -349,7 +331,7 @@ func (s *StandaloneSuite) TestPutHR(c *C) { kc.PutHR(hash, reader, 3) - shuff := kc.shuffledServiceRoots(hash) + shuff := NewRootSorter(kc.ServiceRoots(), hash).GetSortedRoots() log.Print(shuff) s1 := <-st.handled @@ -399,7 +381,8 @@ func (s *StandaloneSuite) TestPutWithFail(c *C) { kc.SetServiceRoots(service_roots) - shuff := kc.shuffledServiceRoots(fmt.Sprintf("%x", md5.Sum([]byte("foo")))) + shuff := NewRootSorter( + kc.ServiceRoots(), Md5String("foo")).GetSortedRoots() phash, replicas, err := kc.PutB([]byte("foo"))