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(