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 82ae6c1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion namespaces/_default_.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,5 @@ _index_type_:
type: keyword
example: project.my-cool-project-in-lab04.748e92c2-70d7-11e9-b387-000d3af2d83b.2019.05.09
description: |
Index name in which this message will be stored within the elastic search.
Index name in which this message will be stored within the Elasticsearch.
The value of this field is generated based on the source of the message.
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 82ae6c1

Please sign in to comment.