mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-29 15:43:54 +00:00
started framework for an automated speed-checking tool. Doesn't do much yet.
This commit is contained in:
parent
c89a18f659
commit
f6be35e122
10
Makefile
10
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)
|
||||
|
74
src/allmydata/test/check_speed.py
Normal file
74
src/allmydata/test/check_speed.py
Normal file
@ -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()
|
Loading…
x
Reference in New Issue
Block a user