]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Fixed an error in previous commit where an empty servermap would throw an exception...
authorAndrew Miller <amiller@dappervision.com>
Sun, 1 Apr 2012 23:31:53 +0000 (19:31 -0400)
committerBrian Warner <warner@lothar.com>
Sun, 13 May 2012 07:59:30 +0000 (00:59 -0700)
Signed-off-by: Andrew Miller <amiller@dappervision.com>
src/allmydata/immutable/filenode.py
src/allmydata/test/test_checker.py

index f138311da234d105d833c9a00a29aa10bf59103e..0bcacb001440960e8042fef8b9e62679f1cfda4e 100644 (file)
@@ -122,7 +122,8 @@ class CiphertextFileNode:
                     servers_responding.union(ur.sharemap.iterkeys())
                     prr.data['servers-responding'] = list(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 cd10285fd82e246c4260b1a406d6c22a50361e19..27f4c4edd09e449277150e5f2007b41382ddeb69 100644 (file)
@@ -351,17 +351,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: 
@@ -372,11 +372,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):