Search in sources :

Example 66 with Version

use of org.opensearch.Version in project OpenSearch by opensearch-project.

the class JoinTaskExecutorTests method testUpdatesNodeWithNewRoles.

public void testUpdatesNodeWithNewRoles() throws Exception {
    // Node roles vary by version, and new roles are suppressed for BWC. This means we can receive a join from a node that's already
    // in the cluster but with a different set of roles: the node didn't change roles, but the cluster state came via an older master.
    // In this case we must properly process its join to ensure that the roles are correct.
    final AllocationService allocationService = mock(AllocationService.class);
    when(allocationService.adaptAutoExpandReplicas(any())).then(invocationOnMock -> invocationOnMock.getArguments()[0]);
    final RerouteService rerouteService = (reason, priority, listener) -> listener.onResponse(null);
    final JoinTaskExecutor joinTaskExecutor = new JoinTaskExecutor(Settings.EMPTY, allocationService, logger, rerouteService, null);
    final DiscoveryNode masterNode = new DiscoveryNode(UUIDs.base64UUID(), buildNewFakeTransportAddress(), Version.CURRENT);
    final DiscoveryNode actualNode = new DiscoveryNode(UUIDs.base64UUID(), buildNewFakeTransportAddress(), Version.CURRENT);
    final DiscoveryNode bwcNode = new DiscoveryNode(actualNode.getName(), actualNode.getId(), actualNode.getEphemeralId(), actualNode.getHostName(), actualNode.getHostAddress(), actualNode.getAddress(), actualNode.getAttributes(), new HashSet<>(randomSubsetOf(actualNode.getRoles())), actualNode.getVersion());
    final ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).nodes(DiscoveryNodes.builder().add(masterNode).localNodeId(masterNode.getId()).masterNodeId(masterNode.getId()).add(bwcNode)).build();
    final ClusterStateTaskExecutor.ClusterTasksResult<JoinTaskExecutor.Task> result = joinTaskExecutor.execute(clusterState, List.of(new JoinTaskExecutor.Task(actualNode, "test")));
    assertThat(result.executionResults.entrySet(), hasSize(1));
    final ClusterStateTaskExecutor.TaskResult taskResult = result.executionResults.values().iterator().next();
    assertTrue(taskResult.isSuccess());
    assertThat(result.resultingState.getNodes().get(actualNode.getId()).getRoles(), equalTo(actualNode.getRoles()));
}
Also used : DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes) Metadata(org.opensearch.cluster.metadata.Metadata) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) VersionUtils.maxCompatibleVersion(org.opensearch.test.VersionUtils.maxCompatibleVersion) VersionUtils.randomCompatibleVersion(org.opensearch.test.VersionUtils.randomCompatibleVersion) AllocationService(org.opensearch.cluster.routing.allocation.AllocationService) Version(org.opensearch.Version) HashMap(java.util.HashMap) VersionUtils.randomVersionBetween(org.opensearch.test.VersionUtils.randomVersionBetween) HashSet(java.util.HashSet) ClusterState(org.opensearch.cluster.ClusterState) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) LegacyESVersion(org.opensearch.LegacyESVersion) VersionUtils(org.opensearch.test.VersionUtils) Mockito.anyBoolean(org.mockito.Mockito.anyBoolean) Map(java.util.Map) RerouteService(org.opensearch.cluster.routing.RerouteService) Matchers.hasSize(org.hamcrest.Matchers.hasSize) UUIDs(org.opensearch.common.UUIDs) OpenSearchTestCase(org.opensearch.test.OpenSearchTestCase) VersionUtils.randomVersion(org.opensearch.test.VersionUtils.randomVersion) ClusterStateTaskExecutor(org.opensearch.cluster.ClusterStateTaskExecutor) Settings(org.opensearch.common.settings.Settings) Mockito.when(org.mockito.Mockito.when) TransportService(org.opensearch.transport.TransportService) List(org.opensearch.common.collect.List) Matchers.equalTo(org.hamcrest.Matchers.equalTo) ClusterName(org.opensearch.cluster.ClusterName) Mockito.any(org.mockito.Mockito.any) Mockito.mock(org.mockito.Mockito.mock) ClusterState(org.opensearch.cluster.ClusterState) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) ClusterStateTaskExecutor(org.opensearch.cluster.ClusterStateTaskExecutor) RerouteService(org.opensearch.cluster.routing.RerouteService) AllocationService(org.opensearch.cluster.routing.allocation.AllocationService)

