summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtestcases/OpenStack/rally/run_rally-cert.py15
-rw-r--r--testcases/vnf/RNC/parser.py27
-rw-r--r--utils/functest_utils.py40
3 files changed, 53 insertions, 29 deletions
diff --git a/testcases/OpenStack/rally/run_rally-cert.py b/testcases/OpenStack/rally/run_rally-cert.py
index 2f696ec30..2bb191fad 100755
--- a/testcases/OpenStack/rally/run_rally-cert.py
+++ b/testcases/OpenStack/rally/run_rally-cert.py
@@ -504,23 +504,14 @@ def main():
'nb tests': total_nb_tests,
'nb success': success_rate}})
- # Generate json results for DB
- # json_results = {"timestart": time_start, "duration": total_duration,
- # "tests": int(total_nb_tests),
- # "success": int(total_success)}
- # logger.info("Results: "+str(json_results))
-
- # Evaluation of the success criteria
- status = "FAIL"
- # for Rally we decided that the overall success rate must be above 90%
- if float(success_rate) >= 90:
- status = "PASS"
-
if args.sanity:
case_name = "rally_sanity"
else:
case_name = "rally_full"
+ # Evaluation of the success criteria
+ status = functest_utils.check_success_rate(case_name, success_rate)
+
if args.report:
logger.debug("Pushing Rally summary into DB...")
functest_utils.push_results_to_db("functest",
diff --git a/testcases/vnf/RNC/parser.py b/testcases/vnf/RNC/parser.py
index 7def5bf82..485af0e14 100644
--- a/testcases/vnf/RNC/parser.py
+++ b/testcases/vnf/RNC/parser.py
@@ -27,13 +27,14 @@ with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
dirs = functest_yaml.get('general').get('directories')
FUNCTEST_REPO = dirs.get('dir_repo_functest')
PARSER_REPO = dirs.get('dir_repo_parser')
-TEST_DB_URL = functest_yaml.get('results').get('test_db_url')
logger = ft_logger.Logger("parser").getLogger()
def main():
EXIT_CODE = -1
+ project = 'parser'
+ case_name = 'parser-basics'
cmd = 'cd %s/tests && ./functest_run.sh' % PARSER_REPO
start_time = time.time()
@@ -54,27 +55,19 @@ def main():
'duration': duration,
'status': test_status,
}
- pod_name = functest_utils.get_pod_name(logger)
- scenario = functest_utils.get_scenario(logger)
- version = functest_utils.get_version(logger)
- build_tag = functest_utils.get_build_tag(logger)
status = "FAIL"
if details['status'] == "OK":
status = "PASS"
- logger.info("Pushing Parser results: TEST_DB_URL=%(db)s pod_name=%(pod)s "
- "version=%(v)s scenario=%(s)s criteria=%(c)s details=%(d)s" % {
- 'db': TEST_DB_URL,
- 'pod': pod_name,
- 'v': version,
- 's': scenario,
- 'c': status,
- 'b': build_tag,
- 'd': details,
- })
- functest_utils.push_results_to_db("parser",
- "parser-basics",
+ functest_utils.logger_test_results(logger,
+ project,
+ case_name,
+ status,
+ details)
+
+ functest_utils.push_results_to_db(project,
+ case_name,
logger,
start_time,
stop_time,
diff --git a/utils/functest_utils.py b/utils/functest_utils.py
index b46dc7dda..b0014308e 100644
--- a/utils/functest_utils.py
+++ b/utils/functest_utils.py
@@ -163,6 +163,27 @@ def get_db_url(logger=None):
return db_url
+def logger_test_results(logger, project, case_name, status, details):
+ pod_name = get_pod_name(logger)
+ scenario = get_scenario(logger)
+ version = get_version(logger)
+ build_tag = get_build_tag(logger)
+
+ logger.info("Pushing %(p)s/%(n)s results: TEST_DB_URL=%(db)s "
+ "pod_name=%(pod)s version=%(v)s scenario=%(s)s "
+ "criteria=%(c)s details=%(d)s" % {
+ 'p': project,
+ 'n': case_name,
+ 'db': get_db_url(),
+ 'pod': pod_name,
+ 'v': version,
+ 's': scenario,
+ 'c': status,
+ 'b': build_tag,
+ 'd': details,
+ })
+
+
def push_results_to_db(project, case_name, logger,
start_date, stop_date, criteria, details):
"""
@@ -326,3 +347,22 @@ def get_parameter_from_yaml(parameter, file=None):
raise ValueError("The parameter %s is not defined in"
" config_functest.yaml" % parameter)
return value
+
+
+def check_success_rate(case_name, success_rate):
+ success_rate = float(success_rate)
+ criteria = get_criteria_by_test(case_name)
+
+ def get_value(op):
+ return float(criteria.split(op)[1].rstrip('%'))
+
+ status = 'FAIL'
+ ops = ['==', '>=']
+ for op in ops:
+ if op in criteria:
+ c_value = get_value(op)
+ if eval("%s %s %s" % (success_rate, op, c_value)):
+ status = 'PASS'
+ break
+
+ return status