[ARVADOS] updated: cc133acd3b94cfdf6b0770f12c0a4ed6b458ef18

git at public.curoverse.com git at public.curoverse.com
Mon Apr 13 13:27:01 EDT 2015


Summary of changes:
 sdk/go/keepclient/keepclient.go       | 14 +++++++-------
 sdk/go/keepclient/keepclient_test.go  | 24 +++++++++++++++++-------
 sdk/go/keepclient/root_sorter.go      | 12 ++++++------
 sdk/go/keepclient/root_sorter_test.go |  9 +++++----
 4 files changed, 35 insertions(+), 24 deletions(-)

       via  cc133acd3b94cfdf6b0770f12c0a4ed6b458ef18 (commit)
       via  320c333f2b49acd698b49b73ed01d32da4d15c8c (commit)
      from  37b57a092568ba92a41ee94a74bb0c73e569a18c (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 cc133acd3b94cfdf6b0770f12c0a4ed6b458ef18
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Apr 13 13:28:05 2015 -0400

    5414: Add test case for unrecognized/future hints.

diff --git a/sdk/go/keepclient/keepclient_test.go b/sdk/go/keepclient/keepclient_test.go
index 5c8d2a0..236d8db 100644
--- a/sdk/go/keepclient/keepclient_test.go
+++ b/sdk/go/keepclient/keepclient_test.go
@@ -839,6 +839,16 @@ func (s *StandaloneSuite) TestMakeLocatorNoSizeHint(c *C) {
 	c.Check(l.Hints, DeepEquals, []string{"Aabcde at 12345678"})
 }
 
+func (s *StandaloneSuite) TestMakeLocatorPreservesUnrecognizedHints(c *C) {
+	str := "91f372a266fe2bf2823cb8ec7fda31ce+3+Unknown+Kzzzzz+Afoobar"
+	l, err := MakeLocator(str)
+	c.Check(err, Equals, nil)
+	c.Check(l.Hash, Equals, "91f372a266fe2bf2823cb8ec7fda31ce")
+	c.Check(l.Size, Equals, 3)
+	c.Check(l.Hints, DeepEquals, []string{"3", "Unknown", "Kzzzzz", "Afoobar"})
+	c.Check(l.String(), Equals, str)
+}
+
 func (s *StandaloneSuite) TestMakeLocatorInvalidInput(c *C) {
 	_, err := MakeLocator("91f372a266fe2bf2823cb8ec7fda31c")
 	c.Check(err, Equals, InvalidLocatorError)

commit 320c333f2b49acd698b49b73ed01d32da4d15c8c
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Apr 13 13:22:34 2015 -0400

    5414: Fix up formatting.

diff --git a/sdk/go/keepclient/keepclient.go b/sdk/go/keepclient/keepclient.go
index 853f4c6..31cfb57 100644
--- a/sdk/go/keepclient/keepclient.go
+++ b/sdk/go/keepclient/keepclient.go
@@ -24,7 +24,7 @@ const BLOCKSIZE = 64 * 1024 * 1024
 
 var BlockNotFound = errors.New("Block not found")
 var InsufficientReplicasError = errors.New("Could not write sufficient replicas")
-var OversizeBlockError = errors.New("Exceeded maximum block size ("+strconv.Itoa(BLOCKSIZE)+")")
+var OversizeBlockError = errors.New("Exceeded maximum block size (" + strconv.Itoa(BLOCKSIZE) + ")")
 var MissingArvadosApiHost = errors.New("Missing required environment variable ARVADOS_API_HOST")
 var MissingArvadosApiToken = errors.New("Missing required environment variable ARVADOS_API_TOKEN")
 var InvalidLocatorError = errors.New("Invalid locator")
@@ -126,7 +126,7 @@ func (kc *KeepClient) PutR(r io.Reader) (locator string, replicas int, err error
 func (kc *KeepClient) Get(locator string) (io.ReadCloser, int64, string, error) {
 	var errs []string
 	for _, host := range kc.getSortedRoots(locator) {
-		url := host+"/"+locator
+		url := host + "/" + locator
 		req, err := http.NewRequest("GET", url, nil)
 		if err != nil {
 			continue
@@ -148,8 +148,8 @@ func (kc *KeepClient) Get(locator string) (io.ReadCloser, int64, string, error)
 		}
 		return HashCheckingReader{
 			Reader: resp.Body,
-			Hash: md5.New(),
-			Check: locator[0:32],
+			Hash:   md5.New(),
+			Check:  locator[0:32],
 		}, resp.ContentLength, url, nil
 	}
 	log.Printf("DEBUG: GET %s failed: %v", locator, errs)
@@ -165,7 +165,7 @@ func (kc *KeepClient) Get(locator string) (io.ReadCloser, int64, string, error)
 // and the URI reporting the data size.
 func (kc *KeepClient) Ask(locator string) (int64, string, error) {
 	for _, host := range kc.getSortedRoots(locator) {
-		url := host+"/"+locator
+		url := host + "/" + locator
 		req, err := http.NewRequest("HEAD", url, nil)
 		if err != nil {
 			continue
@@ -246,8 +246,8 @@ func (kc *KeepClient) getSortedRoots(locator string) []string {
 
 type Locator struct {
 	Hash  string
-	Size  int		// -1 if data size is not known
-	Hints []string		// Including the size hint, if any
+	Size  int      // -1 if data size is not known
+	Hints []string // Including the size hint, if any
 }
 
 func (loc *Locator) String() string {
diff --git a/sdk/go/keepclient/keepclient_test.go b/sdk/go/keepclient/keepclient_test.go
index 7054bba..5c8d2a0 100644
--- a/sdk/go/keepclient/keepclient_test.go
+++ b/sdk/go/keepclient/keepclient_test.go
@@ -504,7 +504,7 @@ func (s *StandaloneSuite) TestGetWithServiceHint(c *C) {
 	// This one should be used:
 	ks := RunFakeKeepServer(StubGetHandler{
 		c,
-		hash+"+K@"+uuid,
+		hash + "+K@" + uuid,
 		"abc123",
 		http.StatusOK,
 		[]byte("foo")})
@@ -517,7 +517,7 @@ func (s *StandaloneSuite) TestGetWithServiceHint(c *C) {
 		map[string]string{"x": ks0.url},
 		map[string]string{uuid: ks.url})
 
-	r, n, uri, err := kc.Get(hash+"+K@"+uuid)
+	r, n, uri, err := kc.Get(hash + "+K@" + uuid)
 	defer r.Close()
 	c.Check(err, Equals, nil)
 	c.Check(n, Equals, int64(3))
@@ -546,7 +546,7 @@ func (s *StandaloneSuite) TestGetWithLocalServiceHint(c *C) {
 	// This one should be used:
 	ks := RunFakeKeepServer(StubGetHandler{
 		c,
-		hash+"+K@"+uuid,
+		hash + "+K@" + uuid,
 		"abc123",
 		http.StatusOK,
 		[]byte("foo")})
@@ -568,7 +568,7 @@ func (s *StandaloneSuite) TestGetWithLocalServiceHint(c *C) {
 			uuid: ks.url},
 	)
 
-	r, n, uri, err := kc.Get(hash+"+K@"+uuid)
+	r, n, uri, err := kc.Get(hash + "+K@" + uuid)
 	defer r.Close()
 	c.Check(err, Equals, nil)
 	c.Check(n, Equals, int64(3))
@@ -585,14 +585,14 @@ func (s *StandaloneSuite) TestGetWithServiceHintFailoverToLocals(c *C) {
 
 	ksLocal := RunFakeKeepServer(StubGetHandler{
 		c,
-		hash+"+K@"+uuid,
+		hash + "+K@" + uuid,
 		"abc123",
 		http.StatusOK,
 		[]byte("foo")})
 	defer ksLocal.listener.Close()
 	ksGateway := RunFakeKeepServer(StubGetHandler{
 		c,
-		hash+"+K@"+uuid,
+		hash + "+K@" + uuid,
 		"abc123",
 		http.StatusInternalServerError,
 		[]byte("Error")})
@@ -605,7 +605,7 @@ func (s *StandaloneSuite) TestGetWithServiceHintFailoverToLocals(c *C) {
 		map[string]string{"zzzzz-bi6l4-keepdisk0000000": ksLocal.url},
 		map[string]string{uuid: ksGateway.url})
 
-	r, n, uri, err := kc.Get(hash+"+K@"+uuid)
+	r, n, uri, err := kc.Get(hash + "+K@" + uuid)
 	c.Assert(err, Equals, nil)
 	defer r.Close()
 	c.Check(n, Equals, int64(3))
diff --git a/sdk/go/keepclient/root_sorter.go b/sdk/go/keepclient/root_sorter.go
index c2780bc..a8afea0 100644
--- a/sdk/go/keepclient/root_sorter.go
+++ b/sdk/go/keepclient/root_sorter.go
@@ -5,12 +5,12 @@ import (
 )
 
 type RootSorter struct {
-	root         []string
-	weight       []string
-	order        []int
+	root   []string
+	weight []string
+	order  []int
 }
 
-func NewRootSorter(serviceRoots map[string]string, hash string) (*RootSorter) {
+func NewRootSorter(serviceRoots map[string]string, hash string) *RootSorter {
 	rs := new(RootSorter)
 	rs.root = make([]string, len(serviceRoots))
 	rs.weight = make([]string, len(serviceRoots))
@@ -26,7 +26,7 @@ func NewRootSorter(serviceRoots map[string]string, hash string) (*RootSorter) {
 	return rs
 }
 
-func (rs RootSorter) getWeight(hash string, uuid string) (string) {
+func (rs RootSorter) getWeight(hash string, uuid string) string {
 	if len(uuid) == 27 {
 		return Md5String(hash + uuid[12:])
 	} else {
@@ -35,7 +35,7 @@ func (rs RootSorter) getWeight(hash string, uuid string) (string) {
 	}
 }
 
-func (rs RootSorter) GetSortedRoots() ([]string) {
+func (rs RootSorter) GetSortedRoots() []string {
 	sorted := make([]string, len(rs.order))
 	for i := range rs.order {
 		sorted[i] = rs.root[rs.order[i]]
diff --git a/sdk/go/keepclient/root_sorter_test.go b/sdk/go/keepclient/root_sorter_test.go
index 455715d..23e8cc9 100644
--- a/sdk/go/keepclient/root_sorter_test.go
+++ b/sdk/go/keepclient/root_sorter_test.go
@@ -8,19 +8,20 @@ import (
 )
 
 type RootSorterSuite struct{}
+
 var _ = Suite(&RootSorterSuite{})
 
-func FakeSvcRoot(i uint64) (string) {
+func FakeSvcRoot(i uint64) string {
 	return fmt.Sprintf("https://%x.svc/", i)
 }
 
-func FakeSvcUuid(i uint64) (string) {
+func FakeSvcUuid(i uint64) string {
 	return fmt.Sprintf("zzzzz-bi6l4-%015x", i)
 }
 
-func FakeServiceRoots(n uint64) (map[string]string) {
+func FakeServiceRoots(n uint64) map[string]string {
 	sr := map[string]string{}
-	for i := uint64(0); i < n; i ++ {
+	for i := uint64(0); i < n; i++ {
 		sr[FakeSvcUuid(i)] = FakeSvcRoot(i)
 	}
 	return sr

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list