test_mutable.py: test replacing a file that has one new outlier share present: closes...
authorBrian Warner <warner@allmydata.com>
Wed, 14 May 2008 20:10:41 +0000 (13:10 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 14 May 2008 20:10:41 +0000 (13:10 -0700)
src/allmydata/test/test_mutable.py

index 845670dc23061f9426b3dd64e557f72c0b2f6c1d..ac0451407fac3a5b6b0562135eb42080f8555cdd 100644 (file)
@@ -1255,6 +1255,32 @@ class MultipleVersions(unittest.TestCase):
                                                   res == self.CONTENTS[4]))
         return d
 
+    def test_replace(self):
+        # if we see a mix of versions in the grid, we should be able to
+        # replace them all with a newer version
+
+        # if exactly one share is at version 3, we should download (and
+        # replace) v2, and the result should be v4. Note that the index we
+        # give to _set_versions is different than the sequence number.
+        target = dict([(i,2) for i in range(10)]) # seqnum3
+        target[0] = 3 # seqnum4
+        self._set_versions(target)
+
+        def _modify(oldversion):
+            return oldversion + " modified"
+        d = self._fn.modify(_modify)
+        d.addCallback(lambda res: self._fn.download_best_version())
+        expected = self.CONTENTS[2] + " modified"
+        d.addCallback(lambda res: self.failUnlessEqual(res, expected))
+        # and the servermap should indicate that the outlier was replaced too
+        d.addCallback(lambda res: self._fn.get_servermap(MODE_CHECK))
+        def _check_smap(smap):
+            self.failUnlessEqual(smap.highest_seqnum(), 5)
+            self.failUnlessEqual(len(smap.unrecoverable_versions()), 0)
+            self.failUnlessEqual(len(smap.recoverable_versions()), 1)
+        d.addCallback(_check_smap)
+        return d
+
 
 class Utils(unittest.TestCase):
     def test_dict_of_sets(self):