Example 67 with Version

use of org.opensearch.Version in project OpenSearch by opensearch-project.

the class JoinTaskExecutorTests method testUpdatesNodeWithOpenSearchVersionForExistingAndNewNodes.

public void testUpdatesNodeWithOpenSearchVersionForExistingAndNewNodes() throws Exception {
    // During the upgrade from Elasticsearch, OpenSearch node send their version as 7.10.2 to Elasticsearch master
    // in order to successfully join the cluster. But as soon as OpenSearch node becomes the master, cluster state
    // should show the OpenSearch nodes version as 1.x. As the cluster state was carry forwarded from ES master,
    // version in DiscoveryNode is stale 7.10.2.
    final AllocationService allocationService = mock(AllocationService.class);
    when(allocationService.adaptAutoExpandReplicas(any())).then(invocationOnMock -> invocationOnMock.getArguments()[0]);
    when(allocationService.disassociateDeadNodes(any(), anyBoolean(), any())).then(invocationOnMock -> invocationOnMock.getArguments()[0]);
    final RerouteService rerouteService = (reason, priority, listener) -> listener.onResponse(null);
    Map<String, Version> channelVersions = new HashMap<>();
    // OpenSearch node running BWC version
    String node_1 = UUIDs.base64UUID();
    // OpenSearch node running BWC version
    String node_2 = UUIDs.base64UUID();
    // OpenSearch node running BWC version, sending new join request and no active channel
    String node_3 = UUIDs.base64UUID();
    // ES node 7.10.2
    String node_4 = UUIDs.base64UUID();
    // ES node 7.10.2 in cluster but missing channel version
    String node_5 = UUIDs.base64UUID();
    // ES node 7.9.0
    String node_6 = UUIDs.base64UUID();
    // ES node 7.9.0 in cluster but missing channel version
    String node_7 = UUIDs.base64UUID();
    channelVersions.put(node_1, Version.CURRENT);
    channelVersions.put(node_2, Version.CURRENT);
    channelVersions.put(node_4, LegacyESVersion.V_7_10_2);
    channelVersions.put(node_6, LegacyESVersion.V_7_10_0);
    final TransportService transportService = mock(TransportService.class);
    when(transportService.getChannelVersion(any())).thenReturn(channelVersions);
    DiscoveryNodes.Builder nodes = new DiscoveryNodes.Builder().localNodeId(node_1);
    nodes.add(new DiscoveryNode(node_1, buildNewFakeTransportAddress(), LegacyESVersion.V_7_10_2));
    nodes.add(new DiscoveryNode(node_2, buildNewFakeTransportAddress(), LegacyESVersion.V_7_10_2));
    nodes.add(new DiscoveryNode(node_3, buildNewFakeTransportAddress(), LegacyESVersion.V_7_10_2));
    nodes.add(new DiscoveryNode(node_4, buildNewFakeTransportAddress(), LegacyESVersion.V_7_10_2));
    nodes.add(new DiscoveryNode(node_5, buildNewFakeTransportAddress(), LegacyESVersion.V_7_10_2));
    nodes.add(new DiscoveryNode(node_6, buildNewFakeTransportAddress(), LegacyESVersion.V_7_10_1));
    nodes.add(new DiscoveryNode(node_7, buildNewFakeTransportAddress(), LegacyESVersion.V_7_10_0));
    final ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).nodes(nodes).build();
    final JoinTaskExecutor joinTaskExecutor = new JoinTaskExecutor(Settings.EMPTY, allocationService, logger, rerouteService, transportService);
    final DiscoveryNode existing_node_3 = clusterState.nodes().get(node_3);
    final DiscoveryNode node_3_new_join = new DiscoveryNode(existing_node_3.getName(), existing_node_3.getId(), existing_node_3.getEphemeralId(), existing_node_3.getHostName(), existing_node_3.getHostAddress(), existing_node_3.getAddress(), existing_node_3.getAttributes(), existing_node_3.getRoles(), Version.CURRENT);
    final ClusterStateTaskExecutor.ClusterTasksResult<JoinTaskExecutor.Task> result = joinTaskExecutor.execute(clusterState, List.of(new JoinTaskExecutor.Task(node_3_new_join, "test"), JoinTaskExecutor.newBecomeMasterTask(), JoinTaskExecutor.newFinishElectionTask()));
    final ClusterStateTaskExecutor.TaskResult taskResult = result.executionResults.values().iterator().next();
    assertTrue(taskResult.isSuccess());
    DiscoveryNodes resultNodes = result.resultingState.getNodes();
    assertEquals(Version.CURRENT, resultNodes.get(node_1).getVersion());
    assertEquals(Version.CURRENT, resultNodes.get(node_2).getVersion());
    // 7.10.2 in old state but sent new join and processed
    assertEquals(Version.CURRENT, resultNodes.get(node_3).getVersion());
    assertEquals(LegacyESVersion.V_7_10_2, resultNodes.get(node_4).getVersion());
    // 7.10.2 node without active channel will be removed and should rejoin
    assertFalse(resultNodes.nodeExists(node_5));
    assertEquals(LegacyESVersion.V_7_10_0, resultNodes.get(node_6).getVersion());
    // 7.9.0 node without active channel but shouldn't get removed
    assertEquals(LegacyESVersion.V_7_10_0, resultNodes.get(node_7).getVersion());
}
Also used : DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes) Metadata(org.opensearch.cluster.metadata.Metadata) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) VersionUtils.maxCompatibleVersion(org.opensearch.test.VersionUtils.maxCompatibleVersion) VersionUtils.randomCompatibleVersion(org.opensearch.test.VersionUtils.randomCompatibleVersion) AllocationService(org.opensearch.cluster.routing.allocation.AllocationService) Version(org.opensearch.Version) HashMap(java.util.HashMap) VersionUtils.randomVersionBetween(org.opensearch.test.VersionUtils.randomVersionBetween) HashSet(java.util.HashSet) ClusterState(org.opensearch.cluster.ClusterState) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) LegacyESVersion(org.opensearch.LegacyESVersion) VersionUtils(org.opensearch.test.VersionUtils) Mockito.anyBoolean(org.mockito.Mockito.anyBoolean) Map(java.util.Map) RerouteService(org.opensearch.cluster.routing.RerouteService) Matchers.hasSize(org.hamcrest.Matchers.hasSize) UUIDs(org.opensearch.common.UUIDs) OpenSearchTestCase(org.opensearch.test.OpenSearchTestCase) VersionUtils.randomVersion(org.opensearch.test.VersionUtils.randomVersion) ClusterStateTaskExecutor(org.opensearch.cluster.ClusterStateTaskExecutor) Settings(org.opensearch.common.settings.Settings) Mockito.when(org.mockito.Mockito.when) TransportService(org.opensearch.transport.TransportService) List(org.opensearch.common.collect.List) Matchers.equalTo(org.hamcrest.Matchers.equalTo) ClusterName(org.opensearch.cluster.ClusterName) Mockito.any(org.mockito.Mockito.any) Mockito.mock(org.mockito.Mockito.mock) ClusterState(org.opensearch.cluster.ClusterState) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) HashMap(java.util.HashMap) VersionUtils.maxCompatibleVersion(org.opensearch.test.VersionUtils.maxCompatibleVersion) VersionUtils.randomCompatibleVersion(org.opensearch.test.VersionUtils.randomCompatibleVersion) Version(org.opensearch.Version) LegacyESVersion(org.opensearch.LegacyESVersion) VersionUtils.randomVersion(org.opensearch.test.VersionUtils.randomVersion) TransportService(org.opensearch.transport.TransportService) ClusterStateTaskExecutor(org.opensearch.cluster.ClusterStateTaskExecutor) RerouteService(org.opensearch.cluster.routing.RerouteService) AllocationService(org.opensearch.cluster.routing.allocation.AllocationService) DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes)

