expirer: tolerate empty buckets, refactor bucketsize-counting code a bit, don't increment -mutable/-immutable counters unless we actually know the sharetype

This commit is contained in:
Brian Warner
2009-03-20 12:18:16 -07:00
parent 8645738c77
commit 3b65607926
2 changed files with 31 additions and 20 deletions

View File

@ -2324,6 +2324,12 @@ class LeaseCrawler(unittest.TestCase, pollmixin.PollMixin, WebRenderingMixin):
# of share we corrupted, this will trigger an
# UnknownImmutableContainerVersionError.
# also create an empty bucket
empty_si = base32.b2a("\x04"*16)
empty_bucket_dir = os.path.join(ss.sharedir,
storage_index_to_dir(empty_si))
fileutil.make_dirs(empty_bucket_dir)
ss.setServiceParent(self.s)
d = eventual.fireEventually()
@ -2361,7 +2367,7 @@ class LeaseCrawler(unittest.TestCase, pollmixin.PollMixin, WebRenderingMixin):
s = lc.get_state()
last = s["history"][0]
rec = last["space-recovered"]
self.failUnlessEqual(rec["examined-buckets"], 4)
self.failUnlessEqual(rec["examined-buckets"], 5)
self.failUnlessEqual(rec["examined-shares"], 3)
self.failUnlessEqual(last["corrupt-shares"], [(first_b32, 0)])
d.addCallback(_after_first_cycle)