Skip to content

Commit

Permalink
adjust E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kvch committed Nov 23, 2020
1 parent 8b24b6c commit 6ce09da
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
10 changes: 9 additions & 1 deletion libbeat/tests/system/idxmgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,19 @@ def assert_index_template_not_loaded(self, template):
with pytest.raises(NotFoundError):
self._client.transport.perform_request('GET', '/_template/' + template)

def assert_index_template_loaded(self, template):
def assert_legacy_index_template_loaded(self, template):
resp = self._client.transport.perform_request('GET', '/_template/' + template)
assert template in resp
assert "lifecycle" not in resp[template]["settings"]["index"]

def assert_index_template_loaded(self, template):
resp = self._client.transport.perform_request('GET', '/_index_template/' + template)
found = False
for index_template in resp['index_templates']:
if index_template['name'] == template:
found = True
assert found

def assert_ilm_template_loaded(self, template, policy, alias):
resp = self._client.transport.perform_request('GET', '/_template/' + template)
assert resp[template]["settings"]["index"]["lifecycle"]["name"] == policy
Expand Down
8 changes: 4 additions & 4 deletions libbeat/tests/system/test_cmd_setup_index_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_setup_ilm_disabled(self):
"-E", "setup.ilm.enabled=false"])

assert exit_code == 0
self.idxmgmt.assert_index_template_loaded(self.index_name)
self.idxmgmt.assert_legacy_index_template_loaded(self.index_name)
self.idxmgmt.assert_alias_not_created(self.alias_name)
self.idxmgmt.assert_policy_not_created(self.policy_name)

Expand Down Expand Up @@ -242,7 +242,7 @@ def test_setup_template_name_and_pattern_on_ilm_disabled(self):
"-E", "setup.template.pattern=" + self.custom_template + "*"])

assert exit_code == 0
self.idxmgmt.assert_index_template_loaded(self.custom_template)
self.idxmgmt.assert_legacy_index_template_loaded(self.custom_template)
self.idxmgmt.assert_index_template_index_pattern(self.custom_template, [self.custom_template + "*"])
self.idxmgmt.assert_alias_not_created(self.alias_name)
self.idxmgmt.assert_policy_not_created(self.policy_name)
Expand All @@ -261,7 +261,7 @@ def test_setup_template_with_opts(self):
"-E", "setup.template.settings.index.number_of_shards=2"])

assert exit_code == 0
self.idxmgmt.assert_index_template_loaded(self.index_name)
self.idxmgmt.assert_legacy_index_template_loaded(self.index_name)

# check that settings are overwritten
resp = self.es.transport.perform_request('GET', '/_template/' + self.index_name)
Expand All @@ -284,7 +284,7 @@ def test_setup_overwrite_template_on_ilm_policy_created(self):
"-E", "setup.template.name=" + self.custom_alias,
"-E", "setup.template.pattern=" + self.custom_alias + "*"])
assert exit_code == 0
self.idxmgmt.assert_index_template_loaded(self.custom_alias)
self.idxmgmt.assert_legacy_index_template_loaded(self.custom_alias)
self.idxmgmt.assert_policy_not_created(self.policy_name)

# ensure ilm policy is created, triggering overwriting existing template
Expand Down
4 changes: 2 additions & 2 deletions libbeat/tests/system/test_ilm.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_ilm_disabled(self):
self.wait_until(lambda: self.log_contains("PublishEvents: 1 events have been published"))
proc.check_kill_and_wait()

self.idxmgmt.assert_index_template_loaded(self.index_name)
self.idxmgmt.assert_legacy_index_template_loaded(self.index_name)
self.idxmgmt.assert_alias_not_created(self.alias_name)
self.idxmgmt.assert_policy_not_created(self.policy_name)

Expand Down Expand Up @@ -234,7 +234,7 @@ def test_setup_ilm_disabled(self):
"-E", "setup.ilm.enabled=false"])

assert exit_code == 0
self.idxmgmt.assert_index_template_loaded(self.index_name)
self.idxmgmt.assert_legacy_index_template_loaded(self.index_name)
self.idxmgmt.assert_alias_not_created(self.alias_name)
self.idxmgmt.assert_policy_not_created(self.policy_name)

Expand Down
4 changes: 2 additions & 2 deletions libbeat/tests/system/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def test_setup_template_with_opts(self):
"-E", "setup.template.settings.index.number_of_shards=2"])

assert exit_code == 0
self.idxmgmt.assert_index_template_loaded(self.index_name)
self.idxmgmt.assert_legacy_index_template_loaded(self.index_name)

# check that settings are overwritten
resp = self.es.transport.perform_request('GET', '/_template/' + self.index_name)
Expand Down Expand Up @@ -305,7 +305,7 @@ def test_template_created_on_ilm_policy_created(self):
"-E", "setup.template.name=" + self.custom_alias,
"-E", "setup.template.pattern=" + self.custom_alias + "*"])
assert exit_code == 0
self.idxmgmt.assert_index_template_loaded(self.custom_alias)
self.idxmgmt.assert_legacy_index_template_loaded(self.custom_alias)
self.idxmgmt.assert_policy_not_created(self.policy_name)

# ensure ilm policy is created, triggering overwriting existing template
Expand Down

0 comments on commit 6ce09da

Please sign in to comment.