Example 68 with Version

use of org.opensearch.Version in project OpenSearch by opensearch-project.

the class ClusterBlockTests method testSerialization.

public void testSerialization() throws Exception {
    int iterations = randomIntBetween(5, 20);
    for (int i = 0; i < iterations; i++) {
        Version version = randomVersion(random());
        ClusterBlock clusterBlock = randomClusterBlock();
        BytesStreamOutput out = new BytesStreamOutput();
        out.setVersion(version);
        clusterBlock.writeTo(out);
        StreamInput in = out.bytes().streamInput();
        in.setVersion(version);
        ClusterBlock result = new ClusterBlock(in);
        assertClusterBlockEquals(clusterBlock, result);
    }
}
Also used : VersionUtils.randomVersion(org.opensearch.test.VersionUtils.randomVersion) Version(org.opensearch.Version) StreamInput(org.opensearch.common.io.stream.StreamInput) BytesStreamOutput(org.opensearch.common.io.stream.BytesStreamOutput)

Example 69 with Version

use of org.opensearch.Version in project OpenSearch by opensearch-project.

the class FailedShardsRoutingTests method testReplicaOnNewestVersionIsPromoted.

public void testReplicaOnNewestVersionIsPromoted() {
    AllocationService allocation = createAllocationService(Settings.builder().build());
    Metadata metadata = Metadata.builder().put(IndexMetadata.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(3)).build();
    RoutingTable initialRoutingTable = RoutingTable.builder().addAsNew(metadata.index("test")).build();
    ClusterState clusterState = ClusterState.builder(CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metadata(metadata).routingTable(initialRoutingTable).build();
    ShardId shardId = new ShardId(metadata.index("test").getIndex(), 0);
    // add a single node
    clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().add(newNode("node1-5.x", Version.fromId(5060099)))).build();
    clusterState = ClusterState.builder(clusterState).routingTable(allocation.reroute(clusterState, "reroute").routingTable()).build();
    assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(1));
    assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).size(), equalTo(3));
    // start primary shard
    clusterState = startInitializingShardsAndReroute(allocation, clusterState);
    assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(1));
    assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).size(), equalTo(3));
    // add another 5.6 node
    clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).add(newNode("node2-5.x", Version.fromId(5060099)))).build();
    // start the shards, should have 1 primary and 1 replica available
    clusterState = allocation.reroute(clusterState, "reroute");
    assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(1));
    assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(1));
    clusterState = startInitializingShardsAndReroute(allocation, clusterState);
    assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(2));
    assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).size(), equalTo(2));
    clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).add(newNode("node3-old", VersionUtils.randomVersionBetween(random(), Version.CURRENT.minimumIndexCompatibilityVersion(), null))).add(newNode("node4-old", VersionUtils.randomVersionBetween(random(), Version.CURRENT.minimumIndexCompatibilityVersion(), null)))).build();
    // start all the replicas
    clusterState = allocation.reroute(clusterState, "reroute");
    assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(2));
    assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(2));
    clusterState = startInitializingShardsAndReroute(allocation, clusterState);
    assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(4));
    assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).size(), equalTo(0));
    ShardRouting startedReplica = clusterState.getRoutingNodes().activeReplicaWithHighestVersion(shardId);
    logger.info("--> all shards allocated, replica that should be promoted: {}", startedReplica);
    // fail the primary shard again and make sure the correct replica is promoted
    ShardRouting primaryShardToFail = clusterState.routingTable().index("test").shard(0).primaryShard();
    ClusterState newState = allocation.applyFailedShard(clusterState, primaryShardToFail, randomBoolean());
    assertThat(newState, not(equalTo(clusterState)));
    clusterState = newState;
    // the primary gets allocated on another node
    assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(3));
    ShardRouting newPrimaryShard = clusterState.routingTable().index("test").shard(0).primaryShard();
    assertThat(newPrimaryShard, not(equalTo(primaryShardToFail)));
    assertThat(newPrimaryShard.allocationId(), equalTo(startedReplica.allocationId()));
    Version replicaNodeVersion = clusterState.nodes().getDataNodes().get(startedReplica.currentNodeId()).getVersion();
    assertNotNull(replicaNodeVersion);
    logger.info("--> shard {} got assigned to node with version {}", startedReplica, replicaNodeVersion);
    for (ObjectCursor<DiscoveryNode> cursor : clusterState.nodes().getDataNodes().values()) {
        if ("node1".equals(cursor.value.getId())) {
            // Skip the node that the primary was on, it doesn't have a replica so doesn't need a version check
            continue;
        }
        Version nodeVer = cursor.value.getVersion();
        assertTrue("expected node [" + cursor.value.getId() + "] with version " + nodeVer + " to be before " + replicaNodeVersion, replicaNodeVersion.onOrAfter(nodeVer));
    }
    startedReplica = clusterState.getRoutingNodes().activeReplicaWithHighestVersion(shardId);
    logger.info("--> failing primary shard a second time, should select: {}", startedReplica);
    // fail the primary shard again, and ensure the same thing happens
    ShardRouting secondPrimaryShardToFail = clusterState.routingTable().index("test").shard(0).primaryShard();
    newState = allocation.applyFailedShard(clusterState, secondPrimaryShardToFail, randomBoolean());
    assertThat(newState, not(equalTo(clusterState)));
    clusterState = newState;
    // the primary gets allocated on another node
    assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(2));
    newPrimaryShard = clusterState.routingTable().index("test").shard(0).primaryShard();
    assertThat(newPrimaryShard, not(equalTo(secondPrimaryShardToFail)));
    assertThat(newPrimaryShard.allocationId(), equalTo(startedReplica.allocationId()));
    replicaNodeVersion = clusterState.nodes().getDataNodes().get(startedReplica.currentNodeId()).getVersion();
    assertNotNull(replicaNodeVersion);
    logger.info("--> shard {} got assigned to node with version {}", startedReplica, replicaNodeVersion);
    for (ObjectCursor<DiscoveryNode> cursor : clusterState.nodes().getDataNodes().values()) {
        if (primaryShardToFail.currentNodeId().equals(cursor.value.getId()) || secondPrimaryShardToFail.currentNodeId().equals(cursor.value.getId())) {
            // Skip the node that the primary was on, it doesn't have a replica so doesn't need a version check
            continue;
        }
        Version nodeVer = cursor.value.getVersion();
        assertTrue("expected node [" + cursor.value.getId() + "] with version " + nodeVer + " to be before " + replicaNodeVersion, replicaNodeVersion.onOrAfter(nodeVer));
    }
}
Also used : ShardId(org.opensearch.index.shard.ShardId) ClusterState(org.opensearch.cluster.ClusterState) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) RoutingTable(org.opensearch.cluster.routing.RoutingTable) Version(org.opensearch.Version) Metadata(org.opensearch.cluster.metadata.Metadata) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) ShardRouting(org.opensearch.cluster.routing.ShardRouting)

