Skip to content

Commit

Permalink
Address PR comment
Browse files Browse the repository at this point in the history
  • Loading branch information
dliappis committed Feb 2, 2021
1 parent 3ae2fa4 commit 861a176
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/track.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Rally implements a fallback logic in order of specificity up to the minor versio
Assuming the track repository has several branches, the order is:

1. Exact branch matches; e.g. if the repo contains branches `7`, `7.1` and `7.10.2` and Elasticsearch version is `7.10.2`, `7.10.2` will be checked out.
2. Nearest minor matches; e.g. if the repo contains branches `7`, `7.1` and `7.10` and Elasticsearch version is `7.10.2`, `7.10` will be checked out. Alternatively if version is `7.9`, `7.1` will be checked out.
2. Nearest prior minor matches; e.g. if the repo contains branches `7`, `7.1` and `7.10` and Elasticsearch version is `7.10.2`, `7.10` will be checked out. Alternatively if version is `7.9`, `7.1` will be checked out.
3. Major branch matches; e.g. if the repo contains branches `7` and `7.10` and Elasticsearch version is `7.1`, `7` will be checked out.
4. Failing everything, `master` will be elected, e.g. if the repo contains branches `6`, `7` and `master` and Elasticsearch version is `8.1.0`, `master` will be checked out.

Expand Down
4 changes: 2 additions & 2 deletions esrally/utils/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def best_match(available_alternatives, distribution_version):
and the provided alternatives reflect this pattern.
Best matches for distribution_version from available_alternatives may be:
1. exact matches of major.minor
2. nearest minor within the same major
2. nearest prior minor within the same major
3. major version
4. as a last resort, `master`.
Expand All @@ -132,7 +132,7 @@ def best_match(available_alternatives, distribution_version):
for version, version_type in versions.all_versions:
if version in available_alternatives:
return version
# match nearest minor
# match nearest prior minor
if version_type == "with_minor" and (latest_minor := latest_bounded_minor(available_alternatives, versions)):
if latest_minor:
return f"{versions.major}.{latest_minor}"
Expand Down
10 changes: 5 additions & 5 deletions tests/utils/versions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_latest_bounded_minor(self, seed):

assert versions.latest_bounded_minor(alternatives, versions.VersionVariants("7.6.3")) == 2
assert versions.latest_bounded_minor(alternatives, versions.VersionVariants("7.12.3")) == 10,\
"Closest alternative with major.minor, skip alternatives with major.minor.patch"
"Nearest alternative with major.minor, skip alternatives with major.minor.patch"
assert versions.latest_bounded_minor(alternatives, versions.VersionVariants("7.11.2")) == 10,\
"Skips all alternatives with major.minor.patch, even if exact match"
assert versions.latest_bounded_minor(alternatives, versions.VersionVariants("7.1.0")) is None,\
Expand Down Expand Up @@ -125,16 +125,16 @@ def test_find_best_match(self):
"Best match for specific minor version"

assert versions.best_match(["7", "7.11", "7.2", "5", "6", "master"], "7.12.0") == "7.11",\
"If no exact match, best match is the closest minor"
"If no exact match, best match is the nearest prior minor"

assert versions.best_match(["7", "7.11", "7.2", "5", "6", "master"], "7.3.0") == "7.2",\
"If no exact match, best match is the closest minor"
"If no exact match, best match is the nearest prior minor"

assert versions.best_match(["7", "7.11", "7.2", "5", "6", "master"], "7.10.0") == "7.2", \
"If no exact match, best match is the closest minor"
"If no exact match, best match is the nearest prior minor"

assert versions.best_match(["7", "7.1", "7.11.1", "7.11.0", "7.2", "5", "6", "master"], "7.12.0") == "7.2",\
"Patch or patch-suffix branches are not supported and ignored, best match is closest minor"
"Patch or patch-suffix branches are not supported and ignored, best match is nearest prior minor"

assert versions.best_match(["7", "7.11", "7.2", "5", "6", "master"], "7.1.0") == "7",\
"If no exact match and no minor match, next best match is major version"

0 comments on commit 861a176

Please sign in to comment.