Skip to content

Commit

Permalink
Update allowed inferred versions to include 8.10 (#98578)
Browse files Browse the repository at this point in the history
Update some tests that could pass CURRENT to infer versions to real versions
  • Loading branch information
thecoop authored Aug 17, 2023
1 parent 57d6b9a commit 6b8cb58
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static VersionInformation inferVersions(Version nodeVersion) {
return null;
} else if (nodeVersion.equals(Version.CURRENT)) {
return CURRENT;
} else if (nodeVersion.before(Version.V_8_10_0)) {
} else if (nodeVersion.onOrBefore(Version.V_8_10_0)) {
return new VersionInformation(
nodeVersion,
IndexVersion.fromId(nodeVersion.minimumIndexCompatibilityVersion().id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.IndexingPressure;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.indices.EmptySystemIndices;
import org.elasticsearch.indices.SystemIndexDescriptorUtils;
import org.elasticsearch.indices.SystemIndices;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.test.index.IndexVersionUtils;
import org.elasticsearch.test.transport.CapturingTransport;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
Expand Down Expand Up @@ -107,7 +109,11 @@ public void setUp() throws Exception {
super.setUp();
threadPool = new TestThreadPool(getClass().getName());
DiscoveryNode discoveryNode = DiscoveryNodeUtils.builder("node")
.version(VersionUtils.randomCompatibleVersion(random(), Version.CURRENT))
.version(
VersionUtils.randomCompatibleVersion(random(), Version.CURRENT),
IndexVersion.MINIMUM_COMPATIBLE,
IndexVersionUtils.randomCompatibleVersion(random())
)
.build();
clusterService = createClusterService(threadPool, discoveryNode);
CapturingTransport capturingTransport = new CapturingTransport();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
import org.elasticsearch.common.util.concurrent.AtomicArray;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.IndexingPressure;
import org.elasticsearch.indices.EmptySystemIndices;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.test.index.IndexVersionUtils;
import org.elasticsearch.test.transport.CapturingTransport;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
Expand Down Expand Up @@ -77,7 +79,11 @@ public static void afterClass() {
public void setUp() throws Exception {
super.setUp();
DiscoveryNode discoveryNode = DiscoveryNodeUtils.builder("node")
.version(VersionUtils.randomCompatibleVersion(random(), Version.CURRENT))
.version(
VersionUtils.randomCompatibleVersion(random(), Version.CURRENT),
IndexVersion.MINIMUM_COMPATIBLE,
IndexVersionUtils.randomCompatibleVersion(random())
)
.build();
clusterService = createClusterService(threadPool, discoveryNode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@
import org.elasticsearch.common.util.concurrent.DeterministicTaskQueue;
import org.elasticsearch.core.IOUtils;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.tasks.TaskId;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.TransportVersionUtils;
import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.test.index.IndexVersionUtils;
import org.elasticsearch.test.transport.MockTransport;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
Expand Down Expand Up @@ -224,7 +226,11 @@ public RecyclerBytesStreamOutput newNetworkBytesStream() {
final List<DiscoveryNode> allNodes = new ArrayList<>();
while (allNodes.size() < 10) {
var node = DiscoveryNodeUtils.builder("node-" + allNodes.size())
.version(VersionUtils.randomCompatibleVersion(random(), Version.CURRENT))
.version(
VersionUtils.randomCompatibleVersion(random(), Version.CURRENT),
IndexVersion.MINIMUM_COMPATIBLE,
IndexVersionUtils.randomCompatibleVersion(random())
)
.build();
allNodes.add(node);
nodeTransports.put(
Expand Down Expand Up @@ -355,7 +361,11 @@ public void testIncludesLastCommittedFieldsInDiffSerialization() {

final var localNode = DiscoveryNodeUtils.create("localNode");
final var otherNode = DiscoveryNodeUtils.builder("otherNode")
.version(VersionUtils.randomCompatibleVersion(random(), Version.CURRENT))
.version(
VersionUtils.randomCompatibleVersion(random(), Version.CURRENT),
IndexVersion.MINIMUM_COMPATIBLE,
IndexVersionUtils.randomCompatibleVersion(random())
)
.build();
for (final var discoveryNode : List.of(localNode, otherNode)) {
final var transport = new MockTransport() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,9 +713,9 @@ public void testCanceledShardIsInitializedRespectingAllocationDeciders() {
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT)
.nodes(
DiscoveryNodes.builder()
.add(newNode("node-0", Version.V_8_10_0))
.add(newNode("node-1", Version.V_8_9_0))
.add(newNode("node-2", Version.V_8_9_0))
.add(newNode("node-0", Version.V_8_10_0, IndexVersion.V_8_10_0))
.add(newNode("node-1", Version.V_8_9_0, IndexVersion.V_8_9_0))
.add(newNode("node-2", Version.V_8_9_0, IndexVersion.V_8_9_0))
)
.metadata(Metadata.builder().put(indexMetadata, false))
.routingTable(RoutingTable.builder().add(IndexRoutingTable.builder(shardId.getIndex()).addShard(primary).addShard(replica)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.indices.cluster.ClusterStateChanges;
import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.test.index.IndexVersionUtils;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;

Expand Down Expand Up @@ -224,7 +225,11 @@ protected DiscoveryNode createNode(DiscoveryNodeRole... mustHaveRoles) {
return DiscoveryNodeUtils.builder(id)
.name(id)
.roles(roles)
.version(VersionUtils.randomCompatibleVersion(random(), Version.CURRENT))
.version(
VersionUtils.randomCompatibleVersion(random(), Version.CURRENT),
IndexVersion.MINIMUM_COMPATIBLE,
IndexVersionUtils.randomCompatibleVersion(random())
)
.build();
}

Expand Down

0 comments on commit 6b8cb58

Please sign in to comment.