diff options
Diffstat (limited to 'utils/functest_utils.py')
-rw-r--r-- | utils/functest_utils.py | 40 |
1 files changed, 40 insertions, 0 deletions
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 |