From: Brian Warner Date: Wed, 14 May 2008 20:10:41 +0000 (-0700) Subject: test_mutable.py: test replacing a file that has one new outlier share present: closes... X-Git-Tag: allmydata-tahoe-1.1.0~135 X-Git-Url: https://git.rkrishnan.org/pf/content/en/service/module-simplejson.encoder.html?a=commitdiff_plain;h=ff0b9e25499c7e5fd040915e7c8ae09c34f6f947;p=tahoe-lafs%2Ftahoe-lafs.git test_mutable.py: test replacing a file that has one new outlier share present: closes #272 --- diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py index 845670dc..ac045140 100644 --- a/src/allmydata/test/test_mutable.py +++ b/src/allmydata/test/test_mutable.py @@ -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):