1 from urllib2 import Request, urlopen, URLError
6 installers = ["apex", "compass", "fuel", "joid"]
7 items = ["tests", "Success rate", "duration"]
10 print "Generate Tempest automatic reporting"
11 for installer in installers:
12 # we consider the Tempest results of the last PERIOD days
13 url = "http://testresults.opnfv.org/test/api/v1/results?case=Tempest"
14 request = Request(url + '&period=' + str(PERIOD)
15 + '&installer=' + installer + '&version=master')
18 response = urlopen(request)
20 results = json.loads(k)
22 print 'No kittez. Got an error code:', e
24 test_results = results['results']
25 test_results.reverse()
31 for r in test_results:
32 # Retrieve all the scenarios per installer
33 # In Brahmaputra use version
34 # Since Colorado use scenario
35 if not r['scenario'] in scenario_results.keys():
36 scenario_results[r['scenario']] = []
37 scenario_results[r['scenario']].append(r)
39 for s, s_result in scenario_results.items():
40 scenario_results[s] = s_result[0:5]
41 # For each scenario, we build a result object to deal with
42 # results, criteria and error handling
43 for result in scenario_results[s]:
44 result["start_date"] = result["start_date"].split(".")[0]
48 nb_tests_run = result['details']['tests']
49 nb_tests_failed = result['details']['failures']
51 success_rate = 100*(int(nb_tests_run)
52 - int(nb_tests_failed))/int(nb_tests_run)
56 result['details']["tests"] = nb_tests_run
57 result['details']["Success rate"] = str(success_rate) + "%"
65 # Expect that at least 165 tests are run
66 if nb_tests_run >= 165:
69 # Expect that at least 90% of success
70 if success_rate >= 90:
73 # Expect that the suite duration is inferior to 30m
74 if result['details']['duration'] < 1800:
77 result['criteria'] = {'tests': crit_tests,
78 'Success rate': crit_rate,
79 'duration': crit_time}
83 errors = result['details']['errors']
84 result['errors'] = errors.replace('{0}', '')
86 print "Error field not present (Brahamputra runs?)"
88 mypath = os.path.abspath(__file__)
89 tplLoader = jinja2.FileSystemLoader(os.path.dirname(mypath))
90 templateEnv = jinja2.Environment(loader=tplLoader)
92 TEMPLATE_FILE = "./template/index-tempest-tmpl.html"
93 template = templateEnv.get_template(TEMPLATE_FILE)
95 outputText = template.render(scenario_results=scenario_results,
99 with open("./release/master/index-tempest-" +
100 installer + ".html", "wb") as fh:
102 print "Tempest automatic reporting Done"