Merge "jjb: xci: bifrost: Clone git repositories to $WORKSPACE"
[releng.git] / utils / test / reporting / storperf / reporting-status.py
index 674fdd8..888e339 100644 (file)
@@ -63,15 +63,23 @@ for version in versions:
 
             logger.info("ten_score: %s / %s" % (ten_score, ten_criteria))
 
-            LASTEST_TESTS = rp_utils.get_config(
-                 'general.nb_iteration_tests_success_criteria')
-            four_result = s_result[:LASTEST_TESTS]
-            four_criteria = len(four_result)
             four_score = 0
-            for v in four_result:
-                if "PASS" in v['criteria']:
-                    four_score += 1
-            logger.info("four_score: %s / %s " % (four_score, four_criteria))
+            try:
+                LASTEST_TESTS = rp_utils.get_config(
+                    'general.nb_iteration_tests_success_criteria')
+                s_result.sort(key=lambda x: x['start_date'])
+                four_result = s_result[-LASTEST_TESTS:]
+                logger.debug("four_result: {}".format(four_result))
+                logger.debug("LASTEST_TESTS: {}".format(LASTEST_TESTS))
+                # logger.debug("four_result: {}".format(four_result))
+                four_criteria = len(four_result)
+                for v in four_result:
+                    if "PASS" in v['criteria']:
+                        four_score += 1
+                logger.info("4 Score: %s / %s " % (four_score,
+                                                   four_criteria))
+            except:
+                logger.error("Impossible to retrieve the four_score")
 
             try:
                 s_status = (four_score * 100) / four_criteria
@@ -82,12 +90,20 @@ for version in versions:
             s_ten_score = str(ten_score) + '/' + str(ten_criteria)
             s_score_percent = str(s_status)
 
-            if '100' == s_status:
+            logger.debug(" s_status: {}".format(s_status))
+            if s_status == 100:
                 logger.info(">>>>> scenario OK, save the information")
             else:
                 logger.info(">>>> scenario not OK, last 4 iterations = %s, \
                              last 10 days = %s" % (s_four_score, s_ten_score))
 
+            s_url = ""
+            if len(s_result) > 0:
+                build_tag = s_result[len(s_result)-1]['build_tag']
+                logger.debug("Build tag: %s" % build_tag)
+                s_url = s_url = rp_utils.getJenkinsUrl(build_tag)
+                logger.info("last jenkins url: %s" % s_url)
+
             # Save daily results in a file
             path_validation_file = ("./display/" + version +
                                     "/storperf/scenario_history.txt")
@@ -106,7 +122,8 @@ for version in versions:
             scenario_result_criteria[s] = sr.ScenarioResult(s_status,
                                                             s_four_score,
                                                             s_ten_score,
-                                                            s_score_percent)
+                                                            s_score_percent,
+                                                            s_url)
 
             logger.info("--------------------------")