From 2154b5751bfa75cf970f0499872dd1e2192b8ad1 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Mon, 16 Jun 2008 17:52:40 -0700 Subject: [PATCH] test_storage: add coverage for discard_storage --- src/allmydata/test/test_storage.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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): -- 2.45.2