diff options
Diffstat (limited to 'elastic/generate-config.py')
| -rwxr-xr-x | elastic/generate-config.py | 78 | 
1 files changed, 46 insertions, 32 deletions
diff --git a/elastic/generate-config.py b/elastic/generate-config.py index be8afcb..88d6e82 100755 --- a/elastic/generate-config.py +++ b/elastic/generate-config.py @@ -33,8 +33,10 @@ def _delete_jsons(directory):  def generate_visualizations(tests):      with open(os.path.join('templates', 'visualization.mustache'), 'r') as f:          template = f.read() -    with open(os.path.join('templates', 'visualization-visState.mustache')) as f: -        template_visState = f.read() +    with open(os.path.join('templates', 'visualization-visState-time.mustache')) as f: +        template_visState_time = f.read() +    with open(os.path.join('templates', 'visualization-visState-resources.mustache')) as f: +        template_visState_resources = f.read()      with open(os.path.join('templates', 'visualization-searchSourceJSON.mustache')) as f:          template_searchSourceJSON = f.read() @@ -46,31 +48,40 @@ def generate_visualizations(tests):          if f.endswith('.json'):              os.unlink(os.path.join(out_dir, f)) +    graphs = [ +        ('time', 'weasel', template_visState_time), +        ('resources', 'Beluga', template_visState_resources) +    ] +      for test_name in tests: -        out_file = os.path.join(out_dir, test_name + '.json') -        logger.info('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 + "'" -        } +        for type, host, template_visState in graphs: + +            out_file = os.path.join(out_dir, test_name + '_' + type + '.json') +            logger.info('Generating ' + out_file) + +            context = { +               'title': test_name + "_" + type, +               'test_name': test_name, +               'query': "commit_info.project:soledad " +#                        "AND commit_info.branch='master' " +                        "AND machine_info.host='" + host + "' " +                        "AND name='" + test_name + "'" +            } -        visState = pystache.render(template_visState, context) -        assert json.loads(visState) -        context['visState'] = json.dumps(visState) +            visState = pystache.render(template_visState, context) +            assert json.loads(visState) +            context['visState'] = json.dumps(visState) -        searchSourceJSON = pystache.render(template_searchSourceJSON, context) -        assert json.loads(searchSourceJSON) -        context['searchSourceJSON'] = json.dumps(searchSourceJSON) +            searchSourceJSON = pystache.render(template_searchSourceJSON, context) +            assert json.loads(searchSourceJSON) +            context['searchSourceJSON'] = json.dumps(searchSourceJSON) -        rendered = pystache.render(template, context) -        assert json.loads(rendered) +            rendered = pystache.render(template, context) +            assert json.loads(rendered) -        with open(out_file, 'w') as out: -            out.write(rendered) +            with open(out_file, 'w') as out: +                out.write(rendered)  def generate_dashboards(tests): @@ -84,18 +95,21 @@ def generate_dashboards(tests):      logger.info('Generating ' + out_file)      panels = [] -    count = 0 +    panelIndex = 1 +    row = 1      for test_name in tests: -        count += 1 -        panels.append({ -            'id': test_name, -            'panelIndex': count, -            'col': 1, -            'row': count, -            'size_x': 6, -            'size_y': 3, -            'type': 'visualization', -        }) +        for type, col in [('time', 1), ('resources', 7)]: +            panels.append({ +                'id': test_name + '_' + type, +                'panelIndex': panelIndex, +                'col': col, +                'row': row, +                'size_x': 6, +                'size_y': 3, +                'type': 'visualization', +            }) +            panelIndex += 1 +        row += 3      context = {'panels_json': json.dumps(json.dumps(panels))}      rendered = pystache.render(template, context)  | 
