From: robk-tahoe Date: Fri, 3 Oct 2008 17:20:26 +0000 (-0700) Subject: fuse/runtests: added a --web-open option X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/css/flags/?a=commitdiff_plain;h=8b9a26792048c4505db7e439c973f01b020d2f95;p=tahoe-lafs%2Ftahoe-lafs.git fuse/runtests: added a --web-open option similar to the --debug-wait option which causes the test harness to pause at various stages of the process to facilitate debugging, this option simplifies that debugging by automatically opening a web browser to the root dir of that implementation's tests when tests are commenced. in addition, if --web-open is specfied but --debug-wait is not, the harness will still pause after running tests but before tearing down the tahoe grid - this allows all tests to run to completion, but provide a debugging hook to investigate the end state of the grid's contents thereafter. --- diff --git a/contrib/fuse/runtests.py b/contrib/fuse/runtests.py index 11482db8..059d0818 100644 --- a/contrib/fuse/runtests.py +++ b/contrib/fuse/runtests.py @@ -24,7 +24,7 @@ Unit and system tests for tahoe-fuse. # using the grid fs). import sys, os, shutil, unittest, subprocess -import tempfile, re, time, random, httplib +import tempfile, re, time, random, httplib, urllib from twisted.python import usage @@ -95,6 +95,8 @@ class FuseTestsOptions(usage.Options): optFlags = [ ["debug-wait", None, "Causes the test system to pause at various points, to facilitate debugging"], + ["web-open", None, + "Opens a web browser to the web ui at the start of each impl's tests"], ] def postOptions(self): @@ -181,11 +183,19 @@ class SystemTest (object): print sfail print '\n*** System Tests were not successfully completed.' - def maybe_wait(self, msg='waiting'): - if self.config['debug-wait']: + def maybe_wait(self, msg='waiting', or_if_webopen=False): + if self.config['debug-wait'] or or_if_webopen and self.config['web-open']: print msg raw_input() + def maybe_webopen(self, where=None): + if self.config['web-open']: + import webbrowser + url = self.weburl + if where is not None: + url += urllib.quote(where) + webbrowser.open(url) + def init_cli_layer(self): '''This layer finds the appropriate tahoe executable.''' #self.cliexec = os.path.join('.', 'bin', 'tahoe') @@ -243,7 +253,7 @@ class SystemTest (object): if clientnum >= self.TotalClientsNeeded: self.maybe_wait('waiting (launched clients)') ret = self.create_test_dirnode_layer() - self.maybe_wait('waiting (ran tests)') + self.maybe_wait('waiting (ran tests)', or_if_webopen=True) return ret tmpl = 'Launching client %d of %d.' @@ -264,7 +274,8 @@ class SystemTest (object): f = open(webportpath, 'w') f.write('tcp:%d:interface=127.0.0.1\n' % self.port) f.close() - print "http://127.0.0.1:%d/" % (self.port,) + self.weburl = "http://127.0.0.1:%d/" % (self.port,) + print self.weburl else: os.remove(webportpath) @@ -324,6 +335,7 @@ class SystemTest (object): return results def run_test_layer(self, root_uri, iman): + self.maybe_webopen('uri/'+root_uri) failures = 0 testnum = 0 numtests = 0