#
# http://www.apache.org/licenses/LICENSE-2.0
#
-from urllib2 import Request, urlopen, URLError
import logging
import json
import os
import pdfkit
import yaml
+from urllib2 import Request, urlopen, URLError
+
# ----------------------------------------------------------
#
"""
Get the list of Scenarios
"""
-
+ test_results = None
+ scenario_results = None
period = get_config('general.period')
url_base = get_config('testapi.url')
def getScenarioStatus(installer, version):
"""
Get the status of a scenariofor Yardstick
- they used criteria SUCCESS (default: PASS)
"""
period = get_config('general.period')
url_base = get_config('testapi.url')
except URLError:
print "GetScenarioStatus: error when calling the API"
- scenario_results = {}
- result_dict = {}
+ x86 = 'x86'
+ aarch64 = 'aarch64'
+ scenario_results = {x86: {}, aarch64: {}}
+ result_dict = {x86: {}, aarch64: {}}
if test_results is not None:
for test_r in test_results:
if (test_r['stop_date'] != 'None' and
test_r['criteria'] is not None):
- if not test_r['scenario'] in scenario_results.keys():
- scenario_results[test_r['scenario']] = []
- scenario_results[test_r['scenario']].append(test_r)
-
- for scen_k, scen_v in scenario_results.items():
- # scenario_results[k] = v[:LASTEST_TESTS]
- s_list = []
- for element in scen_v:
- if element['criteria'] == 'SUCCESS':
- s_list.append(1)
+ scenario_name = test_r['scenario']
+ if 'arm' in test_r['pod_name']:
+ if not test_r['scenario'] in scenario_results[aarch64]:
+ scenario_results[aarch64][scenario_name] = []
+ scenario_results[aarch64][scenario_name].append(test_r)
else:
- s_list.append(0)
- result_dict[scen_k] = s_list
+ if not test_r['scenario'] in scenario_results[x86]:
+ scenario_results[x86][scenario_name] = []
+ scenario_results[x86][scenario_name].append(test_r)
+
+ for key in scenario_results:
+ for scen_k, scen_v in scenario_results[key].items():
+ # scenario_results[k] = v[:LASTEST_TESTS]
+ s_list = []
+ for element in scen_v:
+ if element['criteria'] == 'PASS':
+ s_list.append(1)
+ else:
+ s_list.append(0)
+ result_dict[key][scen_k] = s_list
# return scenario_results
return result_dict
return nb_test_ok
-def getResult(testCase, installer, scenario, version):
+def getCaseScore(testCase, installer, scenario, version):
"""
Get Result for a given Functest Testcase
"""
return test_result_indicator
+def getCaseScoreFromBuildTag(testCase, s_results):
+ """
+ Get Results for a given Functest Testcase with arch filtering
+ """
+ url_base = get_config('testapi.url')
+ nb_tests = get_config('general.nb_iteration_tests_success_criteria')
+ test_result_indicator = 0
+ # architecture is not a result field...so we cannot use getResult as it is
+ res_matrix = []
+ try:
+ for s_result in s_results:
+ build_tag = s_result['build_tag']
+ d = s_result['start_date']
+ res_matrix.append({'date': d,
+ 'build_tag': build_tag})
+ # sort res_matrix
+ filter_res_matrix = sorted(res_matrix, key=lambda k: k['date'],
+ reverse=True)[:nb_tests]
+ for my_res in filter_res_matrix:
+ url = ("http://" + url_base + "?case=" + testCase +
+ "&build_tag=" + my_res['build_tag'])
+ request = Request(url)
+ response = urlopen(request)
+ k = response.read()
+ results = json.loads(k)
+ if "PASS" in results['results'][0]['criteria']:
+ test_result_indicator += 1
+ except:
+ print "No results found for this case"
+ if test_result_indicator > 2:
+ test_result_indicator = test_result_indicator - 1
+
+ return test_result_indicator
+
+
def getJenkinsUrl(build_tag):
"""
Get Jenkins url_base corespoding to the last test CI run