From: Brian Warner Date: Thu, 20 Sep 2007 01:27:47 +0000 (-0700) Subject: started framework for an automated speed-checking tool. Doesn't do much yet. X-Git-Tag: allmydata-tahoe-0.6.0~52 X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/reliability?a=commitdiff_plain;h=f6be35e122fa1099fca2a68a3831dac6c631b585;p=tahoe-lafs%2Ftahoe-lafs.git started framework for an automated speed-checking tool. Doesn't do much yet. --- diff --git a/Makefile b/Makefile index 1ab835ba..3365027f 100644 --- 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 index 00000000..c3e0d905 --- /dev/null +++ b/src/allmydata/test/check_speed.py @@ -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()