summaryrefslogtreecommitdiff
path: root/elastic/generate-config.py
diff options
context:
space:
mode:
Diffstat (limited to 'elastic/generate-config.py')
-rwxr-xr-xelastic/generate-config.py64
1 files changed, 38 insertions, 26 deletions
diff --git a/elastic/generate-config.py b/elastic/generate-config.py
index 9ff1210..b1389e1 100755
--- a/elastic/generate-config.py
+++ b/elastic/generate-config.py
@@ -67,9 +67,6 @@ def generate_visualizations(tests):
for type, title, host, template_visState in graphs:
- out_file = os.path.join(out_dir, test_name + '_' + type + '.json')
- logger.info('Generating ' + out_file)
-
query = "commit_info.project:soledad" \
" AND machine_info.host='" + host + "'" \
" AND name='" + test_name + "'"
@@ -85,26 +82,39 @@ def generate_visualizations(tests):
if type == 'cpu':
query += " AND _exists_:extra_info.cpu_percent"
- context = {
- 'title': title + test_name,
- 'test_name': test_name,
- 'query': query,
- }
+ # create visualization for many ranges
+ for r in ['', '-1w', '-1M', '-1y']:
+
+ rmod = ""
+ tmod = ""
+ if r:
+ rmod = " AND commit_info.time:[\\\"now%s\\\" TO \\\"now\\\"]" % r
+ tmod = ' (' + r + ')'
+
+ context = {
+ 'title': title + test_name + tmod,
+ 'test_name': test_name,
+ 'query': query + rmod,
+ }
- visState = pystache.render(template_visState, context)
- assert json.loads(visState)
- context['visState'] = json.dumps(visState)
+ file_name = test_name + '_' + type + r + '.json'
+ out_file = os.path.join(out_dir, file_name)
+ logger.info('Generating ' + out_file)
- searchSourceJSON = pystache.render(
- template_searchSourceJSON, context)
- assert json.loads(searchSourceJSON)
- context['searchSourceJSON'] = json.dumps(searchSourceJSON)
+ visState = pystache.render(template_visState, context)
+ assert json.loads(visState)
+ context['visState'] = json.dumps(visState)
- rendered = pystache.render(template, context)
- assert json.loads(rendered)
+ searchSourceJSON = pystache.render(
+ template_searchSourceJSON, context)
+ assert json.loads(searchSourceJSON)
+ context['searchSourceJSON'] = json.dumps(searchSourceJSON)
- with open(out_file, 'w') as out:
- out.write(rendered)
+ rendered = pystache.render(template, context)
+ assert json.loads(rendered)
+
+ with open(out_file, 'w') as out:
+ out.write(rendered)
def _dashboard_for_all_tests(tests):
@@ -142,21 +152,23 @@ def _dashboard_for_all_tests(tests):
f.write(rendered)
-def _dashboard_for_one_test(test):
+def _dashboards_for_one_test(test):
path = os.path.join('templates', 'dashboard-per-test.mustache')
with open(path, 'r') as f:
template = f.read()
- context = {'test_name': test}
- rendered = pystache.render(template, context)
- out_file = os.path.join('dashboard', 'dashboard-%s.json' % test)
- with open(out_file, 'w') as out:
- out.write(rendered)
+ for r in ['', '-1w', '-1M', '-1y']:
+ context = {'test_name': test, 'range_modifier': r}
+ rendered = pystache.render(template, context)
+ name = test + r
+ out_file = os.path.join('dashboard', 'dashboard-%s.json' % name)
+ with open(out_file, 'w') as out:
+ out.write(rendered)
def generate_dashboards(tests):
_dashboard_for_all_tests(tests)
for test in tests:
- _dashboard_for_one_test(test)
+ _dashboards_for_one_test(test)
def _get_test_names():