Skip to content

Commit

Permalink
Replace master with cluster_manager in test method names in server/sr…
Browse files Browse the repository at this point in the history
…c/internalClusterTest

Signed-off-by: Tianli Feng <[email protected]>
  • Loading branch information
Tianli Feng committed May 19, 2022
1 parent 50fcf3b commit 737843f
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public void testWithdrawsVotesFromNodesMatchingWildcard() throws InterruptedExce
assertWarnings(AddVotingConfigExclusionsRequest.DEPRECATION_MESSAGE);
}

public void testWithdrawsVotesFromAllMasterEligibleNodes() throws InterruptedException {
public void testWithdrawsVotesFromAllClusterManagerEligibleNodes() throws InterruptedException {
final CountDownLatch countDownLatch = new CountDownLatch(2);

clusterStateObserver.waitForNextChange(new AdjustConfigurationForExclusions(countDownLatch));
Expand Down
21 changes: 12 additions & 9 deletions server/src/test/java/org/opensearch/cluster/ClusterStateTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void testSupersedes() {
.version(randomInt(5))
.nodes(DiscoveryNodes.builder(nodes).masterNodeId(node1.getId()))
.build();
ClusterState withMaster1b = ClusterState.builder(name)
ClusterState withClusterManager1b = ClusterState.builder(name)
.version(randomInt(5))
.nodes(DiscoveryNodes.builder(nodes).masterNodeId(node1.getId()))
.build();
Expand All @@ -110,7 +110,10 @@ public void testSupersedes() {
assertFalse(withClusterManager1a.supersedes(noClusterManager1));

// state from the same cluster-manager compare by version
assertThat(withClusterManager1a.supersedes(withMaster1b), equalTo(withClusterManager1a.version() > withMaster1b.version()));
assertThat(
withClusterManager1a.supersedes(withClusterManager1b),
equalTo(withClusterManager1a.version() > withClusterManager1b.version())
);
}

public void testBuilderRejectsNullCustom() {
Expand Down Expand Up @@ -146,8 +149,8 @@ public void testToXContent() throws IOException {
+ " \"cluster_uuid\" : \"clusterUUID\",\n"
+ " \"version\" : 0,\n"
+ " \"state_uuid\" : \"stateUUID\",\n"
+ " \"master_node\" : \"masterNodeId\",\n"
+ " \"cluster_manager_node\" : \"masterNodeId\",\n"
+ " \"master_node\" : \"clusterManagerNodeId\",\n"
+ " \"cluster_manager_node\" : \"clusterManagerNodeId\",\n"
+ " \"blocks\" : {\n"
+ " \"global\" : {\n"
+ " \"1\" : {\n"
Expand Down Expand Up @@ -352,8 +355,8 @@ public void testToXContent_FlatSettingTrue_ReduceMappingFalse() throws IOExcepti
+ " \"cluster_uuid\" : \"clusterUUID\",\n"
+ " \"version\" : 0,\n"
+ " \"state_uuid\" : \"stateUUID\",\n"
+ " \"master_node\" : \"masterNodeId\",\n"
+ " \"cluster_manager_node\" : \"masterNodeId\",\n"
+ " \"master_node\" : \"clusterManagerNodeId\",\n"
+ " \"cluster_manager_node\" : \"clusterManagerNodeId\",\n"
+ " \"blocks\" : {\n"
+ " \"global\" : {\n"
+ " \"1\" : {\n"
Expand Down Expand Up @@ -551,8 +554,8 @@ public void testToXContent_FlatSettingFalse_ReduceMappingTrue() throws IOExcepti
+ " \"cluster_uuid\" : \"clusterUUID\",\n"
+ " \"version\" : 0,\n"
+ " \"state_uuid\" : \"stateUUID\",\n"
+ " \"master_node\" : \"masterNodeId\",\n"
+ " \"cluster_manager_node\" : \"masterNodeId\",\n"
+ " \"master_node\" : \"clusterManagerNodeId\",\n"
+ " \"cluster_manager_node\" : \"clusterManagerNodeId\",\n"
+ " \"blocks\" : {\n"
+ " \"global\" : {\n"
+ " \"1\" : {\n"
Expand Down Expand Up @@ -868,7 +871,7 @@ private ClusterState buildClusterState() throws IOException {
.stateUUID("stateUUID")
.nodes(
DiscoveryNodes.builder()
.masterNodeId("masterNodeId")
.masterNodeId("clusterManagerNodeId")
.add(new DiscoveryNode("nodeId1", new TransportAddress(InetAddress.getByName("127.0.0.1"), 111), Version.CURRENT))
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ private static class TestShardStateAction extends ShardStateAction {

private Runnable onBeforeWaitForNewClusterManagerAndRetry;

public void setOnBeforeWaitForNewMasterAndRetry(Runnable onBeforeWaitForNewMasterAndRetry) {
this.onBeforeWaitForNewClusterManagerAndRetry = onBeforeWaitForNewMasterAndRetry;
public void setOnBeforeWaitForNewClusterManagerAndRetry(Runnable onBeforeWaitForNewClusterManagerAndRetry) {
this.onBeforeWaitForNewClusterManagerAndRetry = onBeforeWaitForNewClusterManagerAndRetry;
}

private Runnable onAfterWaitForNewClusterManagerAndRetry;

public void setOnAfterWaitForNewMasterAndRetry(Runnable onAfterWaitForNewMasterAndRetry) {
this.onAfterWaitForNewClusterManagerAndRetry = onAfterWaitForNewMasterAndRetry;
public void setOnAfterWaitFornewClusterManagerAndRetry(Runnable onAfterWaitFornewClusterManagerAndRetry) {
this.onAfterWaitForNewClusterManagerAndRetry = onAfterWaitFornewClusterManagerAndRetry;
}

@Override
Expand Down Expand Up @@ -160,8 +160,8 @@ public void setUp() throws Exception {
transportService.start();
transportService.acceptIncomingRequests();
shardStateAction = new TestShardStateAction(clusterService, transportService, null, null);
shardStateAction.setOnBeforeWaitForNewMasterAndRetry(() -> {});
shardStateAction.setOnAfterWaitForNewMasterAndRetry(() -> {});
shardStateAction.setOnBeforeWaitForNewClusterManagerAndRetry(() -> {});
shardStateAction.setOnAfterWaitFornewClusterManagerAndRetry(() -> {});
}

@Override
Expand Down Expand Up @@ -205,14 +205,14 @@ public void testSuccess() throws InterruptedException {
assertNull(listener.failure.get());
}

public void testNoMaster() throws InterruptedException {
public void testNoClusterManager() throws InterruptedException {
final String index = "test";

setState(clusterService, ClusterStateCreationUtils.stateWithActivePrimary(index, true, randomInt(5)));

DiscoveryNodes.Builder noMasterBuilder = DiscoveryNodes.builder(clusterService.state().nodes());
noMasterBuilder.masterNodeId(null);
setState(clusterService, ClusterState.builder(clusterService.state()).nodes(noMasterBuilder));
DiscoveryNodes.Builder noClusterManagerBuilder = DiscoveryNodes.builder(clusterService.state().nodes());
noClusterManagerBuilder.masterNodeId(null);
setState(clusterService, ClusterState.builder(clusterService.state()).nodes(noClusterManagerBuilder));

CountDownLatch latch = new CountDownLatch(1);
AtomicInteger retries = new AtomicInteger();
Expand Down Expand Up @@ -242,7 +242,7 @@ public void onFailure(Exception e) {
assertTrue(success.get());
}

public void testMasterChannelException() throws InterruptedException {
public void testClusterManagerChannelException() throws InterruptedException {
final String index = "test";

setState(clusterService, ClusterStateCreationUtils.stateWithActivePrimary(index, true, randomInt(5)));
Expand Down Expand Up @@ -497,13 +497,13 @@ private ShardRouting getRandomShardRouting(String index) {
}

private void setUpMasterRetryVerification(int numberOfRetries, AtomicInteger retries, CountDownLatch latch, LongConsumer retryLoop) {
shardStateAction.setOnBeforeWaitForNewMasterAndRetry(() -> {
shardStateAction.setOnBeforeWaitForNewClusterManagerAndRetry(() -> {
DiscoveryNodes.Builder clusterManagerBuilder = DiscoveryNodes.builder(clusterService.state().nodes());
clusterManagerBuilder.masterNodeId(clusterService.state().nodes().getMasterNodes().iterator().next().value.getId());
setState(clusterService, ClusterState.builder(clusterService.state()).nodes(clusterManagerBuilder));
});

shardStateAction.setOnAfterWaitForNewMasterAndRetry(() -> verifyRetry(numberOfRetries, retries, latch, retryLoop));
shardStateAction.setOnAfterWaitFornewClusterManagerAndRetry(() -> verifyRetry(numberOfRetries, retries, latch, retryLoop));
}

private void verifyRetry(int numberOfRetries, AtomicInteger retries, CountDownLatch latch, LongConsumer retryLoop) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void testDoesNothingByDefaultIfClusterManagerNodesConfigured() {
testDoesNothingWithSettings(builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey()));
}

public void testDoesNothingByDefaultOnMasterIneligibleNodes() {
public void testDoesNothingByDefaultOnClusterManagerIneligibleNodes() {
localNode = new DiscoveryNode(
"local",
randomAlphaOfLength(10),
Expand Down Expand Up @@ -401,7 +401,7 @@ public void testDoesNotBootstrapIfAlreadyBootstrapped() {
deterministicTaskQueue.runAllTasks();
}

public void testDoesNotBootstrapsOnNonMasterNode() {
public void testDoesNotBootstrapsOnNonClusterManagerNode() {
localNode = new DiscoveryNode(
"local",
randomAlphaOfLength(10),
Expand Down Expand Up @@ -676,7 +676,7 @@ public void testFailBootstrapWithBothSingleNodeDiscoveryAndInitialClusterManager
);
}

public void testFailBootstrapNonMasterEligibleNodeWithSingleNodeDiscovery() {
public void testFailBootstrapNonClusterManagerEligibleNodeWithSingleNodeDiscovery() {
final Settings.Builder settings = Settings.builder()
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE)
.put(NODE_NAME_SETTING.getKey(), localNode.getName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void testScheduling() {
assertThat(logLastFailedJoinAttemptWarningCount.get(), is(5L));
}

public void testDescriptionOnMasterIneligibleNodes() {
public void testDescriptionOnClusterManagerIneligibleNodes() {
final DiscoveryNode localNode = new DiscoveryNode("local", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
final ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT)
.version(12L)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void testCanUpdateClusterStateAfterStabilisation() {
}
}

public void testDoesNotElectNonMasterNode() {
public void testDoesNotElectNonClusterManagerNode() {
try (Cluster cluster = new Cluster(randomIntBetween(1, 5), false, Settings.EMPTY)) {
cluster.runRandomly();
cluster.stabilise();
Expand Down Expand Up @@ -1175,7 +1175,7 @@ private void testAppliesNoMasterBlock(String noMasterBlockSetting, ClusterBlock
}
}

public void testNodeCannotJoinIfJoinValidationFailsOnMaster() {
public void testNodeCannotJoinIfJoinValidationFailsOnClusterManager() {
try (Cluster cluster = new Cluster(randomIntBetween(1, 3))) {
cluster.runRandomly();
cluster.stabilise();
Expand Down Expand Up @@ -1305,7 +1305,7 @@ public void testDiscoveryUsesNodesFromLastClusterState() {
}
}

public void testFollowerRemovedIfUnableToSendRequestsToMaster() {
public void testFollowerRemovedIfUnableToSendRequestsToClusterManager() {
try (Cluster cluster = new Cluster(3)) {
cluster.runRandomly();
cluster.stabilise();
Expand Down Expand Up @@ -1679,7 +1679,7 @@ public String toString() {
}
}

public void testReconfiguresToExcludeMasterIneligibleNodesInVotingConfig() {
public void testReconfiguresToExcludeClusterManagerIneligibleNodesInVotingConfig() {
try (Cluster cluster = new Cluster(3)) {
cluster.runRandomly();
cluster.stabilise();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public void testJoinWithHigherTermButBetterStateGetsRejected() {
assertFalse(isLocalNodeElectedMaster());
}

public void testJoinWithHigherTermButBetterStateStillElectsMasterThroughSelfJoin() {
public void testJoinWithHigherTermButBetterStateStillElectsClusterManagerThroughSelfJoin() {
DiscoveryNode node0 = newNode(0, true);
DiscoveryNode node1 = newNode(1, true);
long initialTerm = randomLongBetween(1, 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public void testClusterStatePublishingFailsOrTimesOutBeforeCommit() throws Inter
);
}

public void testPublishingToMastersFirst() {
public void testPublishingToClusterManagersFirst() {
VotingConfiguration singleNodeConfig = VotingConfiguration.of(n1);
initializeCluster(singleNodeConfig);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public void onFailure(String source, Exception e) {
}
}

public void testLocalNodeMasterListenerCallbacks() {
public void testLocalNodeClusterManagerListenerCallbacks() {
TimedClusterApplierService timedClusterApplierService = createTimedClusterService(false);

AtomicBoolean isClusterManager = new AtomicBoolean();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private IndexMetadata createIndexMetadata(String name) {
return IndexMetadata.builder(name).settings(settings(Version.CURRENT)).numberOfShards(5).numberOfReplicas(2).build();
}

public void testGetRelevantIndicesWithUnassignedShardsOnMasterEligibleNode() {
public void testGetRelevantIndicesWithUnassignedShardsOnClusterManagerEligibleNode() {
IndexMetadata indexMetadata = createIndexMetadata("test");
Set<Index> indices = IncrementalClusterStateWriter.getRelevantIndices(clusterStateWithUnassignedIndex(indexMetadata, true));
assertThat(indices.size(), equalTo(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public void testMissingInSyncIdsPreventAdvance() {
assertThat(updatedGlobalCheckpoint.get(), not(equalTo(UNASSIGNED_SEQ_NO)));
}

public void testInSyncIdsAreIgnoredIfNotValidatedByMaster() {
public void testInSyncIdsAreIgnoredIfNotValidatedByClusterManager() {
final Map<AllocationId, Long> active = randomAllocationsWithLocalCheckpoints(1, 5);
final Map<AllocationId, Long> initializing = randomAllocationsWithLocalCheckpoints(1, 5);
final Map<AllocationId, Long> nonApproved = randomAllocationsWithLocalCheckpoints(1, 5);
Expand All @@ -313,7 +313,7 @@ public void testInSyncIdsAreIgnoredIfNotValidatedByMaster() {
assertThat(tracker.getGlobalCheckpoint(), not(equalTo(UNASSIGNED_SEQ_NO)));
}

public void testInSyncIdsAreRemovedIfNotValidatedByMaster() {
public void testInSyncIdsAreRemovedIfNotValidatedByClusterManager() {
final long initialClusterStateVersion = randomNonNegativeLong();
final Map<AllocationId, Long> activeToStay = randomAllocationsWithLocalCheckpoints(1, 5);
final Map<AllocationId, Long> initializingToStay = randomAllocationsWithLocalCheckpoints(1, 5);
Expand Down Expand Up @@ -492,7 +492,7 @@ public void testWaitForAllocationIdToBeInSyncCanBeInterrupted() throws BrokenBar
thread.join();
}

public void testUpdateAllocationIdsFromMaster() throws Exception {
public void testUpdateAllocationIdsFromClusterManager() throws Exception {
final long initialClusterStateVersion = randomNonNegativeLong();
final int numberOfActiveAllocationsIds = randomIntBetween(2, 16);
final int numberOfInitializingIds = randomIntBetween(2, 16);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public IndexShardSnapshotStatus getShardSnapshotStatus(SnapshotId snapshotId, In
assertThat("Expecting all snapshot shard size fetches to execute a Reroute", reroutes.get(), equalTo(maxShardsToCreate));
}

public void testNoLongerMaster() throws Exception {
public void testNoLongerClusterManager() throws Exception {
final InternalSnapshotsInfoService snapshotsInfoService = new InternalSnapshotsInfoService(
Settings.EMPTY,
clusterService,
Expand Down

0 comments on commit 737843f

Please sign in to comment.