From 618647ca01ded6c1e92618ac71d4c4e1cff7b76b Mon Sep 17 00:00:00 2001 From: varac Date: Thu, 13 Apr 2017 14:08:00 +0200 Subject: Add dashboard template --- .gitignore | 1 + elastic/dashboard/soledad-benchmark.json | 20 --------- elastic/dashboard/template.mustache | 20 +++++++++ elastic/generate-config.py | 73 +++++++++++++++++--------------- elastic/load.sh | 12 +++--- 5 files changed, 66 insertions(+), 60 deletions(-) delete mode 100644 elastic/dashboard/soledad-benchmark.json create mode 100644 elastic/dashboard/template.mustache diff --git a/.gitignore b/.gitignore index 3716f11..8161cca 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /elastic/visualization/*.json +/elastic/dashboard/*.json diff --git a/elastic/dashboard/soledad-benchmark.json b/elastic/dashboard/soledad-benchmark.json deleted file mode 100644 index 71d9279..0000000 --- a/elastic/dashboard/soledad-benchmark.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "title": "Soledad-Benchmarks", - "hits": 0, - "description": "All Soledad benchmak tests run on Weasel", - "panelsJSON": "[{\"col\":1,\"id\":\"test_upload_20_500k\",\"panelIndex\":1,\"row\":1,\"size_x\":5,\"size_y\":4,\"type\":\"visualization\"}]", - "optionsJSON": "{\"darkTheme\":true}", - "uiStateJSON": "{}", - "version": 1, - "timeRestore": true, - "timeTo": "now", - "timeFrom": "now/y", - "refreshInterval": { - "display": "Off", - "pause": false, - "value": 0 - }, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[{\"query\":{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"*\"}}}]}" - } -} diff --git a/elastic/dashboard/template.mustache b/elastic/dashboard/template.mustache new file mode 100644 index 0000000..4d66954 --- /dev/null +++ b/elastic/dashboard/template.mustache @@ -0,0 +1,20 @@ +{ + "title": "Soledad-Benchmarks", + "hits": 0, + "description": "All Soledad benchmak tests run on Weasel", + "panelsJSON": "[{{#tests}} {\"col\":1,\"id\":\"{{name}}\",\"panelIndex\":1,\"row\":1,\"size_x\":6,\"size_y\":3,\"type\":\"visualization\"}, {{/tests}}{\"col\":1,\"id\":\"test_decrypt_doc_1M\",\"panelIndex\":1,\"row\":1,\"size_x\":6,\"size_y\":3,\"type\":\"visualization\"} ]", + "optionsJSON": "{\"darkTheme\":true}", + "uiStateJSON": "{}", + "version": 1, + "timeRestore": true, + "timeTo": "now", + "timeFrom": "now/y", + "refreshInterval": { + "display": "Off", + "pause": false, + "value": 0 + }, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[{\"query\":{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"*\"}}}]}" + } +} diff --git a/elastic/generate-config.py b/elastic/generate-config.py index e5e8547..49a6209 100755 --- a/elastic/generate-config.py +++ b/elastic/generate-config.py @@ -1,32 +1,34 @@ #!/usr/bin/env python3 +import json import pystache #print(pystache.render('Hi {{person}}!', {'person': 'Mom'})) -tests = [ - 'test_encrypt_raw_10M', - 'test_encrypt_raw_100k', - # 'test_encrypt_raw_10k', - # 'test_decrypt_raw_100k', - # 'test_decrypt_raw_10M', - # 'test_decrypt_raw_10k', - # 'test_decrypt_raw_1M', - # 'test_decrypt_raw_500k', - # 'test_encrypt_raw_1M', - # 'test_encrypt_raw_500k', - # 'test_initialization', - # 'test_async_create_1000_10k', - # 'test_async_create_100_100k', - # 'test_create_1000_10k', - # 'test_create_100_100k', - # 'test_create_20_500k', - # 'test_decrypt_doc_100k', - # 'test_decrypt_doc_10M', - # 'test_decrypt_doc_10k', - #'test_decrypt_doc_1M' - ] +tests_json = '{ "tests":[\ + {"name": "test_encrypt_raw_10M"},\ + {"name": "test_encrypt_raw_100k"},\ + {"name": "test_encrypt_raw_10k"},\ + {"name": "test_decrypt_raw_100k"},\ + {"name": "test_decrypt_raw_10M"},\ + {"name": "test_decrypt_raw_10k"},\ + {"name": "test_decrypt_raw_1M"},\ + {"name": "test_decrypt_raw_500k"},\ + {"name": "test_encrypt_raw_1M"},\ + {"name": "test_encrypt_raw_500k"},\ + {"name": "test_initialization"},\ + {"name": "test_async_create_1000_10k"},\ + {"name": "test_async_create_100_100k"},\ + {"name": "test_create_1000_10k"},\ + {"name": "test_create_100_100k"},\ + {"name": "test_create_20_500k"},\ + {"name": "test_decrypt_doc_100k"},\ + {"name": "test_decrypt_doc_10M"},\ + {"name": "test_decrypt_doc_10k"},\ + {"name": "test_decrypt_doc_1M"}\ + ]}' +tests = json.loads(tests_json) # Generate visualizations @@ -34,16 +36,17 @@ def generate_visualizations(): dir = './visualization/' template = open(dir + 'template.mustache', 'r').read() - for test in tests: - out_file = dir + test + '.json' + # test_names = tests. + for test in tests['tests']: + test_name = test['name'] + out_file = dir + test_name + '.json' print('Generating ' + out_file) context = { - 'title': test, - 'query': "commit_info.project:soledad AND commit_info.branch='master' AND machine_info.host='weasel' AND name='" + test + "'" + '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) - #print(context) out = open(out_file, 'w') out.write(rendered) @@ -53,16 +56,18 @@ def generate_visualizations(): def generate_dashboards(): dir = './dashboard/' template = open(dir + 'template.mustache', 'r').read() - out_file = dir + test + '.json' + out_file = dir + 'soledad-benchmarks.json' print('Generating ' + out_file) - item = q + rendered = pystache.render(template, tests) + #print(rendered) - for test in tests: - dashboards = dashboards + '' + out = open(out_file, 'w') + out.write(rendered) + out.flush() - rendered = pystache.render(template, context) - print(rendered) +# Main + +generate_dashboards() generate_visualizations() -#generate_dashboards() diff --git a/elastic/load.sh b/elastic/load.sh index c077948..a50083a 100755 --- a/elastic/load.sh +++ b/elastic/load.sh @@ -126,20 +126,20 @@ do echo done -for file in ${DIR}/visualization/*.json +for file in ${DIR}/dashboard/*.json do NAME=`basename ${file} .json` - echo "Loading visualization ${NAME}:" - ${CURL} -XPUT ${ELASTICSEARCH}/${KIBANA_INDEX}/visualization/${NAME} \ + echo "Loading dashboard ${NAME}:" + ${CURL} -XPUT ${ELASTICSEARCH}/${KIBANA_INDEX}/dashboard/${NAME} \ -d @${file} || exit 1 echo done -for file in ${DIR}/dashboard/*.json +for file in ${DIR}/visualization/*.json do NAME=`basename ${file} .json` - echo "Loading dashboard ${NAME}:" - ${CURL} -XPUT ${ELASTICSEARCH}/${KIBANA_INDEX}/dashboard/${NAME} \ + echo "Loading visualization ${NAME}:" + ${CURL} -XPUT ${ELASTICSEARCH}/${KIBANA_INDEX}/visualization/${NAME} \ -d @${file} || exit 1 echo done -- cgit v1.2.3