[ARVADOS] updated: 999c05af58ef1bb6f2b6804301f6ef8d02544a2b
git at public.curoverse.com
git at public.curoverse.com
Tue May 19 15:25:08 EDT 2015
Summary of changes:
services/datamanager/summary/pull_list.go | 24 ++--
services/datamanager/summary/pull_list_test.go | 152 ++++++++++++-------------
2 files changed, 81 insertions(+), 95 deletions(-)
via 999c05af58ef1bb6f2b6804301f6ef8d02544a2b (commit)
from b2329e2ce27a24a2d964743a87091413b0e5858e (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 999c05af58ef1bb6f2b6804301f6ef8d02544a2b
Author: mishaz <misha at curoverse.com>
Date: Tue May 19 19:10:35 2015 +0000
Modified pull list code to change json output to match the specification at https://arvados.org/projects/arvados/wiki/Keep_Design_Doc#Pull-List
Changed PullList type
Renamed PullListEntry to PullRequest to match the type defined in services/keepstore/handlers.go
Renamed EntriesByDigest sorter to PullListByDigest
Modified TestPullListPrintsJSONCorrectly to update expected json format.
Lots of changes in unittests to accomodate renames.
Reformatted test to improve readability.
diff --git a/services/datamanager/summary/pull_list.go b/services/datamanager/summary/pull_list.go
index 6273bba..64a83a5 100644
--- a/services/datamanager/summary/pull_list.go
+++ b/services/datamanager/summary/pull_list.go
@@ -24,23 +24,21 @@ func (l Locator) MarshalJSON() ([]byte, error) {
}
// One entry in the Pull List
-type PullListEntry struct {
+type PullRequest struct {
Locator Locator `json:"locator"`
Servers []string `json:"servers"`
}
// The Pull List for a particular server
-type PullList struct {
- Entries []PullListEntry `json:"blocks"`
-}
+type PullList []PullRequest
-// EntriesByDigest implements sort.Interface for []PullListEntry
-// based on the Digest.
-type EntriesByDigest []PullListEntry
+// PullListByDigest implements sort.Interface for PullList based on
+// the Digest.
+type PullListByDigest PullList
-func (a EntriesByDigest) Len() int { return len(a) }
-func (a EntriesByDigest) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
-func (a EntriesByDigest) Less(i, j int) bool {
+func (a PullListByDigest) Len() int { return len(a) }
+func (a PullListByDigest) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
+func (a PullListByDigest) Less(i, j int) bool {
di, dj := a[i].Locator.Digest, a[j].Locator.Digest
return di.H < dj.H || (di.H == dj.H && di.L < dj.L)
}
@@ -138,11 +136,11 @@ func BuildPullLists(lps map[Locator]PullServers) (spl map[string]PullList) {
for _, destination := range pullServers.To {
pullList, pullListExists := spl[destination]
if !pullListExists {
- pullList = PullList{Entries: []PullListEntry{}}
+ pullList = PullList{}
spl[destination] = pullList
}
- pullList.Entries = append(pullList.Entries,
- PullListEntry{Locator: locator, Servers: pullServers.From})
+ pullList = append(pullList,
+ PullRequest{Locator: locator, Servers: pullServers.From})
spl[destination] = pullList
}
}
diff --git a/services/datamanager/summary/pull_list_test.go b/services/datamanager/summary/pull_list_test.go
index dd73bf5..5638dc4 100644
--- a/services/datamanager/summary/pull_list_test.go
+++ b/services/datamanager/summary/pull_list_test.go
@@ -28,16 +28,16 @@ func stringSet(slice ...string) (m map[string]struct{}) {
}
func (s *MySuite) TestPullListPrintsJSONCorrectly(c *C) {
- pl := PullList{Entries: []PullListEntry{PullListEntry{
+ pl := PullList{PullRequest{
Locator: Locator{Digest: blockdigest.MakeTestBlockDigest(0xBadBeef)},
Servers: []string{"keep0.qr1hi.arvadosapi.com:25107",
- "keep1.qr1hi.arvadosapi.com:25108"}}}}
+ "keep1.qr1hi.arvadosapi.com:25108"}}}
b, err := json.Marshal(pl)
c.Assert(err, IsNil)
- expectedOutput := `{"blocks":[{"locator":"0000000000000000000000000badbeef",` +
+ expectedOutput := `[{"locator":"0000000000000000000000000badbeef",` +
`"servers":["keep0.qr1hi.arvadosapi.com:25107",` +
- `"keep1.qr1hi.arvadosapi.com:25108"]}]}`
+ `"keep1.qr1hi.arvadosapi.com:25108"]}]`
c.Check(string(b), Equals, expectedOutput)
}
@@ -113,18 +113,19 @@ func (c *pullListMapEqualsChecker) Check(params []interface{}, names []string) (
}
for _, v := range obtained {
- sort.Sort(EntriesByDigest(v.Entries))
+ sort.Sort(PullListByDigest(v))
}
for _, v := range expected {
- sort.Sort(EntriesByDigest(v.Entries))
+ sort.Sort(PullListByDigest(v))
}
return DeepEquals.Check(params, names)
}
-var PullListMapEquals Checker = &pullListMapEqualsChecker{
- &CheckerInfo{Name: "PullListMapEquals", Params: []string{"obtained", "expected"}},
-}
+var PullListMapEquals Checker = &pullListMapEqualsChecker{&CheckerInfo{
+ Name: "PullListMapEquals",
+ Params: []string{"obtained", "expected"},
+}}
func (s *MySuite) TestBuildPullLists(c *C) {
c.Check(
@@ -149,29 +150,28 @@ func (s *MySuite) TestBuildPullLists(c *C) {
BuildPullLists(map[Locator]PullServers{
locator1: PullServers{To: []string{"t1"}, From: []string{"f1", "f2"}}}),
PullListMapEquals,
- map[string]PullList{"t1": PullList{Entries: []PullListEntry{PullListEntry{
- Locator: locator1,
- Servers: []string{"f1", "f2"}}}}})
+ map[string]PullList{"t1": PullList{
+ PullRequest{Locator: locator1, Servers: []string{"f1", "f2"}}}})
c.Check(
BuildPullLists(map[Locator]PullServers{
locator1: PullServers{To: []string{"t1"}, From: []string{}}}),
PullListMapEquals,
- map[string]PullList{"t1": PullList{Entries: []PullListEntry{PullListEntry{
- Locator: locator1,
- Servers: []string{}}}}})
+ map[string]PullList{"t1": PullList{
+ PullRequest{Locator: locator1, Servers: []string{}}}})
c.Check(
BuildPullLists(map[Locator]PullServers{
- locator1: PullServers{To: []string{"t1", "t2"}, From: []string{"f1", "f2"}}}),
+ locator1: PullServers{
+ To: []string{"t1", "t2"},
+ From: []string{"f1", "f2"},
+ }}),
PullListMapEquals,
map[string]PullList{
- "t1": PullList{Entries: []PullListEntry{PullListEntry{
- Locator: locator1,
- Servers: []string{"f1", "f2"}}}},
- "t2": PullList{Entries: []PullListEntry{PullListEntry{
- Locator: locator1,
- Servers: []string{"f1", "f2"}}}},
+ "t1": PullList{
+ PullRequest{Locator: locator1, Servers: []string{"f1", "f2"}}},
+ "t2": PullList{
+ PullRequest{Locator: locator1, Servers: []string{"f1", "f2"}}},
})
locator2 := Locator{Digest: blockdigest.MakeTestBlockDigest(0xCabbed)}
@@ -181,81 +181,69 @@ func (s *MySuite) TestBuildPullLists(c *C) {
locator2: PullServers{To: []string{"t2"}, From: []string{"f3", "f4"}}}),
PullListMapEquals,
map[string]PullList{
- "t1": PullList{Entries: []PullListEntry{PullListEntry{
- Locator: locator1,
- Servers: []string{"f1", "f2"}}}},
- "t2": PullList{Entries: []PullListEntry{PullListEntry{
- Locator: locator2,
- Servers: []string{"f3", "f4"}}}},
+ "t1": PullList{
+ PullRequest{Locator: locator1, Servers: []string{"f1", "f2"}}},
+ "t2": PullList{
+ PullRequest{Locator: locator2, Servers: []string{"f3", "f4"}}},
})
c.Check(
BuildPullLists(map[Locator]PullServers{
- locator1: PullServers{To: []string{"t1"}, From: []string{"f1", "f2"}},
- locator2: PullServers{To: []string{"t2", "t1"}, From: []string{"f3", "f4"}}}),
+ locator1: PullServers{
+ To: []string{"t1"},
+ From: []string{"f1", "f2"}},
+ locator2: PullServers{
+ To: []string{"t2", "t1"},
+ From: []string{"f3", "f4"}},
+ }),
PullListMapEquals,
map[string]PullList{
- "t1": PullList{Entries: []PullListEntry{
- PullListEntry{
- Locator: locator1,
- Servers: []string{"f1", "f2"}},
- PullListEntry{
- Locator: locator2,
- Servers: []string{"f3", "f4"}}}},
- "t2": PullList{Entries: []PullListEntry{PullListEntry{
- Locator: locator2,
- Servers: []string{"f3", "f4"}}}},
+ "t1": PullList{
+ PullRequest{Locator: locator1, Servers: []string{"f1", "f2"}},
+ PullRequest{Locator: locator2, Servers: []string{"f3", "f4"}},
+ },
+ "t2": PullList{
+ PullRequest{Locator: locator2, Servers: []string{"f3", "f4"}},
+ },
})
locator3 := Locator{Digest: blockdigest.MakeTestBlockDigest(0xDeadBeef)}
locator4 := Locator{Digest: blockdigest.MakeTestBlockDigest(0xFedBeef)}
c.Check(
BuildPullLists(map[Locator]PullServers{
- locator1: PullServers{To: []string{"t1"}, From: []string{"f1", "f2"}},
- locator2: PullServers{To: []string{"t2", "t1"}, From: []string{"f3", "f4"}},
- locator3: PullServers{To: []string{"t3", "t2", "t1"}, From: []string{"f4", "f5"}},
- locator4: PullServers{To: []string{"t4", "t3", "t2", "t1"}, From: []string{"f1", "f5"}},
+ locator1: PullServers{
+ To: []string{"t1"},
+ From: []string{"f1", "f2"}},
+ locator2: PullServers{
+ To: []string{"t2", "t1"},
+ From: []string{"f3", "f4"}},
+ locator3: PullServers{
+ To: []string{"t3", "t2", "t1"},
+ From: []string{"f4", "f5"}},
+ locator4: PullServers{
+ To: []string{"t4", "t3", "t2", "t1"},
+ From: []string{"f1", "f5"}},
}),
PullListMapEquals,
map[string]PullList{
- "t1": PullList{Entries: []PullListEntry{
- PullListEntry{
- Locator: locator1,
- Servers: []string{"f1", "f2"}},
- PullListEntry{
- Locator: locator2,
- Servers: []string{"f3", "f4"}},
- PullListEntry{
- Locator: locator3,
- Servers: []string{"f4", "f5"}},
- PullListEntry{
- Locator: locator4,
- Servers: []string{"f1", "f5"}},
- }},
- "t2": PullList{Entries: []PullListEntry{
- PullListEntry{
- Locator: locator2,
- Servers: []string{"f3", "f4"}},
- PullListEntry{
- Locator: locator3,
- Servers: []string{"f4", "f5"}},
- PullListEntry{
- Locator: locator4,
- Servers: []string{"f1", "f5"}},
- }},
- "t3": PullList{Entries: []PullListEntry{
- PullListEntry{
- Locator: locator3,
- Servers: []string{"f4", "f5"}},
- PullListEntry{
- Locator: locator4,
- Servers: []string{"f1", "f5"}},
- }},
- "t4": PullList{Entries: []PullListEntry{
- PullListEntry{
- Locator: locator4,
- Servers: []string{"f1", "f5"}},
- }},
+ "t1": PullList{
+ PullRequest{Locator: locator1, Servers: []string{"f1", "f2"}},
+ PullRequest{Locator: locator2, Servers: []string{"f3", "f4"}},
+ PullRequest{Locator: locator3, Servers: []string{"f4", "f5"}},
+ PullRequest{Locator: locator4, Servers: []string{"f1", "f5"}},
+ },
+ "t2": PullList{
+ PullRequest{Locator: locator2, Servers: []string{"f3", "f4"}},
+ PullRequest{Locator: locator3, Servers: []string{"f4", "f5"}},
+ PullRequest{Locator: locator4, Servers: []string{"f1", "f5"}},
+ },
+ "t3": PullList{
+ PullRequest{Locator: locator3, Servers: []string{"f4", "f5"}},
+ PullRequest{Locator: locator4, Servers: []string{"f1", "f5"}},
+ },
+ "t4": PullList{
+ PullRequest{Locator: locator4, Servers: []string{"f1", "f5"}},
+ },
})
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list