]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
immutable: test for #1118
authorZooko O'Whielacronx <zooko@zooko.com>
Sun, 18 Jul 2010 22:15:37 +0000 (15:15 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Sun, 18 Jul 2010 22:15:37 +0000 (15:15 -0700)
src/allmydata/immutable/upload.py
src/allmydata/test/test_upload.py

index 3f4803af37b15c1e1d28b411986c67291002ed2e..60e1078fc376b4e154e5af71904a2951d9767da7 100644 (file)
@@ -916,7 +916,7 @@ class CHKUploader:
             for shnum in peer.buckets:
                 self._peer_trackers[shnum] = peer
                 servermap.setdefault(shnum, set()).add(peer.peerid)
-        assert len(buckets) == sum([len(peer.buckets) for peer in used_peers])
+        assert len(buckets) == sum([len(peer.buckets) for peer in used_peers]), "%s (%s) != %s (%s)" % (len(buckets), buckets, sum([len(peer.buckets) for peer in used_peers]), [(p.buckets, p.peerid) for p in used_peers])
         encoder.set_shareholders(buckets, servermap)
 
     def _encrypted_done(self, verifycap):
index 782f52f432084fb861f8f8529c07294792404fa7..d3b80aa069a447d4c9fd782ccd4cb58115b018d3 100644 (file)
@@ -1786,6 +1786,37 @@ class EncodingParameters(GridTestMixin, unittest.TestCase, SetDEPMixin,
         return d
     test_problem_layout_comment_187.todo = "this isn't fixed yet"
 
+    def test_problem_layout_ticket_1118(self):
+        # #1118 includes a report from a user who hit an assertion in
+        # the upload code with this layout.
+        self.basedir = self.mktemp()
+        d = self._setup_and_upload(k=2, n=4)
+
+        # server 0: no shares
+        # server 1: shares 0, 3
+        # server 3: share 1
+        # server 2: share 2
+        # The order that they get queries is 0, 1, 3, 2
+        def _setup(ign):
+            self._add_server(server_number=0)
+            self._add_server_with_share(server_number=1, share_number=0)
+            self._add_server_with_share(server_number=2, share_number=2)
+            self._add_server_with_share(server_number=3, share_number=1)
+            # Copy shares
+            self._copy_share_to_server(3, 1)
+            storedir = self.get_serverdir(0)
+            # remove the storedir, wiping out any existing shares
+            shutil.rmtree(storedir)
+            # create an empty storedir to replace the one we just removed
+            os.mkdir(storedir)
+            client = self.g.clients[0]
+            client.DEFAULT_ENCODING_PARAMETERS['happy'] = 4
+            return client
+
+        d.addCallback(_setup)
+        d.addCallback(lambda client:
+                          client.upload(upload.Data("data" * 10000, convergence="")))
+        return d
 
     def test_upload_succeeds_with_some_homeless_shares(self):
         # If the upload is forced to stop trying to place shares before