diff --git a/esrally/telemetry.py b/esrally/telemetry.py index 0ce294339..2ffff9827 100644 --- a/esrally/telemetry.py +++ b/esrally/telemetry.py @@ -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 @@ -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) diff --git a/tests/telemetry_test.py b/tests/telemetry_test.py index 47d5a0d6c..101877ffe 100644 --- a/tests/telemetry_test.py +++ b/tests/telemetry_test.py @@ -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")