Skip to content

Commit

Permalink
Fix test for new field viaq_index_name
Browse files Browse the repository at this point in the history
Closes #115
  • Loading branch information
lukas-vlcek committed Nov 13, 2019
1 parent 24805e0 commit e73c714
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion scripts/compare_against_released_patterns_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ def _support_index_pattern_fields_field_only(self, released_file_URL, es_version
generated_fields = [item for item in generated_fields if not item["name"] == "systemd.t.LINE_BREAK"]
generated_fields = [item for item in generated_fields if not item["name"] == "systemd.t.STREAM_ID"]
generated_fields = [item for item in generated_fields if not item["name"] == "systemd.t.SYSTEMD_INVOCATION_ID"]
# ======================

# https://github.com/ViaQ/elasticsearch-templates/pull/115
generated_fields = [item for item in generated_fields if not item["name"] == "viaq_index_name"]
# ======================

# ---- wget
print('\nDownloading released index pattern file for comparison:')
Expand Down
14 changes: 12 additions & 2 deletions scripts/compare_against_released_templates_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ def _remove_all_field(data, es_version):
_idx_type = supported.index_type_name(es_version)
if "_all" in data["mappings"][_idx_type]:
del data["mappings"][_idx_type]["_all"]


@staticmethod
def _remove_viaq_index_name_field(generated_json, es_version):
# Remove 'viaq_index_name' field. It was introduced after support for ES6.x was added.
# https://github.com/ViaQ/elasticsearch-templates/pull/115
_idx_type = supported.index_type_name(es_version)
if "viaq_index_name" in generated_json["mappings"][_idx_type]["properties"]:
del generated_json["mappings"][_idx_type]["properties"]["viaq_index_name"]

@staticmethod
def _generate_json_index_template(args, es_version):
Expand Down Expand Up @@ -156,11 +163,14 @@ def _support_compare_index_templates(self, es_version, args, json_url):
del generated_json["mappings"][_idx_type]["properties"]["systemd"]["properties"]["t"]["properties"]["STREAM_ID"]
del generated_json["mappings"][_idx_type]["properties"]["systemd"]["properties"]["t"]["properties"]["SYSTEMD_INVOCATION_ID"]

self._remove_viaq_index_name_field(generated_json, es_version)

elif es_version == supported._es5x:
pass
self._remove_viaq_index_name_field(generated_json, es_version)

elif es_version == supported._es6x:
self._remove_all_field(generated_json, es_version)
self._remove_viaq_index_name_field(generated_json, es_version)
# ======================

generated_index_template = self._sort(generated_json)
Expand Down

0 comments on commit e73c714

Please sign in to comment.