killing test runs

This commit is contained in:
Dmitry Shulyak
2013-06-14 15:11:13 +03:00
parent a91499e943
commit 990b81eaae
3 changed files with 20 additions and 5 deletions

View File

@@ -20,6 +20,11 @@ class API(object):
return self._storage.get_test_results(stored_id)
return self._storage.get_test_result(stored_id, test_id, meta=meta)
def kill(self, test_run, test_run_id):
transport = get_transport(test_run)
stored_id = '{}:{}'.format(test_run, test_run_id)
return transport.kill(stored_id)
def flush_storage(self):
self._storage.flush_db()

View File

@@ -20,6 +20,9 @@ nose_opts = [
cfg.CONF.register_opts(nose_opts)
TESTS_PROCESS = {}
class RedisPlugin(plugins.Plugin):
enabled = True
@@ -33,7 +36,7 @@ class RedisPlugin(plugins.Plugin):
super(RedisPlugin, self).__init__()
self._current_stderr = None
self._current_stdout = None
self._start_capture()
# self._start_capture()
def options(self, parser, env=os.environ):
pass
@@ -55,7 +58,6 @@ class RedisPlugin(plugins.Plugin):
self.stats['passes'] += 1
self.add_message(test, type='success')
def addFailure(self, test, err, capt=None, tb_info=None):
self.stats['failures'] += 1
self.add_message(test, type='failure')
@@ -121,7 +123,7 @@ class NoseDriver(object):
def run(self, test_run, conf):
gev = gevent.spawn(self._run_tests, test_run, [conf['working_directory']])
gev.join()
TESTS_PROCESS[test_run] = gev
def _run_tests(self, test_run, argv_add):
try:
@@ -130,7 +132,15 @@ class NoseDriver(object):
exit=True,
argv=[test_run]+argv_add)
finally:
# del TESTS_PROCESS[test_run]
raise gevent.GreenletExit
def kill(self, test_run):
if test_run in TESTS_PROCESS:
TESTS_PROCESS[test_run].kill()
del TESTS_PROCESS[test_run]

View File

@@ -17,6 +17,6 @@ class V1Controller(rest.RestController):
return request.api.get_info(test_run, test_run_id, test_id, stats)
@expose('json')
def delete(self):
request.api.flush_storage()
def delete(self, test_run, test_run_id=0):
request.api.kill(test_run, test_run_id)
return {}