]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
started framework for an automated speed-checking tool. Doesn't do much yet.
authorBrian Warner <warner@allmydata.com>
Thu, 20 Sep 2007 01:27:47 +0000 (18:27 -0700)
committerBrian Warner <warner@allmydata.com>
Thu, 20 Sep 2007 01:27:47 +0000 (18:27 -0700)
Makefile
src/allmydata/test/check_speed.py [new file with mode: 0644]

index 1ab835baa936001eca055398aa2cea810441ce37..3365027fc8a0a159e7cc4be01d2309e6c181718a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -202,6 +202,16 @@ check-memory-once: .built
        $(PP) \
         $(PYTHON) src/allmydata/test/check_memory.py $(MODE)
 
+# this target uses a pre-established client node to run a canned set of
+# performance tests against a test network that is also pre-established
+# (probably on a remote machine). Provide it with the path to a local
+# directory where this client node has been created (and populated with the
+# necessary FURLs of the test network). This target will restart that client
+# with the current code and then run the tests.
+check-speed: .built
+       if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
+       $(PYTHON) bin/allmydata-tahoe restart -f $(TESTCLIENTDIR)
+       $(PYTHON) src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
 
 test-darcs-boringfile:
        $(MAKE)
diff --git a/src/allmydata/test/check_speed.py b/src/allmydata/test/check_speed.py
new file mode 100644 (file)
index 0000000..c3e0d90
--- /dev/null
@@ -0,0 +1,74 @@
+#! /bin/env/python
+
+import os, sys
+from twisted.internet import reactor, defer
+from twisted.python import log
+from twisted.application import service
+from foolscap import Tub, eventual
+
+class SpeedTest:
+    def __init__(self, test_client_dir):
+        #self.real_stderr = sys.stderr
+        log.startLogging(open("st.log", "a"), setStdout=False)
+        f = open(os.path.join(test_client_dir, "control.furl"), "r")
+        self.control_furl = f.read().strip()
+        f.close()
+        self.base_service = service.MultiService()
+        self.failed = None
+
+    def run(self):
+        print "STARTING"
+        d = eventual.fireEventually()
+        d.addCallback(lambda res: self.setUp())
+        d.addCallback(lambda res: self.do_test())
+        d.addBoth(self.tearDown)
+        def _err(err):
+            self.failed = err
+            log.err(err)
+            print err
+        d.addErrback(_err)
+        def _done(res):
+            reactor.stop()
+            return res
+        d.addBoth(_done)
+        reactor.run()
+        if self.failed:
+            print "EXCEPTION"
+            print self.failed
+            sys.exit(1)
+
+    def setUp(self):
+        self.base_service.startService()
+        self.tub = Tub()
+        self.tub.setServiceParent(self.base_service)
+        d = self.tub.getReference(self.control_furl)
+        def _gotref(rref):
+            self.client_rref = rref
+            print "Got Client Control reference"
+            return self.stall(5)
+        d.addCallback(_gotref)
+        return d
+
+    def stall(self, delay, result=None):
+        d = defer.Deferred()
+        reactor.callLater(delay, d.callback, result)
+        return d
+
+    def do_test(self):
+        print "doing test"
+        d = self.client_rref.callRemote("get_memory_usage")
+        def _got(res):
+            print "MEMORY USAGE:", res
+        d.addCallback(_got)
+        return d
+
+    def tearDown(self, res):
+        d = self.base_service.stopService()
+        d.addCallback(lambda ignored: res)
+        return d
+
+
+if __name__ == '__main__':
+    test_client_dir = sys.argv[1]
+    st = SpeedTest(test_client_dir)
+    st.run()