[ARVADOS] updated: c7b7e4d44e9349c9104fbfcd33c5e4b97fe17a71

git at public.curoverse.com git at public.curoverse.com
Tue Nov 11 17:10:43 EST 2014


Summary of changes:
 sdk/go/keepclient/keepclient_test.go  | 18 ++++++++++++------
 sdk/go/keepclient/root_sorter_test.go |  5 -----
 sdk/go/keepclient/support.go          |  9 +++++----
 3 files changed, 17 insertions(+), 15 deletions(-)

       via  c7b7e4d44e9349c9104fbfcd33c5e4b97fe17a71 (commit)
      from  e61de9add861db4c043341f3926acb95ded37862 (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 c7b7e4d44e9349c9104fbfcd33c5e4b97fe17a71
Author: Tom Clegg <tom at curoverse.com>
Date:   Tue Nov 11 16:42:39 2014 -0500

    2853: Remove shuffledServiceRoots() wrapper.

diff --git a/sdk/go/keepclient/keepclient_test.go b/sdk/go/keepclient/keepclient_test.go
index f02f982..c958695 100644
--- a/sdk/go/keepclient/keepclient_test.go
+++ b/sdk/go/keepclient/keepclient_test.go
@@ -104,11 +104,15 @@ func (s *StandaloneSuite) TestShuffleServiceRoots(c *C) {
 
 	// "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)
+	c.Check(NewRootSorter(
+		kc.ServiceRoots(), Md5String("foo")).GetSortedRoots(),
+		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)
+	c.Check(NewRootSorter(
+		kc.ServiceRoots(), Md5String("bar")).GetSortedRoots(),
+		DeepEquals, bar_shuffle)
 }
 
 type StubPutHandler struct {
@@ -273,7 +277,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 +304,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 +354,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 +404,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"))
 
diff --git a/sdk/go/keepclient/root_sorter_test.go b/sdk/go/keepclient/root_sorter_test.go
index 7fe6a70..8b63449 100644
--- a/sdk/go/keepclient/root_sorter_test.go
+++ b/sdk/go/keepclient/root_sorter_test.go
@@ -1,7 +1,6 @@
 package keepclient
 
 import (
-	"crypto/md5"
 	"fmt"
 	. "gopkg.in/check.v1"
 	"strconv"
@@ -27,10 +26,6 @@ func FakeServiceRoots(n uint64) (map[string]string) {
 	return sr
 }
 
-func Md5String(data string) (string) {
-	return fmt.Sprintf("%032x", md5.Sum([]byte(data)))
-}
-
 func (*RootSorterSuite) EmptyRoots(c *C) {
 	rs := NewRootSorter(map[string]string{}, Md5String("foo"))
 	c.Check(rs.GetSortedRoots(), Equals, []string{})
diff --git a/sdk/go/keepclient/support.go b/sdk/go/keepclient/support.go
index e51dcb3..e122144 100644
--- a/sdk/go/keepclient/support.go
+++ b/sdk/go/keepclient/support.go
@@ -2,6 +2,7 @@
 package keepclient
 
 import (
+	"crypto/md5"
 	"git.curoverse.com/arvados.git/sdk/go/streamer"
 	"errors"
 	"fmt"
@@ -21,6 +22,10 @@ type keepDisk struct {
 	SvcType  string `json:"service_type"`
 }
 
+func Md5String(s string) (string) {
+	return fmt.Sprintf("%x", md5.Sum([]byte(s)))
+}
+
 func (this *KeepClient) DiscoverKeepServers() error {
 	if prx := os.Getenv("ARVADOS_KEEP_PROXY"); prx != "" {
 		sr := map[string]string{"proxy":prx}
@@ -70,10 +75,6 @@ func (this *KeepClient) DiscoverKeepServers() error {
 	return nil
 }
 
-func (this KeepClient) shuffledServiceRoots(hash string) (pseq []string) {
-	return NewRootSorter(this.ServiceRoots(), hash).GetSortedRoots()
-}
-
 type uploadStatus struct {
 	err             error
 	url             string

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list