]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
storage_client.py: clean up test_add_server/test_add_descriptor, remove .test_servers
authorBrian Warner <warner@lothar.com>
Sun, 27 Feb 2011 02:10:56 +0000 (19:10 -0700)
committerBrian Warner <warner@lothar.com>
Sun, 27 Feb 2011 02:10:56 +0000 (19:10 -0700)
src/allmydata/storage_client.py
src/allmydata/test/test_checker.py
src/allmydata/test/test_client.py
src/allmydata/test/test_mutable.py
src/allmydata/test/test_upload.py

index e1b3f553f521c605165a474eecd91240bba79d31..8f82097f844cd856702a9462c19387957303bdde 100644 (file)
@@ -71,15 +71,16 @@ class StorageFarmBroker:
         # own Reconnector, and will give us a RemoteReference when we ask
         # them for it.
         self.servers = {}
-        # self.test_servers are statically configured from unit tests
-        self.test_servers = {} # serverid -> rref
         self.introducer_client = None
 
     # these two are used in unit tests
-    def test_add_server(self, serverid, rref):
-        self.test_servers[serverid] = rref
-    def test_add_descriptor(self, serverid, dsc):
-        self.servers[serverid] = dsc
+    def test_add_rref(self, serverid, rref):
+        s = NativeStorageServer(serverid, {})
+        s.rref = rref
+        self.servers[serverid] = s
+
+    def test_add_server(self, serverid, s):
+        self.servers[serverid] = s
 
     def use_introducer(self, introducer_client):
         self.introducer_client = ic = introducer_client
@@ -124,7 +125,6 @@ class StorageFarmBroker:
 
     def get_all_serverids(self):
         serverids = set()
-        serverids.update(self.test_servers.keys())
         serverids.update(self.servers.keys())
         return frozenset(serverids)
 
@@ -133,13 +133,7 @@ class StorageFarmBroker:
                           if s.get_rref()])
 
     def get_known_servers(self):
-        servers = []
-        for serverid,rref in self.test_servers.items():
-            s = NativeStorageServer(serverid, {})
-            s.rref = rref
-            servers.append(s)
-        servers.extend(self.servers.values())
-        return sorted(servers, key=lambda s: s.get_serverid())
+        return sorted(self.servers.values(), key=lambda s: s.get_serverid())
 
     def get_nickname_for_serverid(self, serverid):
         if serverid in self.servers:
index d1cf86f7f31ae1c9174436831b364be9774586af..b302c10d612d8a8f6d6fa385c19fa0cbb25b8601 100644 (file)
@@ -28,8 +28,8 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin):
                       "my-version": "ver",
                       "oldest-supported": "oldest",
                       }
-            dsc = NativeStorageServer(peerid, ann_d)
-            sb.test_add_descriptor(peerid, dsc)
+            s = NativeStorageServer(peerid, ann_d)
+            sb.test_add_server(peerid, s)
         c = FakeClient()
         c.storage_broker = sb
         return c
index b0aea3d5c5c10a9912ef22cddbd0e2d02846648f..62ce712cd54b8b339765fd4d5ff8aa3515d7a15c 100644 (file)
@@ -129,11 +129,11 @@ class Basic(testutil.ReallyEqualMixin, unittest.TestCase):
     def test_permute(self):
         sb = StorageFarmBroker(None, True)
         for k in ["%d" % i for i in range(5)]:
-            sb.test_add_server(k, "rref")
+            sb.test_add_rref(k, "rref")
 
         self.failUnlessReallyEqual(self._permute(sb, "one"), ['3','1','0','4','2'])
         self.failUnlessReallyEqual(self._permute(sb, "two"), ['0','4','2','1','3'])
-        sb.test_servers.clear()
+        sb.servers.clear()
         self.failUnlessReallyEqual(self._permute(sb, "one"), [])
 
     def test_versions(self):
index 0f49dced98f975e3d5679480e16da90ebeb06a43..907d497af02447234f6e16026cb70174ff2d43e3 100644 (file)
@@ -188,7 +188,7 @@ def make_storagebroker(s=None, num_peers=10):
     storage_broker = StorageFarmBroker(None, True)
     for peerid in peerids:
         fss = FakeStorageServer(peerid, s)
-        storage_broker.test_add_server(peerid, fss)
+        storage_broker.test_add_rref(peerid, fss)
     return storage_broker
 
 def make_nodemaker(s=None, num_peers=10):
index 11259324473228a2ea8ee33f905c2eaccc5c5226..e7368604e60e8823f7349e71590b9c7bea30541a 100644 (file)
@@ -196,8 +196,8 @@ class FakeClient:
         peers = [ ("%20d"%fakeid, FakeStorageServer(mode[fakeid]))
                   for fakeid in range(self.num_servers) ]
         self.storage_broker = StorageFarmBroker(None, permute_peers=True)
-        for (serverid, server) in peers:
-            self.storage_broker.test_add_server(serverid, server)
+        for (serverid, rref) in peers:
+            self.storage_broker.test_add_rref(serverid, rref)
         self.last_peers = [p[1] for p in peers]
 
     def log(self, *args, **kwargs):