#!/usr/bin/env python3 import pystache import requests import json URL='https://moose.leap.se:9200' # Generate visualizations def generate_visualizations(): dir = './visualization/' template = open(dir + 'template.mustache', 'r').read() # test_names = tests. for test_name in tests: out_file = dir + test_name + '.json' print('Generating ' + out_file) context = { 'title': test_name, 'query': "commit_info.project:soledad AND commit_info.branch='master' AND machine_info.host='weasel' AND name='" + test_name + "'" } rendered = pystache.render(template, context) out = open(out_file, 'w') out.write(rendered) out.flush() # Generate Dashboard def generate_dashboards(): dir = './dashboard/' template = open(dir + 'template.mustache', 'r').read() out_file = dir + 'soledad-benchmarks.json' print('Generating ' + out_file) panels = '[' count = 0 for test_name in tests: count += 1 panels += '{\\"id\\":\\"' + test_name + '\\",\\"panelIndex\\":' + str(count) + ',\\"col\\":1,\\"row\\":' + str(count) + ',\\"size_x\\":6,\\"size_y\\":3,\\"type\\":\\"visualization\\"}, ' panels = panels[:-2] panels += ']' panels_json = { 'panels_json': panels } rendered = pystache.render(template, panels_json) #print(rendered) out = open(out_file, 'w') out.write(rendered) out.flush() # Main # Get all test names with open('./query/test_names.json') as f: response = requests.get(URL + '/_search', data=f) buckets = response.json()['aggregations']['test_names']['buckets'] tests = [] for d in buckets: name = d['key'] tests.append(name) generate_dashboards() generate_visualizations()