]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
immutable: fix bug in tests, change line-endings to unix style, add comment
authorZooko O'Whielacronx <zooko@zooko.com>
Fri, 29 Jan 2010 18:42:37 +0000 (10:42 -0800)
committerZooko O'Whielacronx <zooko@zooko.com>
Fri, 29 Jan 2010 18:42:37 +0000 (10:42 -0800)
src/allmydata/immutable/download.py
src/allmydata/test/test_hung_server.py

index d5e29b8d43c5a31fdc4d8383fa1ac72df0054889..9262da8537c1352c5175f2c29144d1a9cb719ae8 100644 (file)
@@ -804,6 +804,11 @@ class CiphertextDownloader(log.PrefixingLogMixin):
         # self._current_segnum = 0
         # self._vup # ValidatedExtendedURIProxy
 
+        # _get_all_shareholders() will create the following:
+        # self._total_queries
+        # self._responses_received = 0
+        # self._queries_failed = 0
+
     def pauseProducing(self):
         if self._paused:
             return
index 5f85510646482494686245dd442e8a0a14a39c8a..ce34cba79051c0d15b8307087abf10e786840fa0 100644 (file)
@@ -45,45 +45,45 @@ class HungServerDownloadTest(GridTestMixin, ShouldFailMixin, unittest.TestCase):
         for (i_shnum, i_serverid, i_sharefile) in self.shares:
             if i_serverid in serverids:
                 self._copy_share((i_shnum, i_sharefile), to_server)
-\r
+
     # untested
-    def _copy_share(self, share, to_server):\r
-         (sharenum, sharefile) = share\r
-         (id, ss) = to_server\r
-         # FIXME: this doesn't work because we only have a LocalWrapper\r
-         shares_dir = os.path.join(ss.storedir, "shares")\r
-         si = uri.from_string(self.uri).get_storage_index()\r
-         si_dir = os.path.join(shares_dir, storage_index_to_dir(si))\r
-         if not os.path.exists(si_dir):\r
-             os.makedirs(si_dir)\r
-         new_sharefile = os.path.join(si_dir, str(sharenum))\r
-         shutil.copy(sharefile, new_sharefile)\r
-         self.shares = self.find_shares(self.uri)\r
-         # Make sure that the storage server has the share.\r
-         self.failUnless((sharenum, ss.my_nodeid, new_sharefile)\r
-                         in self.shares)\r
-\r
+    def _copy_share(self, share, to_server):
+         (sharenum, sharefile) = share
+         (id, ss) = to_server
+         # FIXME: this doesn't work because we only have a LocalWrapper
+         shares_dir = os.path.join(ss.original.storedir, "shares")
+         si = uri.from_string(self.uri).get_storage_index()
+         si_dir = os.path.join(shares_dir, storage_index_to_dir(si))
+         if not os.path.exists(si_dir):
+             os.makedirs(si_dir)
+         new_sharefile = os.path.join(si_dir, str(sharenum))
+         shutil.copy(sharefile, new_sharefile)
+         self.shares = self.find_shares(self.uri)
+         # Make sure that the storage server has the share.
+         self.failUnless((sharenum, ss.original.my_nodeid, new_sharefile)
+                         in self.shares)
+
     # untested
-    def _add_server(self, server_number, readonly=False):\r
-        ss = self.g.make_server(server_number, readonly)\r
-        self.g.add_server(server_number, ss)\r
-        self.shares = self.find_shares(self.uri)\r
+    def _add_server(self, server_number, readonly=False):
+        ss = self.g.make_server(server_number, readonly)
+        self.g.add_server(server_number, ss)
+        self.shares = self.find_shares(self.uri)
 
     def _set_up(self, testdir, num_clients=1, num_servers=10):
         self.basedir = "download/" + testdir
         self.set_up_grid(num_clients=num_clients, num_servers=num_servers)
-\r
-        self.c0 = self.g.clients[0]\r
+
+        self.c0 = self.g.clients[0]
         sb = self.c0.nodemaker.storage_broker
         self.servers = [(id, ss) for (id, ss) in sb.get_all_servers()]
