From: Luis Gomez Date: Thu, 20 Sep 2018 01:16:44 +0000 (-0700) Subject: Separate test data vs dashboard script X-Git-Tag: pre-potassium~544 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=integration%2Ftest.git;a=commitdiff_plain;h=e8652b63fac0ee8b68ac599f8994707d71e81187 Separate test data vs dashboard script Also use configured series value to sort series. Change-Id: Idf09eb04c905e0f75c07fbf1123170c684a9df7a Signed-off-by: Luis Gomez --- diff --git a/csit/postplans/bgpcep-bgp-ingest-mixed.txt b/csit/postplans/bgpcep-bgp-ingest-mixed.txt index 5ccfa18c00..f96a5e8d5f 100644 --- a/csit/postplans/bgpcep-bgp-ingest-mixed.txt +++ b/csit/postplans/bgpcep-bgp-ingest-mixed.txt @@ -1,2 +1,2 @@ # Place the commands in run order: -python3 integration/test/csit/scripts/push_to_elk.py a4ff38b99ef2c7626450543021b4c134.us-east-1.aws.found.io:9243 +python3 integration/test/csit/scripts/push_test_data.py a4ff38b99ef2c7626450543021b4c134.us-east-1.aws.found.io:9243 diff --git a/csit/postplans/bgpcep-userfeatures.txt b/csit/postplans/bgpcep-userfeatures.txt index 5ccfa18c00..f96a5e8d5f 100644 --- a/csit/postplans/bgpcep-userfeatures.txt +++ b/csit/postplans/bgpcep-userfeatures.txt @@ -1,2 +1,2 @@ # Place the commands in run order: -python3 integration/test/csit/scripts/push_to_elk.py a4ff38b99ef2c7626450543021b4c134.us-east-1.aws.found.io:9243 +python3 integration/test/csit/scripts/push_test_data.py a4ff38b99ef2c7626450543021b4c134.us-east-1.aws.found.io:9243 diff --git a/csit/postplans/openflowplugin-clustering-perf-bulkomatic.txt b/csit/postplans/openflowplugin-clustering-perf-bulkomatic.txt index 5ccfa18c00..f96a5e8d5f 100644 --- a/csit/postplans/openflowplugin-clustering-perf-bulkomatic.txt +++ b/csit/postplans/openflowplugin-clustering-perf-bulkomatic.txt @@ -1,2 +1,2 @@ # Place the commands in run order: -python3 integration/test/csit/scripts/push_to_elk.py a4ff38b99ef2c7626450543021b4c134.us-east-1.aws.found.io:9243 +python3 integration/test/csit/scripts/push_test_data.py a4ff38b99ef2c7626450543021b4c134.us-east-1.aws.found.io:9243 diff --git a/csit/postplans/openflowplugin-clustering.txt b/csit/postplans/openflowplugin-clustering.txt index 5ccfa18c00..f96a5e8d5f 100644 --- a/csit/postplans/openflowplugin-clustering.txt +++ b/csit/postplans/openflowplugin-clustering.txt @@ -1,2 +1,2 @@ # Place the commands in run order: -python3 integration/test/csit/scripts/push_to_elk.py a4ff38b99ef2c7626450543021b4c134.us-east-1.aws.found.io:9243 +python3 integration/test/csit/scripts/push_test_data.py a4ff38b99ef2c7626450543021b4c134.us-east-1.aws.found.io:9243 diff --git a/csit/postplans/openflowplugin-flow-services.txt b/csit/postplans/openflowplugin-flow-services.txt index 5ccfa18c00..f96a5e8d5f 100644 --- a/csit/postplans/openflowplugin-flow-services.txt +++ b/csit/postplans/openflowplugin-flow-services.txt @@ -1,2 +1,2 @@ # Place the commands in run order: -python3 integration/test/csit/scripts/push_to_elk.py a4ff38b99ef2c7626450543021b4c134.us-east-1.aws.found.io:9243 +python3 integration/test/csit/scripts/push_test_data.py a4ff38b99ef2c7626450543021b4c134.us-east-1.aws.found.io:9243 diff --git a/csit/postplans/openflowplugin-perf-bulkomatic.txt b/csit/postplans/openflowplugin-perf-bulkomatic.txt index 5ccfa18c00..f96a5e8d5f 100644 --- a/csit/postplans/openflowplugin-perf-bulkomatic.txt +++ b/csit/postplans/openflowplugin-perf-bulkomatic.txt @@ -1,2 +1,2 @@ # Place the commands in run order: -python3 integration/test/csit/scripts/push_to_elk.py a4ff38b99ef2c7626450543021b4c134.us-east-1.aws.found.io:9243 +python3 integration/test/csit/scripts/push_test_data.py a4ff38b99ef2c7626450543021b4c134.us-east-1.aws.found.io:9243 diff --git a/csit/scripts/generate_visState.py b/csit/scripts/generate_visState.py index e020ae1548..093cd1a0db 100644 --- a/csit/scripts/generate_visState.py +++ b/csit/scripts/generate_visState.py @@ -59,11 +59,12 @@ class visState: agg = aggs() - temp['aggs'] = [dc(agg.create(field=i['field'], - custom_label=i['custom_label'], - schema=i['schema'])) - for _, i in - config['aggs'].items()] + temp['aggs'] = \ + [dc(agg.create(id=i, + field=config['aggs'][i]['field'], + custom_label=config['aggs'][i]['custom_label'], + schema=config['aggs'][i]['schema'])) + for i in range(1, len(config['aggs']) + 1)] temp['params']['seriesParams'] = [seriesParams(i['data_type'], i['mode'], @@ -179,10 +180,9 @@ class aggs: } self.counter = 0 - def create(self, field, custom_label, schema): - self.counter += 1 + def create(self, id, field, custom_label, schema): temp = dc(self.content) - temp['id'] = str(self.counter) + temp['id'] = id temp['params']['field'] = field temp['params']['customLabel'] = custom_label temp['schema'] = schema @@ -278,22 +278,19 @@ def generate(dash_config, viz_config): format['value_axes'].update(temp) value_axes_counter += 1 - seriesParams_counter = 1 seriesParams_fields = ['value_axis', 'data_type', 'mode', 'label', 'agg_id'] try: for m in viz_config['seriesParams']: if m != 'default': temp = dc(seriesParams_format) - temp[str(seriesParams_counter)] = temp['index'] + temp[m] = temp['index'] for i in seriesParams_fields: try: - temp[str(seriesParams_counter) - ][i] = viz_config['seriesParams'][m][i] + temp[m][i] = viz_config['seriesParams'][m][i] except KeyError: pass format['seriesParams'].update(temp) - seriesParams_counter += 1 except KeyError: pass @@ -302,14 +299,13 @@ def generate(dash_config, viz_config): for m in viz_config['aggs']: if m != 'default': temp = dc(aggs_format) - temp[str(agg_counter)] = temp['index'] + temp[m] = temp['index'] for i in ['field', 'custom_label', 'schema']: try: - temp[str(agg_counter)][i] = viz_config['aggs'][m][i] + temp[m][i] = viz_config['aggs'][m][i] except KeyError: pass format['aggs'].update(temp) - agg_counter += 1 except KeyError: pass @@ -355,33 +351,26 @@ def generate(dash_config, viz_config): config['series'][key]['not_in_seriesParams'] except KeyError: seriesParams_temp = dc(seriesParams_format) - seriesParams_temp[str( - seriesParams_counter)] = seriesParams_temp['index'] + seriesParams_temp[key] = seriesParams_temp['index'] for index in ['value_axis', 'data_type', 'mode', 'label']: try: - seriesParams_temp[str( - seriesParams_counter)][index] = \ + seriesParams_temp[key][index] = \ config['series'][key][index] except KeyError as e: pass - seriesParams_temp[str( - seriesParams_counter)]['agg_id'] = agg_counter + seriesParams_temp[key]['agg_id'] = key format['seriesParams'].update(seriesParams_temp) - seriesParams_counter += 1 finally: agg_temp = dc(aggs_format) - agg_temp[str(agg_counter)] = agg_temp['index'] + agg_temp[key] = agg_temp['index'] for index in ['field', 'schema']: try: - agg_temp[str(agg_counter) - ][index] = config['series'][key][index] + agg_temp[key][index] = config['series'][key][index] except KeyError as e: pass - agg_temp[str( - agg_counter)]['custom_label'] = \ + agg_temp[key]['custom_label'] = \ config['series'][key]['label'] format['aggs'].update(agg_temp) - agg_counter += 1 except KeyError as e: print("required fields are empty!") diff --git a/csit/scripts/push_to_elk.py b/csit/scripts/push_dashboard.py similarity index 73% rename from csit/scripts/push_to_elk.py rename to csit/scripts/push_dashboard.py index a1a085e286..bb86f80323 100755 --- a/csit/scripts/push_to_elk.py +++ b/csit/scripts/push_dashboard.py @@ -12,40 +12,11 @@ ############################################################################## """ -This script is used to parse logs, construct JSON BODY and push -it to ELK DB. - -Usage: python construct_json.py host:port - -JSON body similar to following is \ -constructed from robot files, jenkins environment -and plot files available in workspace available post-build. -{ - "project": "opendaylight", <- fix string for ODL project - "subject": "test", <- fix string for ODL test - "test-type": "performance", <- if there are csv files, \ - otherwise "functional" - "jenkins-silo": "releng" <- from Jenkins $SILO - "test-name": "openflowplugin-csit-1node-periodic \ - -bulkomatic-perf-daily-only-carbon", <- from Jenkins $JOB_NAME - "test-run": 289, <- from Jenkins $BUILD_NUMBER - "start-time": "20170612 16:50:04 GMT-07:00", <- from robot log - "duration": "00:01:05.942", <- from robot log - "pass-tests": 9, <- from robot log - "fail-tests": 0, <- from robot log - "plots": { - "rate": { <- csv filename - "Config DS": 5816.99726601, <- from csv file - "OVS Switch": 5757.05238918, <- from csv file - "Operational DS": 2654.49139945 <- from csv file - }, - "time": { <- csv filename - "Config DS": 17.191, <- from csv file - "OVS Switch": 17.37, <- from csv file - "Operational DS": 37.672 <- from csv file - } - } -} +This script is used to parse dashboard config files, construct +JSON BODY and push it to ELK DB. + +Usage: python push_dashboard.py host:port + """ # stdlib @@ -57,7 +28,6 @@ import glob # 3rd party lib from elasticsearch import Elasticsearch, RequestsHttpConnection, exceptions import yaml -import glob # User defined libs import generate_visState as vis_gen @@ -69,9 +39,9 @@ import data_generate as data_gen def p(x): print(json.dumps(x, indent=6, sort_keys=True)) -# ELK DB host and port to be passed as ':' separated argument +# ELK DB host and port to be passed as ':' separated argument if len(sys.argv) > 1: if ':' in sys.argv[1]: ELK_DB_HOST = sys.argv[1].split(':')[0] @@ -81,10 +51,6 @@ else: print('Unable to publish data to ELK. Exiting.') sys.exit() -# Construct json body - -# BODY = {} - try: es = Elasticsearch( hosts=[{'host': ELK_DB_HOST, 'port': int(ELK_DB_PORT)}], @@ -97,25 +63,6 @@ except Exception as e: # print(es.info()) -# get data from the user defined script -BODY = data_gen.generate() - -print(json.dumps(BODY, indent=4)) - -# Try to send request to ELK DB. - -try: - index = '{}-{}'.format(BODY['project'], - BODY['subject']) - ES_ID = '{}:{}-{}'.format(BODY['test-type'], BODY['test-name'], - BODY['test-run']) - res = es.index(index=index, doc_type='doc', id=ES_ID, body=BODY) - print(json.dumps(res, indent=4)) -except Exception as e: - print(e) - print('Unable to push data to ElasticSearch') - - # sys.exit() # Function to convert JSON object to string. # Python puts 'true' as 'True' etc. which need handling. @@ -144,19 +91,19 @@ except Exception as e: # Create and push index-pattern to be used by visualizations +TEST_DATA_INDEX = 'opendaylight-test' + INDEX_PATTERN_BODY = { "type": "index-pattern", "index-pattern": { "timeFieldName": "@timestamp", - "title": '{}-{}'.format(BODY['project'], - BODY['subject']) + "title": TEST_DATA_INDEX } } KIBANA_CONFIG = {'config': { - 'defaultIndex': 'pattern-for-{}-{}'.format(BODY['project'], - BODY['subject']), + 'defaultIndex': 'pattern-for-{}'.format(TEST_DATA_INDEX), 'timepicker:timeDefaults': '{\n "from": "now-5y",\n \ "to": "now",\n "mode": "quick"\n}', 'xPackMonitoring:showBanner': False}, @@ -169,8 +116,8 @@ res = es.index(index='.kibana', doc_type='doc', try: index = '.kibana' - ES_ID = 'index-pattern:pattern-for-{}-{}'.format( - BODY['project'], BODY['subject']) + ES_ID = 'index-pattern:pattern-for-{}'.format( + TEST_DATA_INDEX) res = es.index(index=index, doc_type='doc', id=ES_ID, body=INDEX_PATTERN_BODY) p(json.dumps(INDEX_PATTERN_BODY, indent=4)) diff --git a/csit/scripts/push_test_data.py b/csit/scripts/push_test_data.py new file mode 100755 index 0000000000..9efaa213c2 --- /dev/null +++ b/csit/scripts/push_test_data.py @@ -0,0 +1,108 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# @License EPL-1.0 +############################################################################## +# Copyright (c) 2017 Raghuram Vadapalli, Jaspreet Singh and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################## + +""" +This script is used to parse test logs, construct JSON BODY and push +it to ELK DB. + +Usage: python push_test_data.py host:port + +JSON body similar to following is \ +constructed from robot files, jenkins environment +and plot files available in workspace available post-build. +{ + "project": "opendaylight", <- fix string for ODL project + "subject": "test", <- fix string for ODL test + "test-type": "performance", <- if there are csv files, \ + otherwise "functional" + "jenkins-silo": "releng" <- from Jenkins $SILO + "test-name": "openflowplugin-csit-1node-periodic \ + -bulkomatic-perf-daily-only-carbon", <- from Jenkins $JOB_NAME + "test-run": 289, <- from Jenkins $BUILD_NUMBER + "start-time": "20170612 16:50:04 GMT-07:00", <- from robot log + "duration": "00:01:05.942", <- from robot log + "pass-tests": 9, <- from robot log + "fail-tests": 0, <- from robot log + "plots": { + "rate": { <- csv filename + "Config DS": 5816.99726601, <- from csv file + "OVS Switch": 5757.05238918, <- from csv file + "Operational DS": 2654.49139945 <- from csv file + }, + "time": { <- csv filename + "Config DS": 17.191, <- from csv file + "OVS Switch": 17.37, <- from csv file + "Operational DS": 37.672 <- from csv file + } + } +} +""" + +# stdlib +import json +import sys + +# 3rd party lib +from elasticsearch import Elasticsearch, RequestsHttpConnection, exceptions + +# User defined libs +import data_generate as data_gen + + +def p(x): + print(json.dumps(x, indent=6, sort_keys=True)) +# ELK DB host and port to be passed as ':' separated argument + + +if len(sys.argv) > 1: + if ':' in sys.argv[1]: + ELK_DB_HOST = sys.argv[1].split(':')[0] + ELK_DB_PORT = sys.argv[1].split(':')[1] +else: + print('Usage: python push_to_elk.py host:port') + print('Unable to publish data to ELK. Exiting.') + sys.exit() + +# Construct json body + +# BODY = {} + +try: + es = Elasticsearch( + hosts=[{'host': ELK_DB_HOST, 'port': int(ELK_DB_PORT)}], + scheme='https', + connection_class=RequestsHttpConnection + ) +except Exception as e: + print('Unexpected Error Occurred. Exiting') + print(e) +# print(es.info()) + + +# get data from the user defined script +BODY = data_gen.generate() + +print(json.dumps(BODY, indent=4)) + +# Try to send request to ELK DB. + +try: + index = '{}-{}'.format(BODY['project'], + BODY['subject']) + ES_ID = '{}:{}-{}'.format(BODY['test-type'], BODY['test-name'], + BODY['test-run']) + res = es.index(index=index, doc_type='doc', id=ES_ID, body=BODY) + print(json.dumps(res, indent=4)) +except Exception as e: + print(e) + print('Unable to push data to ElasticSearch') diff --git a/dashboard/dash_config.yaml b/dashboard/dash_config.yaml index e4a160c792..ce84655376 100644 --- a/dashboard/dash_config.yaml +++ b/dashboard/dash_config.yaml @@ -44,13 +44,13 @@ bgpcep: viz-template: opendaylight-test-performance y-axis: value_axes: - 1: - title: BGP updates/sec - series: 1: + title: BGP updates/sec + series: + 2: field: plots.performance-bgp.+10/-9 routes per UPDATE label: +10/-9 routes per UPDATE - color: red + color: blue filter: 1: field: test-name @@ -67,13 +67,13 @@ bgpcep: viz-template: opendaylight-test-performance y-axis: value_axes: - 1: - title: BGP updates/sec - series: 1: + title: BGP updates/sec + series: + 2: field: plots.performance-bgp.+10/-9 routes per UPDATE label: +10/-9 routes per UPDATE - color: red + color: blue filter: 1: field: test-name @@ -164,18 +164,18 @@ openflowplugin: viz-template: opendaylight-test-performance y-axis: value_axes: - 1: - title: flowmods/sec - series: 1: + title: flowmods/sec + series: + 2: field: plots.rate.Config DS label: Config DS color: red - 2: + 3: field: plots.rate.OVS Switch label: OVS Switch color: green - 3: + 4: field: plots.rate.Operational DS label: Operational DS color: blue @@ -195,18 +195,18 @@ openflowplugin: viz-template: opendaylight-test-performance y-axis: value_axes: - 1: - title: flowmods/sec - series: 1: + title: flowmods/sec + series: + 2: field: plots.rate.Config DS label: Config DS color: red - 2: + 3: field: plots.rate.OVS Switch label: OVS Switch color: green - 3: + 4: field: plots.rate.Operational DS label: Operational DS color: blue @@ -226,18 +226,18 @@ openflowplugin: viz-template: opendaylight-test-performance y-axis: value_axes: - 1: - title: flowmods/sec - series: 1: + title: flowmods/sec + series: + 2: field: plots.rate.Config DS label: Config DS color: red - 2: + 3: field: plots.rate.OVS Switch label: OVS Switch color: green - 3: + 4: field: plots.rate.Operational DS label: Operational DS color: blue @@ -257,18 +257,18 @@ openflowplugin: viz-template: opendaylight-test-performance y-axis: value_axes: - 1: - title: flowmods/sec - series: 1: + title: flowmods/sec + series: + 2: field: plots.rate.Config DS label: Config DS color: red - 2: + 3: field: plots.rate.OVS Switch label: OVS Switch color: green - 3: + 4: field: plots.rate.Operational DS label: Operational DS color: blue diff --git a/dashboard/viz_config.yaml b/dashboard/viz_config.yaml index 4399053309..79d083cf2b 100644 --- a/dashboard/viz_config.yaml +++ b/dashboard/viz_config.yaml @@ -8,23 +8,23 @@ opendaylight-test-feature: position: left title: No. of test cases series: - fail: + 1: data_type: histogram mode: stacked - field: fail-tests - label: Fail tests + field: pass-tests + label: Pass tests schema: metric value_axis: 1 - color: red - pass: + color: green + 2: data_type: histogram mode: stacked - field: pass-tests - label: Pass tests + field: fail-tests + label: Fail tests schema: metric value_axis: 1 - color: green - build: + color: red + 3: field: test-run label: Build Number schema: segment @@ -44,7 +44,7 @@ opendaylight-test-performance: mode: normal value_axis: 1 aggs: - build: + 1: field: test-run custom_label: Build Number schema: segment