]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
immutable: add test case of #1128, fix test case of #1118
authorZooko O'Whielacronx <zooko@zooko.com>
Mon, 19 Jul 2010 08:16:12 +0000 (01:16 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Mon, 19 Jul 2010 08:16:12 +0000 (01:16 -0700)
src/allmydata/test/test_upload.py

index 4ccf68a9e90c50ef61731128ef6db52eb575fee2..917472a2c3ce0acab041352965a9dff43f66c312 100644 (file)
@@ -1875,6 +1875,47 @@ class EncodingParameters(GridTestMixin, unittest.TestCase, SetDEPMixin,
         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)
+        # Note: actually it should succeed! See
+        # test_problem_layout_ticket_1128. But ticket 1118 is just to
+        # make it realize that it has failed, so if it raises
+        # UploadUnhappinessError then we'll give it the green light
+        # for now.
+        d.addCallback(lambda ignored:
+            self.shouldFail(UploadUnhappinessError,
+                            "test_problem_layout_ticket_1118",
+                            "",
+                            self.g.clients[0].upload, upload.Data("data" * 10000,
+                                                       convergence="")))
+        return d
+
+    def test_problem_layout_ticket_1128(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
@@ -1902,6 +1943,7 @@ class EncodingParameters(GridTestMixin, unittest.TestCase, SetDEPMixin,
         d.addCallback(lambda ign:
             self.failUnless(self._has_happy_share_distribution()))
         return d
+    test_problem_layout_ticket_1128.todo = "Invent a smarter uploader that uploads successfully in this case."
 
     def test_upload_succeeds_with_some_homeless_shares(self):
         # If the upload is forced to stop trying to place shares before