Skip to content

Commit 296fa09

Browse files
author
Tianli Feng
authored
Replace internal usages of 'master' term in 'server/src/test' directory (#2520)
* Replace the non-inclusive terminology "master" with "cluster manager" in code comments, internal variable/method/class names, in `server/src/test` directory. * Backwards compatibility is not impacted. * Add a new unit test `testDeprecatedMasterNodeFilter()` to validate using `master:true` or `master:false` can filter the node in [Cluster Stats](https://opensearch.org/docs/latest/opensearch/rest-api/cluster-stats/) API, after the `master` role is deprecated in PR #2424 Signed-off-by: Tianli Feng <ftianli@amazon.com>
1 parent 5099780 commit 296fa09

File tree

59 files changed

+736
-625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+736
-625
lines changed

server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ public void onFailure(Exception e) {
386386
);
387387

388388
if (isolatedNode.equals(nonClusterManagerNode)) {
389-
assertNoMaster(nonClusterManagerNode);
389+
assertNoClusterManager(nonClusterManagerNode);
390390
} else {
391391
ensureStableCluster(2, nonClusterManagerNode);
392392
}

server/src/internalClusterTest/java/org/opensearch/discovery/ClusterManagerDisruptionIT.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void testClusterManagerNodeGCs() throws Exception {
9191

9292
logger.info("waiting for nodes to de-elect cluster-manager [{}]", oldClusterManagerNode);
9393
for (String node : oldNonClusterManagerNodesSet) {
94-
assertDifferentMaster(node, oldClusterManagerNode);
94+
assertDifferentClusterManager(node, oldClusterManagerNode);
9595
}
9696

9797
logger.info("waiting for nodes to elect a new cluster-manager");
@@ -107,7 +107,7 @@ public void testClusterManagerNodeGCs() throws Exception {
107107
// make sure all nodes agree on cluster-manager
108108
String newClusterManager = internalCluster().getMasterName();
109109
assertThat(newClusterManager, not(equalTo(oldClusterManagerNode)));
110-
assertMaster(newClusterManager, nodes);
110+
assertClusterManager(newClusterManager, nodes);
111111
}
112112

113113
/**
@@ -137,7 +137,7 @@ public void testIsolateClusterManagerAndVerifyClusterStateConsensus() throws Exc
137137
ensureStableCluster(2, nonIsolatedNode);
138138

139139
// make sure isolated need picks up on things.
140-
assertNoMaster(isolatedNode, TimeValue.timeValueSeconds(40));
140+
assertNoClusterManager(isolatedNode, TimeValue.timeValueSeconds(40));
141141

142142
// restore isolation
143143
networkDisruption.stopDisrupting();
@@ -227,7 +227,7 @@ public void testVerifyApiBlocksDuringPartition() throws Exception {
227227
// continuously ping until network failures have been resolved. However
228228
// It may a take a bit before the node detects it has been cut off from the elected cluster-manager
229229
logger.info("waiting for isolated node [{}] to have no cluster-manager", isolatedNode);
230-
assertNoMaster(isolatedNode, NoMasterBlockService.NO_MASTER_BLOCK_WRITES, TimeValue.timeValueSeconds(30));
230+
assertNoClusterManager(isolatedNode, NoMasterBlockService.NO_MASTER_BLOCK_WRITES, TimeValue.timeValueSeconds(30));
231231

232232
logger.info("wait until elected cluster-manager has been removed and a new 2 node cluster was from (via [{}])", isolatedNode);
233233
ensureStableCluster(2, nonIsolatedNode);
@@ -273,7 +273,7 @@ public void testVerifyApiBlocksDuringPartition() throws Exception {
273273
// continuously ping until network failures have been resolved. However
274274
// It may a take a bit before the node detects it has been cut off from the elected cluster-manager
275275
logger.info("waiting for isolated node [{}] to have no cluster-manager", isolatedNode);
276-
assertNoMaster(isolatedNode, NoMasterBlockService.NO_MASTER_BLOCK_ALL, TimeValue.timeValueSeconds(30));
276+
assertNoClusterManager(isolatedNode, NoMasterBlockService.NO_MASTER_BLOCK_ALL, TimeValue.timeValueSeconds(30));
277277

278278
// make sure we have stable cluster & cross partition recoveries are canceled by the removal of the missing node
279279
// the unresponsive partition causes recoveries to only time out after 15m (default) and these will cause

server/src/internalClusterTest/java/org/opensearch/discovery/DiscoveryDisruptionIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void testClusterJoinDespiteOfPublishingIssues() throws Exception {
8181
);
8282
nonClusterManagerTransportService.addFailToSendNoConnectRule(clusterManagerTranspotService);
8383

84-
assertNoMaster(nonClusterManagerNode);
84+
assertNoClusterManager(nonClusterManagerNode);
8585

8686
logger.info(
8787
"blocking cluster state publishing from cluster-manager [{}] to non cluster-manager [{}]",
@@ -166,7 +166,7 @@ public void testElectClusterManagerWithLatestVersion() throws Exception {
166166
logger.info("--> forcing a complete election to make sure \"preferred\" cluster-manager is elected");
167167
isolateAllNodes.startDisrupting();
168168
for (String node : nodes) {
169-
assertNoMaster(node);
169+
assertNoClusterManager(node);
170170
}
171171
internalCluster().clearDisruptionScheme();
172172
ensureStableCluster(3);
@@ -194,7 +194,7 @@ public void testElectClusterManagerWithLatestVersion() throws Exception {
194194
logger.info("--> forcing a complete election again");
195195
isolateAllNodes.startDisrupting();
196196
for (String node : nodes) {
197-
assertNoMaster(node);
197+
assertNoClusterManager(node);
198198
}
199199

200200
isolateAllNodes.stopDisrupting();
@@ -242,7 +242,7 @@ public void testNodeNotReachableFromClusterManager() throws Exception {
242242
ensureStableCluster(2, clusterManagerNode);
243243

244244
logger.info("waiting for [{}] to have no cluster-manager", nonClusterManagerNode);
245-
assertNoMaster(nonClusterManagerNode);
245+
assertNoClusterManager(nonClusterManagerNode);
246246

247247
logger.info("healing partition and checking cluster reforms");
248248
clusterManagerTransportService.clearAllRules();

server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public void testWithdrawsVotesFromNodesMatchingWildcard() throws InterruptedExce
252252
assertWarnings(AddVotingConfigExclusionsRequest.DEPRECATION_MESSAGE);
253253
}
254254

255-
public void testWithdrawsVotesFromAllMasterEligibleNodes() throws InterruptedException {
255+
public void testWithdrawsVotesFromAllClusterManagerEligibleNodes() throws InterruptedException {
256256
final CountDownLatch countDownLatch = new CountDownLatch(2);
257257

258258
clusterStateObserver.waitForNextChange(new AdjustConfigurationForExclusions(countDownLatch));
@@ -349,14 +349,14 @@ public void testReturnsErrorIfNoMatchingNodeDescriptions() throws InterruptedExc
349349
assertWarnings(AddVotingConfigExclusionsRequest.DEPRECATION_MESSAGE);
350350
}
351351

352-
public void testOnlyMatchesMasterEligibleNodes() throws InterruptedException {
352+
public void testOnlyMatchesClusterManagerEligibleNodes() throws InterruptedException {
353353
final CountDownLatch countDownLatch = new CountDownLatch(1);
354354
final SetOnce<TransportException> exceptionHolder = new SetOnce<>();
355355

356356
transportService.sendRequest(
357357
localNode,
358358
AddVotingConfigExclusionsAction.NAME,
359-
makeRequestWithNodeDescriptions("_all", "master:false"),
359+
makeRequestWithNodeDescriptions("_all", "cluster_manager:false"),
360360
expectError(e -> {
361361
exceptionHolder.set(e);
362362
countDownLatch.countDown();
@@ -368,7 +368,7 @@ public void testOnlyMatchesMasterEligibleNodes() throws InterruptedException {
368368
assertThat(rootCause, instanceOf(IllegalArgumentException.class));
369369
assertThat(
370370
rootCause.getMessage(),
371-
equalTo("add voting config exclusions request for [_all, master:false] matched no cluster-manager-eligible nodes")
371+
equalTo("add voting config exclusions request for [_all, cluster_manager:false] matched no cluster-manager-eligible nodes")
372372
);
373373
assertWarnings(AddVotingConfigExclusionsRequest.DEPRECATION_MESSAGE);
374374
}

server/src/test/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponsesTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ public void testClusterHealth() throws IOException {
110110
assertThat(clusterHealth.getActiveShardsPercent(), is(allOf(greaterThanOrEqualTo(0.0), lessThanOrEqualTo(100.0))));
111111
}
112112

113-
public void testClusterHealthVerifyMasterNodeDiscovery() throws IOException {
113+
public void testClusterHealthVerifyClusterManagerNodeDiscovery() throws IOException {
114114
DiscoveryNode localNode = new DiscoveryNode("node", OpenSearchTestCase.buildNewFakeTransportAddress(), Version.CURRENT);
115-
// set the node information to verify master_node discovery in ClusterHealthResponse
115+
// set the node information to verify cluster_manager_node discovery in ClusterHealthResponse
116116
ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
117117
.nodes(DiscoveryNodes.builder().add(localNode).localNodeId(localNode.getId()).masterNodeId(localNode.getId()))
118118
.build();

server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/CancellableTasksTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,12 +474,12 @@ public void onFailure(Exception e) {
474474
for (int i = 1; i < testNodes.length; i++) {
475475
discoveryNodes[i - 1] = testNodes[i].discoveryNode();
476476
}
477-
DiscoveryNode master = discoveryNodes[0];
477+
DiscoveryNode clusterManager = discoveryNodes[0];
478478
for (int i = 1; i < testNodes.length; i++) {
479479
// Notify only nodes that should remain in the cluster
480480
setState(
481481
testNodes[i].clusterService,
482-
ClusterStateCreationUtils.state(testNodes[i].discoveryNode(), master, discoveryNodes)
482+
ClusterStateCreationUtils.state(testNodes[i].discoveryNode(), clusterManager, discoveryNodes)
483483
);
484484
}
485485
if (randomBoolean()) {

server/src/test/java/org/opensearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ public static void connectNodes(TestNode... nodes) {
257257
for (int i = 0; i < nodes.length; i++) {
258258
discoveryNodes[i] = nodes[i].discoveryNode();
259259
}
260-
DiscoveryNode master = discoveryNodes[0];
260+
DiscoveryNode clusterManager = discoveryNodes[0];
261261
for (TestNode node : nodes) {
262-
setState(node.clusterService, ClusterStateCreationUtils.state(node.discoveryNode(), master, discoveryNodes));
262+
setState(node.clusterService, ClusterStateCreationUtils.state(node.discoveryNode(), clusterManager, discoveryNodes));
263263
}
264264
for (TestNode nodeA : nodes) {
265265
for (TestNode nodeB : nodes) {

server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteRequestTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public void testEqualsAndHashCode() {
161161
assertEquals(request, copy);
162162
assertEquals(request.hashCode(), copy.hashCode());
163163

164-
// Changing masterNodeTime makes requests not equal
164+
// Changing clusterManagerNodeTimeout makes requests not equal
165165
copy.masterNodeTimeout(timeValueMillis(request.masterNodeTimeout().millis() + 1));
166166
assertNotEquals(request, copy);
167167
assertNotEquals(request.hashCode(), copy.hashCode());

server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public void testDefaultMaxConcurrentSearches() {
260260
}
261261
builder.add(
262262
new DiscoveryNode(
263-
"master",
263+
"cluster_manager",
264264
buildNewFakeTransportAddress(),
265265
Collections.emptyMap(),
266266
Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),

server/src/test/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -366,29 +366,29 @@ public void testOneRequestIsSentToEachNodeHoldingAShard() {
366366
}
367367
}
368368

369-
// simulate the master being removed from the cluster but before a new master is elected
370-
// as such, the shards assigned to the master will still show up in the cluster state as assigned to a node but
371-
// that node will not be in the local cluster state on any node that has detected the master as failing
369+
// simulate the cluster-manager being removed from the cluster but before a new cluster-manager is elected
370+
// as such, the shards assigned to the cluster-manager will still show up in the cluster state as assigned to a node but
371+
// that node will not be in the local cluster state on any node that has detected the cluster-manager as failing
372372
// in this case, such a shard should be treated as unassigned
373-
public void testRequestsAreNotSentToFailedMaster() {
373+
public void testRequestsAreNotSentToFailedClusterManager() {
374374
Request request = new Request(new String[] { TEST_INDEX });
375375
PlainActionFuture<Response> listener = new PlainActionFuture<>();
376376

377-
DiscoveryNode masterNode = clusterService.state().nodes().getMasterNode();
377+
DiscoveryNode clusterManagerNode = clusterService.state().nodes().getMasterNode();
378378
DiscoveryNodes.Builder builder = DiscoveryNodes.builder(clusterService.state().getNodes());
379-
builder.remove(masterNode.getId());
379+
builder.remove(clusterManagerNode.getId());
380380

381381
setState(clusterService, ClusterState.builder(clusterService.state()).nodes(builder));
382382

383383
action.new AsyncAction(null, request, listener).start();
384384

385385
Map<String, List<CapturingTransport.CapturedRequest>> capturedRequests = transport.getCapturedRequestsByTargetNodeAndClear();
386386

387-
// the master should not be in the list of nodes that requests were sent to
387+
// the cluster manager should not be in the list of nodes that requests were sent to
388388
ShardsIterator shardIt = clusterService.state().routingTable().allShards(new String[] { TEST_INDEX });
389389
Set<String> set = new HashSet<>();
390390
for (ShardRouting shard : shardIt) {
391-
if (!shard.currentNodeId().equals(masterNode.getId())) {
391+
if (!shard.currentNodeId().equals(clusterManagerNode.getId())) {
392392
set.add(shard.currentNodeId());
393393
}
394394
}
@@ -399,7 +399,7 @@ public void testRequestsAreNotSentToFailedMaster() {
399399
// check requests were sent to the right nodes
400400
assertEquals(set, capturedRequests.keySet());
401401
for (Map.Entry<String, List<CapturingTransport.CapturedRequest>> entry : capturedRequests.entrySet()) {
402-
// check one request was sent to each non-master node
402+
// check one request was sent to each non-cluster-manager node
403403
assertEquals(1, entry.getValue().size());
404404
}
405405
}
@@ -456,13 +456,13 @@ public void testResultAggregation() throws ExecutionException, InterruptedExcept
456456
Request request = new Request(new String[] { TEST_INDEX });
457457
PlainActionFuture<Response> listener = new PlainActionFuture<>();
458458

459-
// simulate removing the master
460-
final boolean simulateFailedMasterNode = rarely();
461-
DiscoveryNode failedMasterNode = null;
462-
if (simulateFailedMasterNode) {
463-
failedMasterNode = clusterService.state().nodes().getMasterNode();
459+
// simulate removing the cluster-manager
460+
final boolean simulateFailedClusterManagerNode = rarely();
461+
DiscoveryNode failedClusterManagerNode = null;
462+
if (simulateFailedClusterManagerNode) {
463+
failedClusterManagerNode = clusterService.state().nodes().getMasterNode();
464464
DiscoveryNodes.Builder builder = DiscoveryNodes.builder(clusterService.state().getNodes());
465-
builder.remove(failedMasterNode.getId());
465+
builder.remove(failedClusterManagerNode.getId());
466466
builder.masterNodeId(null);
467467

468468
setState(clusterService, ClusterState.builder(clusterService.state()).nodes(builder));
@@ -511,8 +511,8 @@ public void testResultAggregation() throws ExecutionException, InterruptedExcept
511511
transport.handleResponse(requestId, nodeResponse);
512512
}
513513
}
514-
if (simulateFailedMasterNode) {
515-
totalShards += map.get(failedMasterNode.getId()).size();
514+
if (simulateFailedClusterManagerNode) {
515+
totalShards += map.get(failedClusterManagerNode.getId()).size();
516516
}
517517

518518
Response response = listener.get();

0 commit comments

Comments
 (0)