-\r
-        data = upload.Data(immutable_plaintext, convergence="")\r
-        d = self.c0.upload(data)\r
-        def _uploaded(ur):\r
-            self.uri = ur.uri\r
-            self.shares = self.find_shares(self.uri)\r
-        d.addCallback(_uploaded)\r
-        return d\r
+
+        data = upload.Data(immutable_plaintext, convergence="")
+        d = self.c0.upload(data)
+        def _uploaded(ur):
+            self.uri = ur.uri
+            self.shares = self.find_shares(self.uri)
+        d.addCallback(_uploaded)
+        return d
 
     def test_10_good_sanity_check(self):
         d = self._set_up("test_10_good_sanity_check")
@@ -92,19 +92,19 @@ class HungServerDownloadTest(GridTestMixin, ShouldFailMixin, unittest.TestCase):
 
     def test_3_good_7_hung(self):
         d = self._set_up("test_3_good_7_hung")
-        d.addCallback(lambda ign: self._hang(self.servers[3:]))\r
+        d.addCallback(lambda ign: self._hang(self.servers[3:]))
         d.addCallback(lambda ign: self.download_immutable())
         return d
 
     def test_3_good_7_noshares(self):
         d = self._set_up("test_3_good_7_noshares")
-        d.addCallback(lambda ign: self._delete_all_shares_from(self.servers[3:]))\r
+        d.addCallback(lambda ign: self._delete_all_shares_from(self.servers[3:]))
         d.addCallback(lambda ign: self.download_immutable())
         return d
 
     def test_2_good_8_broken_fail(self):
         d = self._set_up("test_2_good_8_broken_fail")
-        d.addCallback(lambda ign: self._break(self.servers[2:]))\r
+        d.addCallback(lambda ign: self._break(self.servers[2:]))
         d.addCallback(lambda ign:
                       self.shouldFail(NotEnoughSharesError, "test_2_good_8_broken_fail",
                                       "Failed to get enough shareholders: have 2, need 3",
@@ -113,7 +113,7 @@ class HungServerDownloadTest(GridTestMixin, ShouldFailMixin, unittest.TestCase):
 
     def test_2_good_8_noshares_fail(self):
         d = self._set_up("test_2_good_8_noshares_fail")
-        d.addCallback(lambda ign: self._delete_all_shares_from(self.servers[2:]))\r
+        d.addCallback(lambda ign: self._delete_all_shares_from(self.servers[2:]))
         d.addCallback(lambda ign:
                       self.shouldFail(NotEnoughSharesError, "test_2_good_8_noshares_fail",
                                       "Failed to get enough shareholders: have 2, need 3",
@@ -123,8 +123,8 @@ class HungServerDownloadTest(GridTestMixin, ShouldFailMixin, unittest.TestCase):
     def test_2_good_8_hung_then_1_recovers(self):
         recovered = defer.Deferred()
         d = self._set_up("test_2_good_8_hung_then_1_recovers")
-        d.addCallback(lambda ign: self._hang(self.servers[2:3], until=recovered))\r
-        d.addCallback(lambda ign: self._hang(self.servers[3:]))\r
+        d.addCallback(lambda ign: self._hang(self.servers[2:3], until=recovered))
+        d.addCallback(lambda ign: self._hang(self.servers[3:]))
         d.addCallback(lambda ign: self.download_immutable())
         reactor.callLater(5, recovered.callback, None)
         return d
@@ -132,9 +132,9 @@ class HungServerDownloadTest(GridTestMixin, ShouldFailMixin, unittest.TestCase):
     def test_2_good_8_hung_then_1_recovers_with_2_shares(self):
         recovered = defer.Deferred()
         d = self._set_up("test_2_good_8_hung_then_1_recovers_with_2_shares")
-        d.addCallback(lambda ign: self._copy_all_shares_from(self.servers[0:1], self.servers[2]))\r
-        d.addCallback(lambda ign: self._hang(self.servers[2:3], until=recovered))\r
-        d.addCallback(lambda ign: self._hang(self.servers[3:]))\r
+        d.addCallback(lambda ign: self._copy_all_shares_from(self.servers[0:1], self.servers[2]))
+        d.addCallback(lambda ign: self._hang(self.servers[2:3], until=recovered))
+        d.addCallback(lambda ign: self._hang(self.servers[3:]))
         d.addCallback(lambda ign: self.download_immutable())
         reactor.callLater(5, recovered.callback, None)
         return d