]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Sun May 13 08:59:30 BST 2012 Brian Warner <warner@lothar.com>
authorDaira Hopwood <daira@jacaranda.org>
Thu, 5 Sep 2013 17:01:49 +0000 (18:01 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Thu, 5 Sep 2013 17:01:49 +0000 (18:01 +0100)
  * Fixed an error in previous commit where an empty servermap would throw an exception in 'count-good-share-hosts'. Augmented unit test.

Signed-off-by: Andrew Miller <amiller@dappervision.com>
src/allmydata/immutable/filenode.py
src/allmydata/test/test_checker.py

index 7f15c1138b9061e6a85d952170fc13cad5c3d2a2..b338ea7d9d35e79a3d1cc331d77f60a4e8f94a5c 100644 (file)
@@ -124,7 +124,8 @@ class CiphertextFileNode:
                     servers_responding = sorted(servers_responding)
                     prr.data['servers-responding'] = servers_responding
                     prr.data['count-shares-good'] = len(sm)
-                    prr.data['count-good-share-hosts'] = len(reduce(set.union, sm.itervalues()))
+                    prr.data['count-good-share-hosts'] = len(reduce(set.union, 
+                                                       sm.itervalues(), set()))
                     is_healthy = bool(len(sm) >= verifycap.total_shares)
                     is_recoverable = bool(len(sm) >= verifycap.needed_shares)
                     prr.set_healthy(is_healthy)
index 6ba22e5a016493323958714026241fc0d50406a0..8efe4d8f47abeb270fd04ace0c03fef924348e5e 100644 (file)
@@ -350,17 +350,17 @@ class BalancingAct(GridTestMixin, unittest.TestCase):
         def add_three(_, i):
             # Add a new server with just share 3
             self.add_server_with_share(i, self.uri, 3)
-            #print self._shares_chart(self.uri)
+            #print self._pretty_shares_chart(self.uri)
         for i in range(1,5):
             d.addCallback(add_three, i)
     
         def _check_and_repair(_):
             return self.imm.check_and_repair(Monitor())
-        def _check_counts(crr): 
+        def _check_counts(crr, shares_good, good_share_hosts):
             p_crr = crr.get_post_repair_results().data
-            #print self._shares_chart(self.uri)
-            self.failUnless(p_crr['count-shares-good'] == 4)
-            self.failUnless(p_crr['count-good-share-hosts'] == 5)
+            #print self._pretty_shares_chart(self.uri)
+            self.failUnless(p_crr['count-shares-good'] == shares_good)
+            self.failUnless(p_crr['count-good-share-hosts'] == good_share_hosts)
 
         """
         Initial sharemap: 
@@ -371,11 +371,14 @@ class BalancingAct(GridTestMixin, unittest.TestCase):
           Still 4 good shares and 5 good hosts
             """
         d.addCallback(_check_and_repair)
-        d.addCallback(_check_counts)
+        d.addCallback(_check_counts, 4, 5)
         d.addCallback(lambda _: self.delete_shares_numbered(self.uri, [3]))
         d.addCallback(_check_and_repair)
-        d.addCallback(_check_counts)
-
+        d.addCallback(_check_counts, 4, 5)
+        d.addCallback(lambda _: [self.g.break_server(sid) for sid 
+                                 in self.g.get_all_serverids()])
+        d.addCallback(_check_and_repair)
+        d.addCallback(_check_counts, 0, 0)
         return d
 
 class AddLease(GridTestMixin, unittest.TestCase):