check_memory.py: record initial memory usage (before any connections are made)

This commit is contained in:
Brian Warner 2007-09-20 12:36:27 -07:00
parent d0c2153c34
commit 77fae0b338
1 changed files with 21 additions and 6 deletions

View File

@ -83,6 +83,9 @@ class SystemFramework(testutil.PollMixin):
#log.startLoggingWithObserver(flo.emit, setStdout=False) #log.startLoggingWithObserver(flo.emit, setStdout=False)
d = eventual.fireEventually() d = eventual.fireEventually()
d.addCallback(lambda res: self.setUp()) d.addCallback(lambda res: self.setUp())
d.addCallback(lambda res: self.record_initial_memusage())
d.addCallback(lambda res: self.make_nodes())
d.addCallback(lambda res: self.wait_for_client_connected())
d.addCallback(lambda res: self.do_test()) d.addCallback(lambda res: self.do_test())
d.addBoth(self.tearDown) d.addBoth(self.tearDown)
def _err(err): def _err(err):
@ -104,7 +107,6 @@ class SystemFramework(testutil.PollMixin):
self.statsfile = open(os.path.join(self.basedir, "stats.out"), "a") self.statsfile = open(os.path.join(self.basedir, "stats.out"), "a")
d = self.make_introducer_and_vdrive() d = self.make_introducer_and_vdrive()
def _more(res): def _more(res):
self.make_nodes()
return self.start_client() return self.start_client()
d.addCallback(_more) d.addCallback(_more)
def _record_control_furl(control_furl): def _record_control_furl(control_furl):
@ -114,8 +116,6 @@ class SystemFramework(testutil.PollMixin):
d.addCallback(_record_control_furl) d.addCallback(_record_control_furl)
def _record_control(control_rref): def _record_control(control_rref):
self.control_rref = control_rref self.control_rref = control_rref
return control_rref.callRemote("wait_for_client_connections",
self.numnodes+1)
d.addCallback(_record_control) d.addCallback(_record_control)
def _ready(res): def _ready(res):
#print "CLIENT READY" #print "CLIENT READY"
@ -123,6 +123,19 @@ class SystemFramework(testutil.PollMixin):
d.addCallback(_ready) d.addCallback(_ready)
return d return d
def record_initial_memusage(self):
print
print "Client started (no connections yet)"
d = self._print_usage()
d.addCallback(self.stash_stats, "init")
return d
def wait_for_client_connected(self):
print
print "Client connecting to other nodes.."
return self.control_rref.callRemote("wait_for_client_connections",
self.numnodes+1)
def tearDown(self, passthrough): def tearDown(self, passthrough):
# the client node will shut down in a few seconds # the client node will shut down in a few seconds
#os.remove(os.path.join(self.clientdir, "suicide_prevention_hotline")) #os.remove(os.path.join(self.clientdir, "suicide_prevention_hotline"))
@ -148,12 +161,14 @@ class SystemFramework(testutil.PollMixin):
iv = introducer_and_vdrive.IntroducerAndVdrive(basedir=iv_basedir) iv = introducer_and_vdrive.IntroducerAndVdrive(basedir=iv_basedir)
self.introducer_and_vdrive = self.add_service(iv) self.introducer_and_vdrive = self.add_service(iv)
d = self.introducer_and_vdrive.when_tub_ready() d = self.introducer_and_vdrive.when_tub_ready()
return d def _introducer_ready(res):
def make_nodes(self):
q = self.introducer_and_vdrive q = self.introducer_and_vdrive
self.introducer_furl = q.urls["introducer"] self.introducer_furl = q.urls["introducer"]
self.vdrive_furl = q.urls["vdrive"] self.vdrive_furl = q.urls["vdrive"]
d.addCallback(_introducer_ready)
return d
def make_nodes(self):
self.nodes = [] self.nodes = []
for i in range(self.numnodes): for i in range(self.numnodes):
nodedir = os.path.join(self.testdir, "node%d" % i) nodedir = os.path.join(self.testdir, "node%d" % i)