]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
test_system.py: add coverage for allmydata.control
authorBrian Warner <warner@allmydata.com>
Wed, 26 Sep 2007 19:06:55 +0000 (12:06 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 26 Sep 2007 19:06:55 +0000 (12:06 -0700)
src/allmydata/control.py
src/allmydata/test/test_system.py

index 5d0c75e8ed9c0332e867b94e8afba4fdf9cb23cf..7aca472fe422425ac3f2641cd0b6c36bc04fe2c1 100644 (file)
@@ -135,5 +135,7 @@ class SpeedTest:
 class Discard:
     def write(self, data):
         pass
-    def close(self):
-        pass
+    # download_to_filehandle explicitly does not close the filehandle it was
+    # given: that is reserved for the provider of the filehandle. Therefore
+    # the lack of a close() method on this otherwise filehandle-like object
+    # is a part of the test.
index 5a537448fd170dc40fa40c8f560b0efb397cec9a..e203d5d3bdc51dc04a792fcc5addbc5efe99516d 100644 (file)
@@ -1,6 +1,6 @@
 
 from base64 import b32encode
-import os
+import os, sys
 from cStringIO import StringIO
 from twisted.trial import unittest
 from twisted.internet import defer, reactor
@@ -288,7 +288,7 @@ class SystemTest(testutil.SignalMixin, unittest.TestCase):
         d.addCallback(self.log, "did _check_publish_private")
         d.addCallback(self._test_web)
         d.addCallback(self._test_web_start)
-        d.addCallback(self._test_runner)
+        d.addCallback(self._test_control)
         return d
     test_vdrive.timeout = 1100
 
@@ -661,3 +661,31 @@ class SystemTest(testutil.SignalMixin, unittest.TestCase):
                     ):
             self.failUnless("%s: " % key in output, key)
 
+    def _test_control(self, res):
+        # exercise the remote-control-the-client foolscap interfaces in
+        # allmydata.control (mostly used for performance tests)
+        c0 = self.clients[0]
+        control_furl_file = os.path.join(c0.basedir, "control.furl")
+        control_furl = open(control_furl_file, "r").read().strip()
+        # it doesn't really matter which Tub we use to connect to the client,
+        # so let's just use our Introducer's
+        d = self.introducer_and_vdrive.tub.getReference(control_furl)
+        d.addCallback(self._test_control2, control_furl_file)
+        return d
+    def _test_control2(self, rref, filename):
+        d = rref.callRemote("upload_from_file_to_uri", filename)
+        downfile = os.path.join(self.basedir, "control.downfile")
+        d.addCallback(lambda uri:
+                      rref.callRemote("download_from_uri_to_file",
+                                      uri, downfile))
+        def _check(res):
+            self.failUnlessEqual(res, downfile)
+            data = open(downfile, "r").read()
+            expected_data = open(filename, "r").read()
+            self.failUnlessEqual(data, expected_data)
+        d.addCallback(_check)
+        d.addCallback(lambda res: rref.callRemote("speed_test", 1, 200))
+        if sys.platform == "linux2":
+            d.addCallback(lambda res: rref.callRemote("get_memory_usage"))
+        return d
+