Added unit test for protocols in From field.
authormishaz <misha@curoverse.com>
Tue, 9 Jun 2015 18:31:55 +0000 (18:31 +0000)
committermishaz <misha@curoverse.com>
Tue, 9 Jun 2015 18:31:55 +0000 (18:31 +0000)
services/datamanager/summary/pull_list.go
services/datamanager/summary/pull_list_test.go

index 542a6693d2358535dfb4e1b8d76c910af853cd02..950d1d056b762e937a36d5d4c66c51f5f40a362c 100644 (file)
@@ -71,7 +71,7 @@ func ComputePullServers(kc *keepclient.KeepClient,
        // Servers that are writeable
        writableServers := map[string]struct{}{}
        for _, url := range kc.WritableLocalRoots() {
-               writableServers[cs.Get(RemoveProtocolPrefix(url))] = struct{}{}
+               writableServers[cs.Get(url)] = struct{}{}
        }
 
        for block, _ := range underReplicated {
@@ -129,7 +129,7 @@ func CreatePullServers(cs CanonicalString,
                        // The from field should include the protocol.
                        ps.From = append(ps.From, cs.Get(host))
                } else if len(ps.To) < maxToFields {
-                       _, writable := writableServers[server]
+                       _, writable := writableServers[host]
                        if writable {
                                ps.To = append(ps.To, server)
                        }
index 9628a32018936bcc157e44b429b351bdaf218f56..8f17d28bb55986295a0047b3314a1c2d3c650f0e 100644 (file)
@@ -100,6 +100,18 @@ func (s *MySuite) TestCreatePullServers(c *C) {
                PullServers{To: []string{"keep3:25110"},
                        From: []string{"keep1:25108", "keep0:25107"}})
 
+       c.Check(
+               CreatePullServers(cs,
+                       stringSet("keep0:25107", "keep1:25108"),
+                       stringSet("https://keep3:25110", "http://keep2:25109",
+                               "https://keep1:25108", "http://keep0:25107"),
+                       []string{"https://keep3:25110", "http://keep2:25109",
+                               "https://keep1:25108", "http://keep0:25107"},
+                       1),
+               DeepEquals,
+               PullServers{To: []string{"keep3:25110"},
+                       From: []string{"https://keep1:25108", "http://keep0:25107"}})
+
        c.Check(
                CreatePullServers(cs,
                        stringSet("keep0:25107", "keep1:25108"),