From 11c80c02b3c782faf317a83ede1fd9ba9e13be05 Mon Sep 17 00:00:00 2001 From: Masco Date: Mon, 7 Oct 2024 13:25:19 +0530 Subject: [PATCH] make metadata indexing optional while indexing the rally results to ES make the metadata indexing optional. now we can remove the metadata field in browbeat-config.yml and disable the metadata indexing. Change-Id: I68fcf4153f79bc321d920203525fea228fa0e996 --- browbeat/elastic.py | 30 ++++++++++++++---------------- browbeat/schema/browbeat.yml | 2 +- browbeat/tools.py | 2 +- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/browbeat/elastic.py b/browbeat/elastic.py index 2174fde1e..102becb9d 100644 --- a/browbeat/elastic.py +++ b/browbeat/elastic.py @@ -73,22 +73,20 @@ class Elastic(object): return json_data def combine_metadata(self, result): - if (self.config['elasticsearch']['metadata_files'] is not None and - len(self.config['elasticsearch']['metadata_files']) > 0): - meta = self.config['elasticsearch']['metadata_files'] - for _meta in meta: - try: - with open(_meta['file']) as jdata: - result[_meta['name']] = json.load(jdata) - except Exception: - self.logger.error( - "Error loading Metadata file : {}".format( - _meta['file'])) - self.logger.error( - "Please make sure the metadata file exists and" - " is valid JSON or run the playbook ansible/gather/site.yml" - " before running the Browbeat test Suite") - sys.exit(1) + meta = self.config['elasticsearch'].get('metadata_files', []) or [] + for _meta in meta: + try: + with open(_meta['file']) as jdata: + result[_meta['name']] = json.load(jdata) + except Exception: + self.logger.error( + "Error loading Metadata file : {}".format( + _meta['file'])) + self.logger.error( + "Please make sure the metadata file exists and" + " is valid JSON or run the playbook ansible/gather/site.yml" + " before running the Browbeat test Suite") + sys.exit(1) return result # Used to transform the cache dict into an elastic insertable iterable diff --git a/browbeat/schema/browbeat.yml b/browbeat/schema/browbeat.yml index 5e1377197..8dbf78673 100644 --- a/browbeat/schema/browbeat.yml +++ b/browbeat/schema/browbeat.yml @@ -62,7 +62,7 @@ mapping: required: True metadata_files: type: seq - required: True + required: False sequence: - type: map mapping: diff --git a/browbeat/tools.py b/browbeat/tools.py index c647b6b1a..8cf28b3ea 100644 --- a/browbeat/tools.py +++ b/browbeat/tools.py @@ -70,7 +70,7 @@ class Tools(object): workloads.run_workload(copy.deepcopy(workload), run_iteration) def check_metadata(self): - meta = self.config['elasticsearch']['metadata_files'] + meta = self.config['elasticsearch'].get('metadata_files', []) or [] for _meta in meta: if not os.path.isfile(_meta['file']): self.logger.info(