summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dovetail/compliance/debug.yml8
-rw-r--r--dovetail/conf/dovetail_config.yml5
-rw-r--r--dovetail/conf/functest_config.yml1
-rw-r--r--dovetail/container.py10
-rw-r--r--dovetail/report.py57
-rwxr-xr-xdovetail/run.py38
-rw-r--r--dovetail/test_runner.py7
-rw-r--r--dovetail/testcase.py11
-rw-r--r--dovetail/testcase/defcore.tc001.yml2
-rw-r--r--dovetail/utils/dovetail_utils.py16
10 files changed, 97 insertions, 58 deletions
diff --git a/dovetail/compliance/debug.yml b/dovetail/compliance/debug.yml
index 847251bd..c48d6b65 100644
--- a/dovetail/compliance/debug.yml
+++ b/dovetail/compliance/debug.yml
@@ -7,10 +7,10 @@ debug:
testcases_list:
- dovetail.example.tc002
- dovetail.defcore.tc001
- - dovetail.ipv6.tc008
- - dovetail.ipv6.tc009
- - dovetail.ipv6.tc018
- - dovetail.ipv6.tc019
+# - dovetail.ipv6.tc008
+# - dovetail.ipv6.tc009
+# - dovetail.ipv6.tc018
+# - dovetail.ipv6.tc019
- dovetail.nfvi.tc001
- dovetail.nfvi.tc002
- dovetail.nfvi.tc101
diff --git a/dovetail/conf/dovetail_config.yml b/dovetail/conf/dovetail_config.yml
index b8174bdb..56a5482a 100644
--- a/dovetail/conf/dovetail_config.yml
+++ b/dovetail/conf/dovetail_config.yml
@@ -1,5 +1,4 @@
---
-result_dir: /home/opnfv/dovetail/results
report_file: 'dovetail_report.txt'
cli_file_name: 'cmd_config.yml'
report_dest: 'file'
@@ -7,10 +6,6 @@ report_dest: 'file'
# OPENSTACK Credential file
openrc: '/home/opnfv/dovetail/openrc.sh'
-repo:
- tag: tag_name
- path: https://github.com/opnfv/dovetail/tree/
-
COMPLIANCE_PATH: compliance/
TESTCASE_PATH: testcase/
# testsuite supported, should adjust accordingly
diff --git a/dovetail/conf/functest_config.yml b/dovetail/conf/functest_config.yml
index c65504e2..f636c204 100644
--- a/dovetail/conf/functest_config.yml
+++ b/dovetail/conf/functest_config.yml
@@ -14,5 +14,4 @@ functest:
dir: '/home/opnfv/functest/results'
store_type: 'file'
file_path: 'dump.txt'
- tp_path: 'tempest/tempest.log'
openrc: '/home/opnfv/functest/conf/openstack.creds'
diff --git a/dovetail/container.py b/dovetail/container.py
index 583f2e0c..4dd3b8f3 100644
--- a/dovetail/container.py
+++ b/dovetail/container.py
@@ -217,9 +217,9 @@ class Container(object):
return dt_utils.exec_cmd(cmd, cls.logger, exit_on_error)
@classmethod
- def pre_copy(cls, container_id, src_path, dest_path, exit_on_error=False):
- if src_path == "" or dest_path == "":
+ def pre_copy(cls, container_id, src_path, dest_path,
+ exit_on_error=False):
+ if not src_path or not dest_path:
return (1, 'src_path or dest_path is empty')
- cmd = 'sudo docker cp %s %s:%s' % (src_path, container_id, dest_path)
- cls.logger.debug('execute cmd %s', cmd)
- return dt_utils.exec_cmd(cmd, cls.logger, exit_on_error)
+ cmd = 'cp %s %s' % (src_path, dest_path)
+ return cls.exec_cmd(container_id, cmd, exit_on_error)
diff --git a/dovetail/report.py b/dovetail/report.py
index deabbdd2..6c45e00c 100644
--- a/dovetail/report.py
+++ b/dovetail/report.py
@@ -245,42 +245,39 @@ class FunctestCrawler(object):
'details': {"timestart": timestart,
"duration": testcase_duration,
"tests": '', "failures": ''}}
- elif 'tempest' in testcase_name:
+ elif testcase_name in dt_cfg.dovetail_config['functest_testsuite']:
file_path = \
os.path.join(dovetail_config['result_dir'],
- dovetail_config[self.type]['result']['tp_path'])
+ dovetail_config[self.type]['result']['file_path'])
if not os.path.exists(file_path):
self.logger.info('result file not found: %s', file_path)
return None
- with open(file_path, 'r') as myfile:
- output = myfile.read()
-
- match = re.findall('(.*?)[. ]*fail ', output)
- if match:
- error_logs = " ".join(match)
- else:
- error_logs = ""
- match = re.findall('(.*?)[. ]*skip:', output)
- if match:
- skipped = " ".join(match)
- else:
- skipped = ""
+ tests = 0
+ failed_num = 0
+ error_case = ''
+ skipped_case = ''
+ with open(file_path, 'r') as f:
+ for jsonfile in f:
+ try:
+ data = json.loads(jsonfile)
+ if testcase_name == data['case_name']:
+ criteria = data['details']['status']
+ timestart = data['details']['timestart']
+ testcase_duration = data['details']['duration']
+ tests = data['details']['tests']
+ failed_num = data['details']['failures']
+ error_case = data['details']['errors']
+ skipped_case = data['details']['skipped']
+ except Exception:
+ continue
- match = re.findall(' - Failures: (\d*)', output)
- if match:
- failed_num = int(match[0])
- else:
- failed_num = 0
- if failed_num == 0:
- criteria = 'PASS'
-
- match = re.findall('Ran: (\d*) tests in (\d*)\.\d* sec.', output)
- num_tests, dur_sec_int = match[0]
- json_results = {'criteria': criteria, 'details': {"timestart": '',
- "duration": int(dur_sec_int),
- "tests": int(num_tests), "failures": failed_num,
- "errors": error_logs,
- "skipped": skipped}}
+ json_results = {'criteria': criteria,
+ 'details': {"timestart": timestart,
+ "duration": testcase_duration,
+ "tests": tests,
+ "failures": failed_num,
+ "errors": error_case,
+ "skipped": skipped_case}}
self.logger.debug('Results: %s', str(json_results))
return json_results
diff --git a/dovetail/run.py b/dovetail/run.py
index 828a2b70..aae35e12 100755
--- a/dovetail/run.py
+++ b/dovetail/run.py
@@ -44,6 +44,7 @@ def run_test(testsuite, testarea, logger):
testarea_list.append(value)
duration = 0
+ start_time = time.time()
for testcase_name in testarea_list:
logger.info('>>[testcase]: %s', testcase_name)
testcase = Testcase.get(testcase_name)
@@ -60,21 +61,33 @@ def run_test(testsuite, testarea, logger):
run_testcase = False
if run_testcase:
- start_time = time.time()
testcase.run()
- end_time = time.time()
- duration = end_time - start_time
- if dt_cfg.dovetail_config['report_dest'].startswith("http"):
- logger.info("Results has been pushed to database.")
- if dt_cfg.dovetail_config['report_dest'] == "file":
- logger.info("Results has been stored with files.")
- result = Report.get_result(testcase)
- Report.check_result(testcase, result)
+ check_tc_result(testcase, logger)
+ end_time = time.time()
+ duration = end_time - start_time
return duration
+def check_tc_result(testcase, logger):
+ if dt_cfg.dovetail_config['report_dest'].startswith("http"):
+ if testcase.validate_type() == 'yardstick':
+ logger.info("Results have been stored with files.")
+ else:
+ if dt_utils.check_db_results(dt_cfg.dovetail_config['report_dest'],
+ dt_cfg.dovetail_config['build_tag'],
+ testcase.validate_testcase(),
+ logger):
+ logger.info("Results have been pushed to database.")
+ else:
+ logger.error("Fail to push results to database.")
+ if dt_cfg.dovetail_config['report_dest'] == "file":
+ logger.info("Results have been stored with files.")
+ result = Report.get_result(testcase)
+ Report.check_result(testcase, result)
+
+
def validate_input(input_dict, check_dict, logger):
# for 'func_tag' and 'yard_tag' options
func_tag = input_dict['func_tag']
@@ -153,10 +166,17 @@ def clean_results_dir():
raise SystemExit(1)
+def get_result_path():
+ dovetail_home = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+ result_path = os.path.join(dovetail_home, 'results')
+ dt_cfg.dovetail_config['result_dir'] = result_path
+
+
def main(*args, **kwargs):
"""Dovetail compliance test entry!"""
build_tag = "daily-master-%s" % str(uuid.uuid4())
dt_cfg.dovetail_config['build_tag'] = build_tag
+ get_result_path()
clean_results_dir()
if kwargs['debug']:
os.environ['DEBUG'] = 'true'
diff --git a/dovetail/test_runner.py b/dovetail/test_runner.py
index 32a18743..2c1b7fd6 100644
--- a/dovetail/test_runner.py
+++ b/dovetail/test_runner.py
@@ -48,9 +48,10 @@ class DockerRunner(object):
dest_path = self.testcase.pre_copy_dest_path()
if dest_path:
- src_path = self.testcase.mk_src_file()
- ret, msg = Container.pre_copy(container_id, src_path, dest_path)
-
+ self.testcase.mk_src_file()
+ src_path = self.testcase.pre_copy_src_path(self.type)
+ ret, msg = Container.pre_copy(container_id, src_path,
+ dest_path)
if not self.testcase.prepared():
prepare_failed = False
cmds = self.testcase.pre_condition()
diff --git a/dovetail/testcase.py b/dovetail/testcase.py
index 7f218c47..21d655ef 100644
--- a/dovetail/testcase.py
+++ b/dovetail/testcase.py
@@ -115,6 +115,17 @@ class Testcase(object):
self.name())
return pre_condition
+ def pre_copy_src_path(self, test_type):
+ try:
+ pre_copy_src_file = \
+ self.testcase['validate']['pre_copy']['src_file']
+ result_dir = dt_cfg.dovetail_config[test_type]['result']['dir']
+ except KeyError as e:
+ self.logger.error('src file Key error %s', e)
+ return None
+ src_path = os.path.join(result_dir, pre_copy_src_file)
+ return src_path
+
def pre_copy_dest_path(self):
try:
pre_copy_dest_path = \
diff --git a/dovetail/testcase/defcore.tc001.yml b/dovetail/testcase/defcore.tc001.yml
index bbd2c313..39be7471 100644
--- a/dovetail/testcase/defcore.tc001.yml
+++ b/dovetail/testcase/defcore.tc001.yml
@@ -12,7 +12,7 @@ dovetail.defcore.tc001:
- 'echo test for precondition in testcase'
pre_copy:
src_file: defcore.txt
- dest_path: /home/opnfv/repos/functest/functest/opnfv_tests/openstack/refstack_client
+ dest_path: /home/opnfv/repos/functest/functest/opnfv_tests/openstack/refstack_client/defcore.txt
cmds:
- 'functest env prepare'
- 'functest testcase run refstack_defcore -r'
diff --git a/dovetail/utils/dovetail_utils.py b/dovetail/utils/dovetail_utils.py
index 32d334e8..e72a37ca 100644
--- a/dovetail/utils/dovetail_utils.py
+++ b/dovetail/utils/dovetail_utils.py
@@ -14,6 +14,8 @@ import os
import re
import subprocess
from collections import Mapping, Set, Sequence
+import json
+import urllib2
def exec_log(verbose, logger, msg, level, flush=False):
@@ -123,6 +125,20 @@ def get_ext_net_name(env_file, logger=None):
return None
+def check_db_results(db_url, build_tag, testcase, logger):
+ url = "%s/results?build_tag=%s&case=%s" % (db_url, build_tag, testcase)
+ logger.debug("Query to rest api: %s", url)
+ try:
+ data = json.load(urllib2.urlopen(url))
+ if data['results']:
+ return True
+ else:
+ return False
+ except Exception as e:
+ logger.error("Cannot read content from %s, exception: %s", url, e)
+ return False
+
+
def show_progress_bar(length):
max_len = 50
length %= max_len