configuring with commands file, in progress

This commit is contained in:
Dmitry Shulyak
2013-06-25 18:50:58 +03:00
parent 80e172e0b0
commit f6b5952f86
6 changed files with 30 additions and 16 deletions

View File

@@ -24,10 +24,10 @@ class API(object):
def run(self, test_run_name, conf):
log.info('Looking for %s in %s' % (test_run_name, self._commands))
commands_keys = self._commands.get(test_run_name, {})
transport = get_transport(commands_keys['driver'])
command = self._commands.get(test_run_name, {})
transport = get_transport(command['driver'])
test_run = self._storage.add_test_run(test_run_name)
transport.run(test_run['id'], conf, **commands_keys)
transport.run(test_run['id'], conf, **command)
return test_run
def get_info(self, test_run_name, test_run_id):

View File

@@ -1,7 +1,14 @@
tempest:
test_path: /root/ostf/ostf-tests
fuel_smoke:
test_path: /root/anaboikina/ostf_tests/ostf/ostf-tests/fuel/tests
driver: nose
argv: smoke
fuel_sanity:
test_path: /root/slyopka-test-debug/ostf-tests/fuel/tests
driver: nose
argv: sanity
five_min:
test_path: /root/ostf-tests/fuel
driver: nose
argv: -A "type == ['sanity', 'smoke']"
tests:
test_path: /home/dshulyak/projects/ostf-tests
driver: nose

View File

@@ -59,7 +59,7 @@ class StoragePlugin(plugins.Plugin):
self.add_message(test, type='failure')
def addError(self, test, err, capt=None, tb_info=None):
log.info('ERROR for %s' % test)
log.info('ERROR for %s\n%s' % (test, err))
self.stats['errors'] += 1
self.add_message(test, type='error')
@@ -124,7 +124,10 @@ class NoseDriver(object):
def run(self, test_run, conf, **kwargs):
if 'config_path' in kwargs:
self.prepare_config(conf, kwargs['config_path'])
argv_add = [kwargs['argv']] if 'argv' in kwargs else []
argv_add = []
if 'argv' in kwargs:
argv_add = [kwargs['argv']]
log.info('Additional args: %s' % argv_add)
gev = g_pool.spawn(self._run_tests, test_run, kwargs['test_path'],
argv_add)
TESTS_PROCESS[test_run] = gev
@@ -144,10 +147,11 @@ class NoseDriver(object):
raise gevent.GreenletExit
def kill(self, test_run):
if test_run in TESTS_PROCESS:
log.info('Trying to stop process %s\n'
'%s' % (test_run, TESTS_PROCESS))
if int(test_run) in TESTS_PROCESS:
log.info('Kill green thread: %s' % test_run)
TESTS_PROCESS[test_run].kill()
del TESTS_PROCESS[test_run]
TESTS_PROCESS[int(test_run)].kill()
return True
return False

View File

@@ -3,7 +3,7 @@ from mock import patch, MagicMock
from core.api import API, parse_commands_file
TEST_RUN_NAME = 'tempest'
TEST_RUN_NAME = 'tests'
TEST_RUN_ID = 1
TEST_ID = 'simple.TestSimple'
CONF = {'config': True}
@@ -31,7 +31,7 @@ class TestApi(unittest.TestCase):
res = api.run(TEST_RUN_NAME, CONF)
self.storage.add_test_run.assert_called_once_with(TEST_RUN_NAME)
self.transport.run.assert_called_once_with(TEST_RUN_ID, CONF)
self.assertEqual(res, {'type': TEST_RUN_NAME, 'id':TEST_RUN_ID})
self.assertEqual(res, {'type': TEST_RUN_NAME, 'id': TEST_RUN_ID})
@patch('core.api.get_storage')
def test_get_info(self, get_storage_mock):
@@ -42,8 +42,8 @@ class TestApi(unittest.TestCase):
def test_parse_commands_file(self):
res = parse_commands_file()
expected = {'tempest': {
'argv': '-A "type == [\'sanity\', \'smoke\']"',
expected = {'fuel_smoke': {
'argv': '-A "type == ["fuel", "smoke"]"',
'driver': 'nose',
'test_path': '/root/ostf/ostf-tests'},
'tests': {'driver': 'nose',

View File

@@ -17,11 +17,13 @@ class TestNoseAdapters(unittest.TestCase):
self.nose_driver = nose_adapter.NoseDriver()
def test_get_nose_transport(self):
driver = get_transport('tempest')
driver = get_transport('nose')
self.assertIsInstance(driver, nose_adapter.NoseDriver)
@patch('core.transport.nose_adapter.io.open')
def test_create_tempest_conf(self, io_mock):
"""Test verified
"""
string_io = DummyStringIO()
io_mock.return_value = string_io
conf = {'param1': 'test',

View File

@@ -8,3 +8,4 @@ psycogreen
sqlalchemy
simplejson
alembic
pyyaml