summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhongbo tian <hongbo.tianhongbo@huawei.com>2016-12-14 09:24:15 +0000
committerGerrit Code Review <gerrit@opnfv.org>2016-12-14 09:24:15 +0000
commit5809de2a438fcffb57d2b675e36ce1cbc0ea90f7 (patch)
tree6bbd744ae853e42302fb005ad69bfdf653b753d5
parent089e13505950e852d973c969b8bc81160818d9d2 (diff)
parente5be1b8b5c5e2714ad4a558da2aa3727a70ef516 (diff)
Merge "[dovetail tool] support shell scripts for testcase validation"
-rw-r--r--dovetail/conf/functest_config.yml2
-rw-r--r--dovetail/container.py2
-rw-r--r--dovetail/test_runner.py2
-rw-r--r--dovetail/testcase.py18
4 files changed, 16 insertions, 8 deletions
diff --git a/dovetail/conf/functest_config.yml b/dovetail/conf/functest_config.yml
index 72cdb0dd..682d19bf 100644
--- a/dovetail/conf/functest_config.yml
+++ b/dovetail/conf/functest_config.yml
@@ -11,7 +11,7 @@ functest:
- 'functest env prepare'
- 'functest testcase run {{validate_testcase}}'
post_condition:
- - ''
+ - 'echo test for postcondition'
result:
dir: '/home/opnfv/functest/results'
store_type: 'file'
diff --git a/dovetail/container.py b/dovetail/container.py
index af05dcd5..87174727 100644
--- a/dovetail/container.py
+++ b/dovetail/container.py
@@ -77,5 +77,7 @@ class Container:
@classmethod
def exec_cmd(cls, container_id, sub_cmd, exit_on_error=False):
+ if sub_cmd == "":
+ return
cmd = 'sudo docker exec %s /bin/bash -c "%s"' % (container_id, sub_cmd)
dt_utils.exec_cmd(cmd, cls.logger, exit_on_error)
diff --git a/dovetail/test_runner.py b/dovetail/test_runner.py
index bc0e4679..8a95b1f7 100644
--- a/dovetail/test_runner.py
+++ b/dovetail/test_runner.py
@@ -38,7 +38,7 @@ class DockerRunner(object):
if not self.testcase.prepare_cmd():
self.logger.error('failed to prepare testcase:%s',
- self.testcase.name())
+ self.testcase.name)
else:
for cmd in self.testcase.cmds:
Container.exec_cmd(container_id, cmd)
diff --git a/dovetail/testcase.py b/dovetail/testcase.py
index af8b325e..6f2d76de 100644
--- a/dovetail/testcase.py
+++ b/dovetail/testcase.py
@@ -23,7 +23,6 @@ class Testcase(object):
def __init__(self, testcase_yaml):
self.testcase = testcase_yaml.values()[0]
- # self.logger.debug('testcase:%s', self.testcase)
self.testcase['passed'] = False
self.cmds = []
self.sub_testcase_status = {}
@@ -35,8 +34,17 @@ class Testcase(object):
def prepare_cmd(self):
try:
- self.cmds = self.testcase['validate']['cmds']
- return True
+ for cmd in self.testcase['validate']['cmds']:
+ cmd_lines = Parser.parse_cmd(cmd, self)
+ if not cmd_lines:
+ return False
+ # self.logger.debug('cmd_lines:%s', cmd_lines)
+ self.cmds.append(cmd_lines)
+ self.logger.debug('cmds:%s', self.cmds)
+ if len(self.cmds) > 0:
+ return True
+ else:
+ return False
except KeyError:
return False
@@ -182,8 +190,6 @@ class FunctestTestcase(Testcase):
def prepare_cmd(self):
ret = super(FunctestTestcase, self).prepare_cmd()
if not ret:
- return False
- else:
for cmd in \
dt_cfg.dovetail_config[self.name]['cmds']:
cmd_lines = Parser.parse_cmd(cmd, self)
@@ -191,7 +197,7 @@ class FunctestTestcase(Testcase):
return False
self.logger.debug('cmd_lines:%s', cmd_lines)
self.cmds.append(cmd_lines)
- return True
+ return True
class YardstickTestcase(Testcase):