summaryrefslogtreecommitdiffstats
path: root/scripts/run.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/run.py')
-rwxr-xr-xscripts/run.py36
1 files changed, 24 insertions, 12 deletions
diff --git a/scripts/run.py b/scripts/run.py
index 9b59f76f..2afdfc7e 100755
--- a/scripts/run.py
+++ b/scripts/run.py
@@ -15,13 +15,15 @@ import time
import utils.dovetail_logger as dt_logger
import utils.dovetail_utils as dt_utils
-logger = dt_logger.Logger('run.py').getLogger()
+
from container import Container
from testcase import *
from report import *
from conf.dovetail_config import *
+logger = dt_logger.Logger('run.py').getLogger()
+
def load_scenario(scenario):
Scenario.load()
return Scenario.get(SCENARIO_NAMING_FMT % scenario)
@@ -30,10 +32,8 @@ def load_testcase():
Testcase.load()
def run_functest(testcase, container_id):
- sub_cmd = dovetail_config[testcase.script_type()]['testcase']['pre_cmd']
- Container.exec_cmd(container_id, sub_cmd)
- sub_cmd = dovetail_config[testcase.script_type()]['testcase']['exec_cmd'] % testcase.script_testcase()
- Container.exec_cmd(container_id, sub_cmd)
+ for cmd in testcase.cmds:
+ Container.exec_cmd(container_id, cmd)
def run_yardstick(testcase, container_id):
type = testcase.script_type()
@@ -51,23 +51,35 @@ def run_test(scenario):
for testcase_name in scenario['testcase_list']:
logger.info('>>[testcase]: %s' % (testcase_name))
testcase = Testcase.get(testcase_name)
- run_test = True
+ run_testcase = True
if testcase.exceed_max_retry_times():
- run_test = False
+ run_testcase = False
if testcase.script_result_acquired():
- run_test = False
+ run_testcase = False
- if run_test:
+ if run_testcase:
Container.pull_image(testcase.script_type())
container_id = Container.create(testcase.script_type())
logger.debug('container id:%s' % container_id)
- if testcase.script_type() == 'functest':
- run_functest(testcase, container_id)
+ if not Testcase.prepared(testcase.script_type()):
+ cmds = Testcase.pre_condition(testcase.script_type())['cmds']
+ if cmds:
+ for cmd in cmds:
+ Container.exec_cmd(container_id, cmd)
+ Testcase.prepared(testcase.script_type(),True)
+
+ if not testcase.prepare_cmd():
+ logger.error('failed to prepare testcase:%s' % testcase.name())
else:
- run_yardstick(testcase, container_id)
+ if testcase.script_type() == 'functest':
+ run_functest(testcase, container_id)
+ else:
+ run_yardstick(testcase, container_id)
+
+ #testcase.post_condition()
Container.clean(container_id)