Skip to content

Commit

Permalink
Override serverless cluster version (#1818)
Browse files Browse the repository at this point in the history
Make Rally report `serverless` version instead of dummy `8.11.0` version
when run against Elastic Serverless clusters. With `serverless` version,
Rally track branch selection defaults to `master`.
  • Loading branch information
gbanasiak authored Jan 8, 2024
1 parent 6611f67 commit df49d4d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/serverless.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The Serverless detection and the skip manifests through the following messages o
[INFO] Race id is [d9d82d3f-dd74-4af0-90ea-8bdd449c824c]
[INFO] Detected Elasticsearch Serverless mode with operator=[False].
[INFO] Excluding [check-cluster-health], [force-merge], [wait-until-merges-finish], [index-stats], [node-stats] as challenge [append-no-conflicts] is run on serverless.
[INFO] Racing on track [geonames], challenge [append-no-conflicts] and car ['external'] with version [8.11.0].
[INFO] Racing on track [geonames], challenge [append-no-conflicts] and car ['external'] with version [serverless].
[..]

The automatic skip does not apply to the following tasks:
Expand Down
6 changes: 4 additions & 2 deletions esrally/client/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,15 @@ def cluster_distribution_version(hosts, client_options, client_factory=EsClientF
version = es.info()["version"]

version_build_flavor = version.get("build_flavor", "oss")
# build hash will only be available for serverless if the client has operator privs
# if build hash is not available default to build flavor
version_build_hash = version.get("build_hash", version_build_flavor)
# version number does not exist for serverless
# if version number is not available default to build flavor
version_number = version.get("number", version_build_flavor)

serverless_operator = False
if versions.is_serverless(version_build_flavor):
# overwrite static serverless version number
version_number = "serverless"
authentication_info = es.perform_request(method="GET", path="/_security/_authenticate")
serverless_operator = authentication_info.body.get("operator", False)

Expand Down
12 changes: 8 additions & 4 deletions esrally/driver/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,10 +724,14 @@ def prepare_benchmark(self, t):
else:
self.wait_for_rest_api(es_clients)
self.driver_actor.cluster_details = self.retrieve_cluster_info(es_clients)
if serverless_mode and serverless_operator:
build_hash = self.retrieve_build_hash_from_nodes_info(es_clients)
self.logger.info("Retrieved actual build hash [%s] from serverless cluster.", build_hash)
self.driver_actor.cluster_details["version"]["build_hash"] = build_hash
if serverless_mode:
# overwrite static serverless version number
self.driver_actor.cluster_details["version"]["number"] = "serverless"
if serverless_operator:
# overwrite build hash if running as operator
build_hash = self.retrieve_build_hash_from_nodes_info(es_clients)
self.logger.info("Retrieved actual build hash [%s] from serverless cluster.", build_hash)
self.driver_actor.cluster_details["version"]["build_hash"] = build_hash

# Avoid issuing any requests to the target cluster when static responses are enabled. The results
# are not useful and attempts to connect to a non-existing cluster just lead to exception traces in logs.
Expand Down
5 changes: 3 additions & 2 deletions esrally/driver/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import ijson

from esrally import exceptions, track
from esrally.utils import convert
from esrally.utils.versions import Version

# Mapping from operation type to specific runner
Expand Down Expand Up @@ -175,8 +176,8 @@ def __init__(self, *args, config=None, **kwargs):
self.serverless_mode = False
self.serverless_operator = False
if config:
self.serverless_mode = config.opts("driver", "serverless.mode", mandatory=False, default_value=False)
self.serverless_operator = config.opts("driver", "serverless.operator", mandatory=False, default_value=False)
self.serverless_mode = convert.to_bool(config.opts("driver", "serverless.mode", mandatory=False, default_value=False))
self.serverless_operator = convert.to_bool(config.opts("driver", "serverless.operator", mandatory=False, default_value=False))

async def __aenter__(self):
return self
Expand Down
4 changes: 2 additions & 2 deletions tests/driver/driver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@ def test_prepare_serverless_benchmark(self, mock_method):
d = driver.Driver(driver_actor, self.cfg, es_client_factory_class=self.StaticServerlessClientFactory)
d.prepare_benchmark(t=self.track)

# was build hash determined correctly?
# was build hash and version determined correctly?
assert driver_actor.cluster_details == {
"name": "serverless",
"cluster_name": "serverless",
"cluster_uuid": "4bbPT0Z6SsuODSz_vG1umA",
"version": {
"number": "8.10.0",
"number": "serverless", # <--- THIS
"build_flavor": "serverless",
"build_type": "docker",
"build_hash": "5f626ea4014dc029b8ae3f0bca06944975bf2d80", # <--- THIS
Expand Down

0 comments on commit df49d4d

Please sign in to comment.