Skip to content

Commit 5bfe2ba

Browse files
committed
Avoid randomization bug in FeatureAwareTests
We compute a random version and later try to compute the version prior that random version. If the random version is the earliest version in our list of versions then it, by definition, does not have a previous version. Yet trying to find its previous is someting we do and so the test fails. This commit adds a version check to the randomization so that we do not select the earliest version in our list.
1 parent 3670a2a commit 5bfe2ba

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

server/src/test/java/org/elasticsearch/cluster/FeatureAwareTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public Optional<String> getRequiredFeature() {
107107
}
108108

109109
public void testVersion() {
110-
final Version version = VersionUtils.randomVersion(random());
110+
final Version version = randomValueOtherThan(VersionUtils.getFirstVersion(), () -> VersionUtils.randomVersion(random()));
111111
for (final Custom custom : Arrays.asList(new NoRequiredFeatureCustom(version), new RequiredFeatureCustom(version))) {
112112
{
113113
final BytesStreamOutput out = new BytesStreamOutput();

0 commit comments

Comments
 (0)