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

Fix rally-annotations index creation #1747

Merged
merged 2 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 6 additions & 4 deletions esrally/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def delete(self, index, id):
def get_index(self, name):
return self.guarded(self._client.indices.get, name=name)

def create_index(self, index, body=None):
return self.guarded(self._client.indices.create, index=index, body=body, ignore=400)
def create_index(self, index):
return self.guarded(self._client.indices.create, index=index, ignore=400)
gbanasiak marked this conversation as resolved.
Show resolved Hide resolved

def exists(self, index):
return self.guarded(self._client.indices.exists, index=index)
Expand All @@ -94,6 +94,7 @@ def search(self, index, body):
def guarded(self, target, *args, **kwargs):
# pylint: disable=import-outside-toplevel
import elasticsearch
import elasticsearch.helpers
from elastic_transport import ApiError, TransportError

max_execution_count = 10
Expand Down Expand Up @@ -1773,8 +1774,9 @@ def _at_midnight(race_timestamp):
)
else:
if not self.client.exists(index="rally-annotations"):
body = self.index_template_provider.annotations_template()
self.client.create_index(index="rally-annotations", body=body)
# create or overwrite template on index creation
self.client.put_template("rally-annotations", self.index_template_provider.annotations_template())
self.client.create_index(index="rally-annotations")
self.client.index(
index="rally-annotations",
id=annotation_id,
Expand Down
4 changes: 3 additions & 1 deletion esrally/resources/annotation-template.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"index_patterns": ["rally-annotations"],
"settings": {
"number_of_shards": 1
"index":{
}
},
"mappings": {
"dynamic_templates": [
Expand Down
5 changes: 5 additions & 0 deletions tests/metrics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2607,6 +2607,7 @@ def test_primary_and_replica_shard_count_specified_index_template_update(self):
_index_template_provider = metrics.IndexTemplateProvider(self.cfg)

templates = [
_index_template_provider.annotations_template(),
_index_template_provider.metrics_template(),
_index_template_provider.races_template(),
_index_template_provider.results_template(),
Expand All @@ -2627,6 +2628,7 @@ def test_primary_shard_count_specified_index_template_update(self):
_index_template_provider = metrics.IndexTemplateProvider(self.cfg)

templates = [
_index_template_provider.annotations_template(),
_index_template_provider.metrics_template(),
_index_template_provider.races_template(),
_index_template_provider.results_template(),
Expand All @@ -2649,6 +2651,7 @@ def test_replica_shard_count_specified_index_template_update(self):
_index_template_provider = metrics.IndexTemplateProvider(self.cfg)

templates = [
_index_template_provider.annotations_template(),
_index_template_provider.metrics_template(),
_index_template_provider.races_template(),
_index_template_provider.results_template(),
Expand All @@ -2672,6 +2675,7 @@ def test_primary_shard_count_less_than_one(self):
with pytest.raises(exceptions.SystemSetupError) as ctx:
# pylint: disable=unused-variable
templates = [
_index_template_provider.annotations_template(),
_index_template_provider.metrics_template(),
_index_template_provider.races_template(),
_index_template_provider.results_template(),
Expand All @@ -2693,6 +2697,7 @@ def test_primary_and_replica_shard_counts_passed_as_strings(self):
_index_template_provider = metrics.IndexTemplateProvider(self.cfg)

templates = [
_index_template_provider.annotations_template(),
_index_template_provider.metrics_template(),
_index_template_provider.races_template(),
_index_template_provider.results_template(),
Expand Down