X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=testsuites%2Fposca%2Ftestcase_dashboard%2Fsystem_bandwidth.py;h=155ca2df80b01e9b1e326c52ce7dc978d0723b91;hb=58c97253eaaf72f73924837fca4ddcb5cb8a5d94;hp=708820d1fae46f59eff9827cb26b35003694dca4;hpb=b533d7bbf4e36e50c1280f14da4bda903633280c;p=bottlenecks.git diff --git a/testsuites/posca/testcase_dashboard/system_bandwidth.py b/testsuites/posca/testcase_dashboard/system_bandwidth.py index 708820d1..155ca2df 100755 --- a/testsuites/posca/testcase_dashboard/system_bandwidth.py +++ b/testsuites/posca/testcase_dashboard/system_bandwidth.py @@ -9,95 +9,122 @@ ############################################################################## import ConfigParser from elasticsearch import Elasticsearch +import json +import os +import utils.logger as log +from utils.parser import Parser as conf_parser +LOG = log.Logger(__name__).getLogger() config = ConfigParser.ConfigParser() -file_str = "testcase_cfg/posca_factor_system_bandwidth.yaml" -with open(file_str, "rd") as cfgfile: - config.readfp(cfgfile) - ES_ip_a = config.get("config", "ES_ip") +es = Elasticsearch() +dashboard_path = os.path.join(conf_parser.test_dir, + "posca", + "testcase_dashboard") +dashboard_dir = dashboard_path + "/" -es_ip = ES_ip_a.split(':') -es = Elasticsearch([{'host':es_ip[0]}]) -doc={ - "title": "bottlenecks", - "timeFieldName": "time", - "fields": "[{\"name\":\"runner_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"tx_cache_size\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"task_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"scenarios\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"local_cpu_util\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"rx_cache_size\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"local_transport_retrans\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"host\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"throughput\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"throughput_units\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"mean_latency\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"tx_msg_size\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"version\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"deploy_scenario\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"pod_name\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"target\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"rx_msg_size\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"installer\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"remote_cpu_util\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false}]" -} -res = es.index(index=".kibana",doc_type="index-pattern",id="bottlenecks",body=doc) -print(res['created']) +def dashboard_send_data(runner_config, test_data): + global es + es_ip = runner_config['dashboard_ip'].split(':') + es = Elasticsearch([{'host': es_ip[0]}]) + res = es.index(index="bottlenecks", + doc_type=test_data["testcase"], + body=test_data["data_body"]) + if res['created'] == "False": + LOG.error("date send to kibana have errors ", test_data["data_body"]) -doc={ - "buildNum": 10146, - "defaultIndex": "bottlenecks" -} -res = es.index(index=".kibana",doc_type="config",id="4.6.1",body=doc) -print(res['created']) -doc={ -"title": "system_bandwidth", - "description": "", - "version": 1, -} -res = es.index(index=".kibana",doc_type="search",id="system_bandwidth",body=doc) -print(res['created']) -doc = { - "title": "system_bandwidth_line-date", - "visState": "{\"title\":\"system_bandwidth_line-date\",\"type\":\"line\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"showCircles\":true,\"smoothLines\":false,\"interpolate\":\"linear\",\"scale\":\"linear\",\"drawLinesBetweenPoints\":true,\"radiusRatio\":9,\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"sum\",\"schema\":\"metric\",\"params\":{\"field\":\"throughput\"}},{\"id\":\"2\",\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"time\",\"size\":100,\"order\":\"asc\",\"orderBy\":\"_term\"}},{\"id\":\"3\",\"type\":\"sum\",\"schema\":\"metric\",\"params\":{\"field\":\"rx_msg_size\"}}],\"listeners\":{}}", - "uiStateJSON": "{}", - "description": "", - "version": 1, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"index\":\"bottlenecks\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}" - } -} -res = es.index( - index=".kibana", doc_type="visualization", id="system_bandwidth_line-date", body=doc) -print(res['created']) +def dashboard_system_bandwidth(runner_config): + global es + es_ip = runner_config['dashboard_ip'].split(':') + es = Elasticsearch([{'host': es_ip[0]}]) + # Create bottlenecks index + with open(dashboard_dir + 'posca_system_bandwidth_index_pattern.json')\ + as index_pattern: + doc = json.load(index_pattern) + res = es.index( + index=".kibana", + doc_type="index-pattern", + id="bottlenecks", + body=doc) + if res['created'] == "True": + LOG.info("bottlenecks index-pattern has created") + else: + LOG.info("bottlenecks index-pattern has existed") -doc = { - "title": "system_bandwidth_line-char", - "visState": "{\"title\":\"system_bandwidth_line-char\",\"type\":\"line\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"showCircles\":true,\"smoothLines\":false,\"interpolate\":\"linear\",\"scale\":\"linear\",\"drawLinesBetweenPoints\":true,\"radiusRatio\":9,\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"sum\",\"schema\":\"metric\",\"params\":{\"field\":\"throughput\"}},{\"id\":\"2\",\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"rx_msg_size\",\"size\":30,\"order\":\"asc\",\"orderBy\":\"_term\"}},{\"id\":\"3\",\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"tx_msg_size\",\"size\":30,\"order\":\"desc\",\"orderBy\":\"_term\"}}],\"listeners\":{}}", - "uiStateJSON": "{}", - "description": "", - "version": 1, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"index\":\"bottlenecks\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}" - } -} + with open(dashboard_dir + 'posca_system_bandwidth_config.json')\ + as index_config: + doc = json.load(index_config) + res = es.index(index=".kibana", doc_type="config", id="4.6.1", body=doc) + if res['created'] == "True": + LOG.info("bottlenecks config has created") + else: + LOG.info("bottlenecks config has existed") -res = es.index( - index=".kibana", doc_type="visualization", id="system_bandwidth_line-char", body=doc) -print(res['created']) + # Configure discover panel + with open(dashboard_dir + 'posca_system_bandwidth_discover.json')\ + as index_discover: + doc = json.load(index_discover) + res = es.index( + index=".kibana", + doc_type="search", + id="system_bandwidth", + body=doc) + if res['created'] == "True": + LOG.info("system_bandwidth search has created") + else: + LOG.info("system_bandwidth search has existed") -doc = { - "title": "system_bandwidth_terms_data", - "visState": "{\"title\":\"system_bandwidth_terms_data\",\"type\":\"table\",\"params\":{\"perPage\":80,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false},\"aggs\":[{\"id\":\"1\",\"type\":\"sum\",\"schema\":\"metric\",\"params\":{\"field\":\"throughput\"}},{\"id\":\"4\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"tx_msg_size\",\"size\":200,\"order\":\"asc\",\"orderBy\":\"_term\"}},{\"id\":\"5\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"rx_msg_size\",\"size\":200,\"order\":\"asc\",\"orderBy\":\"_term\"}},{\"id\":\"6\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"mean_latency\",\"size\":5,\"order\":\"asc\",\"orderBy\":\"_term\"}},{\"id\":\"7\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"local_cpu_util\",\"size\":20,\"order\":\"desc\",\"orderBy\":\"_term\"}},{\"id\":\"8\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"remote_cpu_util\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"_term\"}}],\"listeners\":{}}", - "uiStateJSON": "{}", - "description": "", - "version": 1, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"index\":\"bottlenecks\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}" - } -} + # Create testing data in line graph + # Create testing data in line graph + with open(dashboard_dir + 'posca_system_bandwidth_line_data.json')\ + as line_data: + doc = json.load(line_data) + res = es.index( + index=".kibana", + doc_type="visualization", + id="system_bandwidth_line-date", + body=doc) + if res['created'] == "True": + LOG.info("system_bandwidth_line-date visualization has created") + else: + LOG.info("system_bandwidth_line-date visualization has existed") -res = es.index( - index=".kibana", doc_type="visualization", id="system_bandwidth_terms_data", body=doc) -print(res['created']) + # Create comparison results in line chart + with open(dashboard_dir + 'posca_system_bandwidth_line_char.json')\ + as line_char: + doc = json.load(line_char) + res = es.index( + index=".kibana", + doc_type="visualization", + id="system_bandwidth_line-char", + body=doc) + if res['created'] == "True": + LOG.info("system_bandwidth_line-char visualization has created") + else: + LOG.info("system_bandwidth_line-char visualization has existed") -doc = { - "title": "system_bandwidth_dashboard", - "hits": 0, - "description": "", - "panelsJSON": "[{\"id\":\"system_bandwidth_line-char\",\"type\":\"visualization\",\"panelIndex\":3,\"size_x\":7,\"size_y\":4,\"col\":1,\"row\":1},{\"id\":\"system_bandwidth_line-date\",\"type\":\"visualization\",\"panelIndex\":4,\"size_x\":7,\"size_y\":4,\"col\":1,\"row\":5},{\"id\":\"system_bandwidth_terms_data\",\"type\":\"visualization\",\"panelIndex\":5,\"size_x\":5,\"size_y\":8,\"col\":8,\"row\":1}]", - "optionsJSON": "{\"darkTheme\":false}", - "uiStateJSON": "{}", - "version": 1, - "kibanaSavedObjectMeta": { - "searchSourceJSON": "{\"filter\":[{\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}}}]}" - } -} + # Create monitoring data in table + with open(dashboard_dir + 'posca_system_bandwidth_terms_data.json')\ + as terms_char: + doc = json.load(terms_char) + res = es.index(index=".kibana", doc_type="visualization", + id="system_bandwidth_terms_data", body=doc) + if res['created'] == "True": + LOG.info("system_bandwidth_terms_data visualization has created") + else: + LOG.info("system_bandwidth_terms_data visualization has existed") -res = es.index( - index=".kibana", doc_type="dashboard", id="system_bandwidth_dashboard", body=doc) -print(res['created']) + # Create dashboard + with open(dashboard_dir + 'posca_system_bandwidth_dashboard.json')\ + as dashboard: + doc = json.load(dashboard) + res = es.index( + index=".kibana", + doc_type="dashboard", + id="system_bandwidth_dashboard", + body=doc) + if res['created'] == "True": + LOG.info("system_bandwidth dashboard has created") + else: + LOG.info("system_bandwidth dashboard has existed")