Example 70 with Version

use of org.opensearch.Version in project OpenSearch by opensearch-project.

the class FailedNodeRoutingTests method testRandomClusterPromotesNewestReplica.

public void testRandomClusterPromotesNewestReplica() throws InterruptedException {
    ThreadPool threadPool = new TestThreadPool(getClass().getName());
    ClusterStateChanges cluster = new ClusterStateChanges(xContentRegistry(), threadPool);
    ClusterState state = randomInitialClusterState();
    // randomly add nodes of mixed versions
    logger.info("--> adding random nodes");
    for (int i = 0; i < randomIntBetween(4, 8); i++) {
        DiscoveryNodes newNodes = DiscoveryNodes.builder(state.nodes()).add(createNode()).build();
        state = ClusterState.builder(state).nodes(newNodes).build();
        // always reroute after adding node
        state = cluster.reroute(state, new ClusterRerouteRequest());
    }
    // Log the node versions (for debugging if necessary)
    for (ObjectCursor<DiscoveryNode> cursor : state.nodes().getDataNodes().values()) {
        Version nodeVer = cursor.value.getVersion();
        logger.info("--> node [{}] has version [{}]", cursor.value.getId(), nodeVer);
    }
    // randomly create some indices
    logger.info("--> creating some indices");
    for (int i = 0; i < randomIntBetween(2, 5); i++) {
        String name = "index_" + randomAlphaOfLength(8).toLowerCase(Locale.ROOT);
        Settings.Builder settingsBuilder = Settings.builder().put(SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 4)).put(SETTING_NUMBER_OF_REPLICAS, randomIntBetween(2, 4));
        CreateIndexRequest request = new CreateIndexRequest(name, settingsBuilder.build()).waitForActiveShards(ActiveShardCount.NONE);
        state = cluster.createIndex(state, request);
        assertTrue(state.metadata().hasIndex(name));
    }
    logger.info("--> starting shards");
    state = cluster.applyStartedShards(state, state.getRoutingNodes().shardsWithState(INITIALIZING));
    logger.info("--> starting replicas a random number of times");
    for (int i = 0; i < randomIntBetween(1, 10); i++) {
        state = cluster.applyStartedShards(state, state.getRoutingNodes().shardsWithState(INITIALIZING));
    }
    boolean keepGoing = true;
    while (keepGoing) {
        List<ShardRouting> primaries = state.getRoutingNodes().shardsWithState(STARTED).stream().filter(ShardRouting::primary).collect(Collectors.toList());
        // Pick a random subset of primaries to fail
        List<FailedShard> shardsToFail = new ArrayList<>();
        List<ShardRouting> failedPrimaries = randomSubsetOf(primaries);
        failedPrimaries.stream().forEach(sr -> {
            shardsToFail.add(new FailedShard(randomFrom(sr), "failed primary", new Exception(), randomBoolean()));
        });
        logger.info("--> state before failing shards: {}", state);
        state = cluster.applyFailedShards(state, shardsToFail);
        final ClusterState compareState = state;
        failedPrimaries.forEach(shardRouting -> {
            logger.info("--> verifying version for {}", shardRouting);
            ShardRouting newPrimary = compareState.routingTable().index(shardRouting.index()).shard(shardRouting.id()).primaryShard();
            Version newPrimaryVersion = getNodeVersion(newPrimary, compareState);
            logger.info("--> new primary is on version {}: {}", newPrimaryVersion, newPrimary);
            compareState.routingTable().shardRoutingTable(newPrimary.shardId()).shardsWithState(STARTED).stream().forEach(sr -> {
                Version candidateVer = getNodeVersion(sr, compareState);
                if (candidateVer != null) {
                    logger.info("--> candidate on {} node; shard routing: {}", candidateVer, sr);
                    assertTrue("candidate was not on the newest version, new primary is on " + newPrimaryVersion + " and there is a candidate on " + candidateVer, candidateVer.onOrBefore(newPrimaryVersion));
                }
            });
        });
        keepGoing = randomBoolean();
    }
    terminate(threadPool);
}
Also used : ClusterState(org.opensearch.cluster.ClusterState) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) ThreadPool(org.opensearch.threadpool.ThreadPool) TestThreadPool(org.opensearch.threadpool.TestThreadPool) ArrayList(java.util.ArrayList) TestThreadPool(org.opensearch.threadpool.TestThreadPool) ClusterStateChanges(org.opensearch.indices.cluster.ClusterStateChanges) ClusterRerouteRequest(org.opensearch.action.admin.cluster.reroute.ClusterRerouteRequest) Version(org.opensearch.Version) CreateIndexRequest(org.opensearch.action.admin.indices.create.CreateIndexRequest) ShardRouting(org.opensearch.cluster.routing.ShardRouting) DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes) Settings(org.opensearch.common.settings.Settings)

Aggregations

Version (org.opensearch.Version)242 Settings (org.opensearch.common.settings.Settings)86 LegacyESVersion (org.opensearch.LegacyESVersion)84 ArrayList (java.util.ArrayList)59 IOException (java.io.IOException)54 List (java.util.List)54 Map (java.util.Map)50 DiscoveryNode (org.opensearch.cluster.node.DiscoveryNode)42 Collections (java.util.Collections)39 HashMap (java.util.HashMap)38 ClusterState (org.opensearch.cluster.ClusterState)38 IndexMetadata (org.opensearch.cluster.metadata.IndexMetadata)37 HashSet (java.util.HashSet)36 BytesReference (org.opensearch.common.bytes.BytesReference)36 TimeValue (org.opensearch.common.unit.TimeValue)36 Set (java.util.Set)35 Collectors (java.util.stream.Collectors)34 XContentBuilder (org.opensearch.common.xcontent.XContentBuilder)33 StreamInput (org.opensearch.common.io.stream.StreamInput)32 BytesArray (org.opensearch.common.bytes.BytesArray)30