-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdvaresults
executable file
·50 lines (44 loc) · 1.62 KB
/
dvaresults
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
import argparse
import os
import yaml
import json
def parse_results(dva_yaml):
# Read dva tests results
with open(dva_yaml, 'r') as f:
doc = yaml.load(f)
# If run from jenkins, BUILD_URL should be available
ref_url = os.environ.get('BUILD_URL')
body = {}
results = {}
# iterate over each testcase
for item in doc:
if 'test' in item:
test_name = 'dva.ami.' + item['test']['name']
result_name = 'dva.ami.%s.%s.%s' % (item['ami'], item['region'],
item['test']['name'])
outcome = item['test']['result'].upper()
if outcome == 'SKIP':
outcome = 'PASSED'
results[result_name] = {}
data = {}
data.update(item=item['ami'])
results[result_name].update(data=data)
results[result_name].update(outcome=outcome)
results[result_name].update(ref_url=ref_url)
results[result_name].update(note=None)
testcase = {}
testcase.update(name=test_name)
testcase.update(ref_url=ref_url)
results[result_name].update(testcase=testcase)
body.update(results=results)
body.update(ref_url=ref_url)
json_data = json.dumps(body, sort_keys=True, indent=2)
return json_data
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Imports dva results into resultsdb')
parser.add_argument('dva_yaml', help='Path to dva results yaml')
args = parser.parse_args()
results = parse_results(args.dva_yaml)
print results