Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -564,15 +564,9 @@ tests:
- class: org.elasticsearch.cluster.ClusterStateSerializationTests
method: testSerializationPreMultiProject
issue: https://github.com/elastic/elasticsearch/issues/130872
- class: org.elasticsearch.cluster.coordination.votingonly.VotingOnlyNodePluginTests
method: testPreferFullMasterOverVotingOnlyNodes
issue: https://github.com/elastic/elasticsearch/issues/130883
- class: org.elasticsearch.search.SearchWithRejectionsIT
method: testOpenContextsAfterRejections
issue: https://github.com/elastic/elasticsearch/issues/130821
- class: org.elasticsearch.cluster.coordination.votingonly.VotingOnlyNodePluginTests
method: testVotingOnlyNodesCannotBeMasterWithoutFullMasterNodes
issue: https://github.com/elastic/elasticsearch/issues/130979
- class: org.elasticsearch.packaging.test.DockerTests
method: test082CannotUseEnvVarsAndFiles
issue: https://github.com/elastic/elasticsearch/issues/129808
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.ProjectId;
import org.elasticsearch.cluster.metadata.RepositoryMetadata;
import org.elasticsearch.cluster.node.DiscoveryNode;
Expand Down Expand Up @@ -96,24 +97,21 @@ public void testPreferFullMasterOverVotingOnlyNodes() throws Exception {
internalCluster().setBootstrapMasterNodeIndex(0);
internalCluster().startNodes(2);
internalCluster().startNode(addRoles(Set.of(DiscoveryNodeRole.VOTING_ONLY_NODE_ROLE)));
internalCluster().startDataOnlyNodes(randomInt(2));
assertBusy(
() -> assertThat(
clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getLastCommittedConfiguration().getNodeIds().size(),
equalTo(3)
)
final int numDataNodes = randomInt(2);
internalCluster().startDataOnlyNodes(numDataNodes);
internalCluster().validateClusterFormed();

awaitClusterState(
state -> state.getLastCommittedConfiguration().getNodeIds().size() == 3 && state.nodes().size() == 3 + numDataNodes
);
final String originalMaster = internalCluster().getMasterName();

internalCluster().stopCurrentMasterNode();
awaitMasterNode();
internalCluster().validateClusterFormed();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather this remained as just an awaitMasterNode(). That should be sufficient here...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is theoretically possible that the data node fails to join the new master so that awaitMasterNode() returns without seeing the data node. If we later ask the data node (via a randomed client) about its master and it could fail with NPE. That said, it is not a practical concern for this test. So I reverted back to use awaitMasterNode.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theoretically possible that the data node fails to join the new master

No, that shouldn't be possible (i.e. I'd want the test to fail if that happens). The new master will start from the state that the old master last committed, which will include the data node, so the data node will automatically be part of the new master's cluster. The new master would only remove the data node from its cluster if something positively fails (e.g. network disconnect).

assertNotEquals(originalMaster, internalCluster().getMasterName());
assertThat(
VotingOnlyNodePlugin.isVotingOnlyNode(
clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().nodes().getMasterNode()
),
equalTo(false)
);
final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.nodes().size(), equalTo(2 + numDataNodes));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... except for this new assertion, which I think we should revert. This requires us to wait for the old master to be removed, and that shouldn't be necessary to make the more important assertion that the elected master is not voting-only.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I removed this.

assertThat(VotingOnlyNodePlugin.isVotingOnlyNode(state.nodes().getMasterNode()), equalTo(false));
}

public void testBootstrapOnlyVotingOnlyNodes() throws Exception {
Expand Down Expand Up @@ -157,21 +155,21 @@ public void testVotingOnlyNodesCannotBeMasterWithoutFullMasterNodes() throws Exc
internalCluster().setBootstrapMasterNodeIndex(0);
internalCluster().startNode();
internalCluster().startNodes(2, addRoles(Set.of(DiscoveryNodeRole.VOTING_ONLY_NODE_ROLE)));
internalCluster().startDataOnlyNodes(randomInt(2));
assertBusy(
() -> assertThat(
clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getLastCommittedConfiguration().getNodeIds().size(),
equalTo(3)
)
final int numDataNodes = randomInt(2);
internalCluster().startDataOnlyNodes(numDataNodes);
internalCluster().validateClusterFormed();

awaitClusterState(
state -> state.getLastCommittedConfiguration().getNodeIds().size() == 3 && state.nodes().size() == 3 + numDataNodes
);
awaitMasterNode();
final String oldMasterId = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().nodes().getMasterNodeId();
final String oldMasterId = internalCluster().getMasterName();

internalCluster().stopCurrentMasterNode();
awaitMasterNotFound();

// start a fresh full master node, which will be brought into the cluster as master by the voting-only nodes
final String newMaster = internalCluster().startNode();
internalCluster().validateClusterFormed();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should revert this too, it's stronger than needed. InternalTestCluster#getMasterName already waits for the new master to be elected, and that's enough.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my above reply applies to here. Thanks!

assertEquals(newMaster, internalCluster().getMasterName());
final String newMasterId = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().nodes().getMasterNodeId();
assertNotEquals(oldMasterId, newMasterId);
Expand Down