]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
test_storage: add coverage for discard_storage
authorBrian Warner <warner@allmydata.com>
Tue, 17 Jun 2008 00:52:40 +0000 (17:52 -0700)
committerBrian Warner <warner@allmydata.com>
Tue, 17 Jun 2008 00:52:40 +0000 (17:52 -0700)
src/allmydata/test/test_storage.py

index e6218435f1fab5e55dd3d69d2b8dce14f9e4a5e5..8d92db989a41ed530562ecc33f3042268304889f 100644 (file)
@@ -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):