correct rally criteria check 01/17801/2
authorSerenaFeng <feng.xiaowei@zte.com.cn>
Fri, 29 Jul 2016 09:07:44 +0000 (17:07 +0800)
committerSerena Feng <feng.xiaowei@zte.com.cn>
Fri, 29 Jul 2016 09:11:58 +0000 (09:11 +0000)
add method check_success_rate() to unify criteria check by success_rate

JIRA: FUNCTEST-398

Change-Id: I1b3f0ccd7061b80ac88356206f29844e31e4101b
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
testcases/OpenStack/rally/run_rally-cert.py
utils/functest_utils.py

index 2f696ec..2bb191f 100755 (executable)
@@ -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",
index a21ac44..b001430 100644 (file)
@@ -347,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