Skip to content

Commit

Permalink
Override serverless cluster version in metrics (#1819)
Browse files Browse the repository at this point in the history
Changes telemetry to report `serverless` version instead of `8.11.0`
version in case of Elastic Serverless clusters. This aligns telemetry
output with #1818.
  • Loading branch information
gbanasiak authored Jan 10, 2024
1 parent df49d4d commit 21ae64a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
7 changes: 5 additions & 2 deletions esrally/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from esrally import exceptions, metrics, time
from esrally.metrics import MetaInfoScope
from esrally.utils import console, io, opts, process, serverless, sysstats
from esrally.utils import console, io, opts, process, serverless, sysstats, versions
from esrally.utils.versions import Version


Expand Down Expand Up @@ -1814,8 +1814,11 @@ def on_benchmark_start(self):
revision = client_info["version"].get("build_hash", distribution_flavor)
if self.revision_override:
revision = self.revision_override
# build version does not exist for serverless
# if version number is not available default to build flavor
distribution_version = client_info["version"].get("number", distribution_flavor)
# overwrite static serverless version number
if versions.is_serverless(distribution_flavor):
distribution_version = "serverless"
self.metrics_store.add_meta_info(metrics.MetaInfoScope.cluster, None, "source_revision", revision)
self.metrics_store.add_meta_info(metrics.MetaInfoScope.cluster, None, "distribution_version", distribution_version)
self.metrics_store.add_meta_info(metrics.MetaInfoScope.cluster, None, "distribution_flavor", distribution_flavor)
Expand Down
48 changes: 48 additions & 0 deletions tests/telemetry_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3441,6 +3441,54 @@ def test_resilient_if_error_response(self, metrics_store_add_meta_info):

assert metrics_store_add_meta_info.call_count == 0

@mock.patch("esrally.metrics.EsMetricsStore.add_meta_info")
def test_static_serverless_version_overwrite(self, metrics_store_add_meta_info):
cluster_info = {
"version": {
"build_hash": "00000000",
"number": "8.11.0",
"build_flavor": "serverless",
},
}

cfg = create_config()
client = Client(info=cluster_info)
metrics_store = metrics.EsMetricsStore(cfg)
env_device = telemetry.ClusterEnvironmentInfo(client, metrics_store, None)
t = telemetry.Telemetry(cfg, devices=[env_device])
t.on_benchmark_start()
calls = [
mock.call(metrics.MetaInfoScope.cluster, None, "source_revision", "00000000"),
mock.call(metrics.MetaInfoScope.cluster, None, "distribution_version", "serverless"),
mock.call(metrics.MetaInfoScope.cluster, None, "distribution_flavor", "serverless"),
]

metrics_store_add_meta_info.assert_has_calls(calls)

@mock.patch("esrally.metrics.EsMetricsStore.add_meta_info")
def test_revision_override(self, metrics_store_add_meta_info):
cluster_info = {
"version": {
"build_hash": "00000000",
"number": "8.11.0",
"build_flavor": "serverless",
},
}

cfg = create_config()
client = Client(info=cluster_info)
metrics_store = metrics.EsMetricsStore(cfg)
env_device = telemetry.ClusterEnvironmentInfo(client, metrics_store, "abc123")
t = telemetry.Telemetry(cfg, devices=[env_device])
t.on_benchmark_start()
calls = [
mock.call(metrics.MetaInfoScope.cluster, None, "source_revision", "abc123"),
mock.call(metrics.MetaInfoScope.cluster, None, "distribution_version", "serverless"),
mock.call(metrics.MetaInfoScope.cluster, None, "distribution_flavor", "serverless"),
]

metrics_store_add_meta_info.assert_has_calls(calls)


class TestNodeEnvironmentInfo:
@mock.patch("esrally.metrics.EsMetricsStore.add_meta_info")
Expand Down

0 comments on commit 21ae64a

Please sign in to comment.