From 3812c3e89d4048a91db28b4b9276f0c45dba7201 Mon Sep 17 00:00:00 2001 From: mishaz Date: Tue, 9 Jun 2015 18:31:55 +0000 Subject: [PATCH] Added unit test for protocols in From field. --- services/datamanager/summary/pull_list.go | 4 ++-- services/datamanager/summary/pull_list_test.go | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/services/datamanager/summary/pull_list.go b/services/datamanager/summary/pull_list.go index 542a6693d2..950d1d056b 100644 --- a/services/datamanager/summary/pull_list.go +++ b/services/datamanager/summary/pull_list.go @@ -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) } diff --git a/services/datamanager/summary/pull_list_test.go b/services/datamanager/summary/pull_list_test.go index 9628a32018..8f17d28bb5 100644 --- a/services/datamanager/summary/pull_list_test.go +++ b/services/datamanager/summary/pull_list_test.go @@ -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"), -- 2.30.2