-def _get_pods_and_scenarios(project_name, case_name, installer):
- query_json = json.JSONEncoder().encode({
- "query": {
- "bool": {
- "must": [
- {"match_all": {}}
- ],
- "filter": [
- {"match": {"installer": {"query": installer, "type": "phrase"}}},
- {"match": {"project_name": {"query": project_name, "type": "phrase"}}},
- {"match": {"case_name": {"query": case_name, "type": "phrase"}}}
- ]
- }
- }
- })
-
- elastic_data = elastic_access.get_docs(urlparse.urljoin(CONF.es_url, '/test_results/mongo2elastic'),
- CONF.es_creds,
- query_json)
-
- pods_and_scenarios = {}
-
- for data in elastic_data:
- pod = data['pod_name']
- if pod in pods_and_scenarios:
- pods_and_scenarios[pod].add(data['scenario'])
- else:
- pods_and_scenarios[pod] = {data['scenario']}
-
- if 'all' in pods_and_scenarios:
- pods_and_scenarios['all'].add(data['scenario'])
- else:
- pods_and_scenarios['all'] = {data['scenario']}
-
- return pods_and_scenarios
-
-
-def construct_dashboards():
- """
- iterate over testcase and installer
- 1. get available pods for each testcase/installer pair
- 2. get available scenario for each testcase/installer/pod tuple
- 3. construct KibanaInput and append
-
- :return: list of KibanaDashboards
- """
- dashboards = []
- for project, case_dicts in testcases.testcases_yaml.items():
- for case in case_dicts:
- case_name = case.get('name')
- vis_ps = case.get('visualizations')
- family = case.get('test_family')
- for installer in _installers:
- pods_and_scenarios = _get_pods_and_scenarios(project, case_name, installer)
- for vis_p in vis_ps:
- for pod, scenarios in pods_and_scenarios.iteritems():
- vissAssember = VisualizationsAssembler(project,
- case_name,
- installer,
- pod,
- scenarios,
- vis_p,
- CONF.es_url,
- CONF.es_creds)
- dashboardAssembler = DashboardAssembler(project,
- case_name,
- family,
+class KibanaConstructor(object):
+ def __init__(self):
+ super(KibanaConstructor, self).__init__()
+ self.js_dict = {}
+
+ def construct(self):
+ for project, case_dicts in testcases.testcases_yaml.items():
+ for case in case_dicts:
+ self._construct_by_case(project, case)
+ return self
+
+ def _construct_by_case(self, project, case):
+ case_name = case.get('name')
+ vis_ps = case.get('visualizations')
+ family = case.get('test_family')
+ for vis_p in vis_ps:
+ self._construct_by_vis(project, case_name, family, vis_p)
+
+ def _construct_by_vis(self, project, case, family, vis_p):
+ for installer in _installers:
+ pods_and_scenarios = self._get_pods_and_scenarios(project,
+ case,
+ installer)
+ for pod, scenarios in pods_and_scenarios.iteritems():
+ visualizations = self._construct_visualizations(project,
+ case,