From: Brian Warner Date: Tue, 17 Jun 2008 00:52:40 +0000 (-0700) Subject: test_storage: add coverage for discard_storage X-Git-Tag: allmydata-tahoe-1.2.0~86 X-Git-Url: https://git.rkrishnan.org/?a=commitdiff_plain;h=2154b5751bfa75cf970f0499872dd1e2192b8ad1;p=tahoe-lafs%2Ftahoe-lafs.git test_storage: add coverage for discard_storage --- diff --git a/src/allmydata/test/test_storage.py b/src/allmydata/test/test_storage.py index e6218435..8d92db98 100644 --- a/src/allmydata/test/test_storage.py +++ b/src/allmydata/test/test_storage.py @@ -499,6 +499,26 @@ class Server(unittest.TestCase): self.failUnlessEqual(already, set()) self.failUnlessEqual(writers, {}) + def test_discard(self): + # discard is really only used for other tests, but we test it anyways + workdir = self.workdir("test_discard") + ss = StorageServer(workdir, discard_storage=True) + ss.setServiceParent(self.sparent) + + canary = FakeCanary() + already,writers = self.allocate(ss, "vid", [0,1,2], 75) + self.failUnlessEqual(already, set()) + self.failUnlessEqual(set(writers.keys()), set([0,1,2])) + for i,wb in writers.items(): + wb.remote_write(0, "%25d" % i) + wb.remote_close() + # since we discard the data, the shares should be present but sparse. + # Since we write with some seeks, the data we read back will be all + # zeros. + b = ss.remote_get_buckets("vid") + self.failUnlessEqual(set(b.keys()), set([0,1,2])) + self.failUnlessEqual(b[0].remote_read(0, 25), "\x00" * 25) + class MutableServer(unittest.TestCase):