Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore HTTP 404 consistently in runners #1691

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions esrally/driver/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,7 @@ async def __call__(self, es, params):
try:
for index_name in indices:
if not only_if_exists:
await es.indices.delete(index=index_name, params=request_params)
await es.indices.delete(index=index_name, ignore=[404], params=request_params)
ops += 1
elif only_if_exists and await es.indices.exists(index=index_name):
self.logger.info("Index [%s] already exists. Deleting it.", index_name)
Expand Down Expand Up @@ -1602,7 +1602,7 @@ async def __call__(self, es, params):
try:
for template_name, delete_matching_indices, index_pattern in template_names:
if not only_if_exists:
await es.indices.delete_template(name=template_name, params=request_params)
await es.indices.delete_template(name=template_name, ignore=[404], params=request_params)
ops_count += 1
elif only_if_exists and await es.indices.exists_template(name=template_name):
self.logger.info("Index template [%s] already exists. Deleting it.", template_name)
Expand Down Expand Up @@ -1976,7 +1976,7 @@ class DeleteSnapshotRepository(Runner):
"""

async def __call__(self, es, params):
await es.snapshot.delete_repository(repository=mandatory(params, "repository", repr(self)))
await es.snapshot.delete_repository(repository=mandatory(params, "repository", repr(self)), ignore=[404])

def __repr__(self, *args, **kwargs):
return "delete-snapshot-repository"
Expand Down Expand Up @@ -2677,7 +2677,7 @@ async def __call__(self, es, params):
timeout = request_params.get("timeout", None)

await es.ilm.delete_lifecycle(
name=policy_name, error_trace=error_trace, filter_path=filter_path, master_timeout=master_timeout, timeout=timeout
name=policy_name, error_trace=error_trace, filter_path=filter_path, master_timeout=master_timeout, timeout=timeout, ignore=[404]
)
return {
"weight": 1,
Expand Down
14 changes: 8 additions & 6 deletions tests/driver/runner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2782,8 +2782,8 @@ async def test_deletes_all_indices(self, es):
)
es.indices.delete.assert_has_awaits(
[
mock.call(index="indexA", params=params["request-params"]),
mock.call(index="indexB", params=params["request-params"]),
mock.call(index="indexA", params=params["request-params"], ignore=[404]),
mock.call(index="indexB", params=params["request-params"], ignore=[404]),
]
)
assert es.indices.exists.call_count == 0
Expand Down Expand Up @@ -2920,9 +2920,9 @@ async def test_deletes_all_index_templates(self, es):

es.indices.delete_template.assert_has_awaits(
[
mock.call(name="templateA", params=params["request-params"]),
mock.call(name="templateB", params=params["request-params"]),
mock.call(name="templateC", params=params["request-params"]),
mock.call(name="templateA", ignore=[404], params=params["request-params"]),
mock.call(name="templateB", ignore=[404], params=params["request-params"]),
mock.call(name="templateC", ignore=[404], params=params["request-params"]),
]
)
es.indices.delete.assert_has_awaits(
Expand Down Expand Up @@ -3777,7 +3777,7 @@ async def test_delete_snapshot_repository(self, es):
r = runner.DeleteSnapshotRepository()
await r(es, params)

es.snapshot.delete_repository.assert_called_once_with(repository="backups")
es.snapshot.delete_repository.assert_called_once_with(repository="backups", ignore=[404])


class TestCreateSnapshotRepository:
Expand Down Expand Up @@ -5222,6 +5222,7 @@ async def test_delete_ilm_policy_with_request_params(self, es):
timeout=self.params["request-params"].get("timeout"),
error_trace=None,
filter_path=None,
ignore=[404],
)

@mock.patch("elasticsearch.Elasticsearch")
Expand All @@ -5244,6 +5245,7 @@ async def test_delete_ilm_policy_without_request_params(self, es):
timeout=None,
error_trace=None,
filter_path=None,
ignore=[404],
)


Expand Down