logger.info("* *")
logger.info("*******************************************")
+
# For all the versions
for version in conf.versions:
# For all the installers
if not scenario_results.has_key(k):
scenario_results[k] = []
scenario_results[k] += stable_result[k]
- for k,v in scenario_results.items():
- scenario_results[k] = v[0:conf.LASTEST_TESTS]
scenario_result_criteria = {}
# From each scenarios get results list
logger.info("---------------------------------")
logger.info("installer %s, version %s, scenario %s:" % (installer, version, s))
- s_status = 'KO'
- scenario_criteria = len(s_result)
- scenario_score = 0
-
+ ten_criteria = len(s_result)
+ ten_score = 0
for v in s_result:
- if v['criteria'] == 'SUCCESS':
- scenario_score += 1
+ ten_score += v
- if scenario_score == scenario_criteria and scenario_criteria == 4:
- s_status = 'OK'
- logger.info(">>>>> scenario OK, save the information")
- else:
- logger.info(">>>> scenario not OK, score = %s/%s" % (scenario_score, scenario_criteria))
+ four_result = s_result[:conf.LASTEST_TESTS]
+ four_criteria = len(four_result)
+ four_score = 0
+ for v in four_result:
+ four_score += v
- s_score = str(scenario_score) + '/' + str(scenario_criteria)
- scenario_result_criteria[s] = sr.ScenarioResult(s_status, s_score)
+ s_status = str(utils.get_status(four_result, s_result))
+ s_four_score = str(four_score) + '/' + str(four_criteria)
+ s_ten_score = str(ten_score) + '/' + str(ten_criteria)
+ scenario_result_criteria[s] = sr.ScenarioResult(s_status, s_four_score, s_ten_score)
+ if '100' == s_status:
+ 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))
logger.info("--------------------------")
templateLoader = jinja2.FileSystemLoader(conf.REPORTING_PATH)
versions = ["master", "colorado"]
-# get data in the past 7 days
-PERIOD = 7
+# get data in the past 10 days
+PERIOD = 10
# get the lastest 4 test results to determinate the success criteria
LASTEST_TESTS = 4
print 'Got an error code:', e
scenario_results = {}
+ result_dict = {}
if test_results is not None:
for r in test_results:
- if r['stop_date'] != 'None':
+ if r['stop_date'] != 'None' and r['criteria'] is not None:
if not r['scenario'] in scenario_results.keys():
scenario_results[r['scenario']] = []
scenario_results[r['scenario']].append(r)
for k,v in scenario_results.items():
- scenario_results[k] = v[:conf.LASTEST_TESTS]
+ # scenario_results[k] = v[:conf.LASTEST_TESTS]
+ s_list = []
+ for element in v:
+ if element['criteria'] == 'SUCCESS':
+ s_list.append(1)
+ else:
+ s_list.append(0)
+ result_dict[k] = s_list
- return scenario_results
+ # return scenario_results
+ return result_dict
+
+def subfind(given_list, pattern_list):
+ for i in range(len(given_list)):
+ if given_list[i] == pattern_list[0] and given_list[i:i + conf.LASTEST_TESTS] == pattern_list:
+ return True
+ return False
+
+def get_percent(status):
+
+ if status * 100 % 6:
+ return round(float(status) * 100 / 6, 1)
+ else:
+ return status * 100 / 6
+
+def get_status(four_list, ten_list):
+ four_score = 0
+ ten_score = 0
+
+ for v in four_list:
+ four_score += v
+ for v in ten_list:
+ ten_score += v
+
+ if four_score == conf.LASTEST_TESTS:
+ status = 6
+ elif subfind(ten_list, [1, 1, 1, 1]):
+ status = 5
+ elif ten_score == 0:
+ status = 0
+ else:
+ status = four_score + 1
+
+ return get_percent(status)
def _test():
class ScenarioResult(object):
- def __init__(self, status, score=0):
+ def __init__(self, status, four_days_score='', ten_days_score=''):
self.status = status
- self.score = score
+ self.four_days_score = four_days_score
+ self.ten_days_score = ten_days_score
def getStatus(self):
return self.status
- def getScore(self):
- return self.score
+ def getTenDaysScore(self):
+ return self.ten_days_score
+
+ def getFourDaysScore(self):
+ return self.four_days_score
<div class="panel-heading"><h4><b>List of last scenarios ({{version}}) run over the last {{period}} days </b></h4></div>
<table class="table">
<tr>
- <th width="60%">Scenario</th>
+ <th width="40%">Scenario</th>
<th width="20%">Status</th>
- <th width="20%">Score</th>
+ <th width="20%">Last 4 Iterations</th>
+ <th width="20%">Last 10 Days</th>
</tr>
{% for scenario,result in scenario_results.iteritems() -%}
<tr class="tr-ok">
<td>{{scenario}}</td>
<td>
- {%if scenario_results[scenario].getStatus() is sameas "OK" -%}
- <img src="../../img/icon-ok.png">
- {%- else -%}
- <img src="../../img/icon-nok.png">
- {%- endif %}
+ <img src="../../img/gauge_{{ scenario_results[scenario].getStatus() }}.png">
</td>
- <td>{{scenario_results[scenario].getScore()}}</td>
+ <td>{{scenario_results[scenario].getFourDaysScore()}}</td>
+ <td>{{scenario_results[scenario].getTenDaysScore()}}</td>
</tr>
{%- endfor %}
</table>