Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace internal usages of 'master' term in 'server/src/internalClusterTest' directory #2521

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
}

public void testNodesInfoTimeout() {
String masterNode = internalCluster().startMasterOnlyNode();
String clusterManagerNode = internalCluster().startMasterOnlyNode();
String dataNode = internalCluster().startDataOnlyNode();
String anotherDataNode = internalCluster().startDataOnlyNode();

Expand All @@ -65,11 +65,11 @@ public void testNodesInfoTimeout() {
nodes.add(node.getNode().getName());
}
assertThat(response.getNodes().size(), equalTo(2));
assertThat(nodes.contains(masterNode), is(true));
assertThat(nodes.contains(clusterManagerNode), is(true));
}

public void testNodesStatsTimeout() {
String masterNode = internalCluster().startMasterOnlyNode();
String clusterManagerNode = internalCluster().startMasterOnlyNode();
String dataNode = internalCluster().startDataOnlyNode();
String anotherDataNode = internalCluster().startDataOnlyNode();
TimeValue timeout = TimeValue.timeValueMillis(1000);
Expand All @@ -87,11 +87,11 @@ public void testNodesStatsTimeout() {
nodes.add(node.getNode().getName());
}
assertThat(response.getNodes().size(), equalTo(2));
assertThat(nodes.contains(masterNode), is(true));
assertThat(nodes.contains(clusterManagerNode), is(true));
}

public void testListTasksTimeout() {
String masterNode = internalCluster().startMasterOnlyNode();
String clusterManagerNode = internalCluster().startMasterOnlyNode();
String dataNode = internalCluster().startDataOnlyNode();
String anotherDataNode = internalCluster().startDataOnlyNode();
TimeValue timeout = TimeValue.timeValueMillis(1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,17 @@ public void testTaskCounts() {
assertThat(response.getTasks().size(), greaterThanOrEqualTo(cluster().numDataNodes()));
}

public void testMasterNodeOperationTasks() {
public void testClusterManagerNodeOperationTasks() {
registerTaskManagerListeners(ClusterHealthAction.NAME);

// First run the health on the master node - should produce only one task on the master node
// First run the health on the cluster-manager node - should produce only one task on the cluster-manager node
internalCluster().masterClient().admin().cluster().prepareHealth().get();
assertEquals(1, numberOfEvents(ClusterHealthAction.NAME, Tuple::v1)); // counting only registration events
assertEquals(1, numberOfEvents(ClusterHealthAction.NAME, event -> event.v1() == false)); // counting only unregistration events

resetTaskManagerListeners(ClusterHealthAction.NAME);

// Now run the health on a non-master node - should produce one task on master and one task on another node
// Now run the health on a non-cluster-manager node - should produce one task on cluster-manager and one task on another node
internalCluster().nonMasterClient().admin().cluster().prepareHealth().get();
assertEquals(2, numberOfEvents(ClusterHealthAction.NAME, Tuple::v1)); // counting only registration events
assertEquals(2, numberOfEvents(ClusterHealthAction.NAME, event -> event.v1() == false)); // counting only unregistration events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ public void runRepeatedlyWhileChangingMaster(Runnable runnable) throws Exception
String value = "none";
while (shutdown.get() == false) {
value = "none".equals(value) ? "all" : "none";
final String nonMasterNode = randomValueOtherThan(masterName, () -> randomFrom(internalCluster().getNodeNames()));
final String nonClusterManagerNode = randomValueOtherThan(masterName, () -> randomFrom(internalCluster().getNodeNames()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the variable masterName need to change as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @VachaShah, thank you so much for your review! You are so careful 👍😁! Yes.. it needs to be changed. I will search for the "master" word completely.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Finally I did another scan. The variable name masterName has been changed. 👍

assertAcked(
client(nonMasterNode).admin()
client(nonClusterManagerNode).admin()
.cluster()
.prepareUpdateSettings()
.setPersistentSettings(Settings.builder().put(CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), value))
Expand Down Expand Up @@ -235,8 +235,8 @@ public void runRepeatedlyWhileChangingMaster(Runnable runnable) throws Exception
}

assertBusy(() -> {
final String nonMasterNode = randomValueOtherThan(masterName, () -> randomFrom(internalCluster().getNodeNames()));
final String claimedMasterName = internalCluster().getMasterName(nonMasterNode);
final String nonClusterManagerNode = randomValueOtherThan(masterName, () -> randomFrom(internalCluster().getNodeNames()));
final String claimedMasterName = internalCluster().getMasterName(nonClusterManagerNode);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change claimedMasterName to claimedClusterManagerName?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed the variable name. 😄

assertThat(claimedMasterName, not(equalTo(masterName)));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@
public class ClusterStateDiffIT extends OpenSearchIntegTestCase {
public void testClusterStateDiffSerialization() throws Exception {
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(ClusterModule.getNamedWriteables());
DiscoveryNode masterNode = randomNode("master");
DiscoveryNode clusterManagerNode = randomNode("master");
DiscoveryNode otherNode = randomNode("other");
DiscoveryNodes discoveryNodes = DiscoveryNodes.builder().add(masterNode).add(otherNode).localNodeId(masterNode.getId()).build();
DiscoveryNodes discoveryNodes = DiscoveryNodes.builder()
.add(clusterManagerNode)
.add(otherNode)
.localNodeId(clusterManagerNode.getId())
.build();
ClusterState clusterState = ClusterState.builder(new ClusterName("test")).nodes(discoveryNodes).build();
ClusterState clusterStateFromDiffs = ClusterState.Builder.fromBytes(
ClusterState.Builder.toBytes(clusterState),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@ public void testThreeNodesNoMasterBlock() throws Exception {
assertHitCount(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet(), 100);
}

List<String> nonMasterNodes = new ArrayList<>(
List<String> nonClusterManagerNodes = new ArrayList<>(
Sets.difference(Sets.newHashSet(internalCluster().getNodeNames()), Collections.singleton(internalCluster().getMasterName()))
);
Settings nonMasterDataPathSettings1 = internalCluster().dataPathSettings(nonMasterNodes.get(0));
Settings nonMasterDataPathSettings2 = internalCluster().dataPathSettings(nonMasterNodes.get(1));
Settings nonMasterDataPathSettings1 = internalCluster().dataPathSettings(nonClusterManagerNodes.get(0));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Variable name change for nonMasterDataPathSettings1 and nonMasterDataPathSettings2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed the variable name. 👍

Settings nonMasterDataPathSettings2 = internalCluster().dataPathSettings(nonClusterManagerNodes.get(1));
internalCluster().stopRandomNonMasterNode();
internalCluster().stopRandomNonMasterNode();

Expand Down Expand Up @@ -393,7 +393,7 @@ public void onFailure(String source, Exception e) {
// otherwise persistent setting (which is a part of accepted state on old master) will be propagated to other nodes
logger.debug("--> wait for master to be elected in major partition");
assertBusy(() -> {
DiscoveryNode masterNode = internalCluster().client(randomFrom(otherNodes))
DiscoveryNode clusterManagerNode = internalCluster().client(randomFrom(otherNodes))
.admin()
.cluster()
.prepareState()
Expand All @@ -402,8 +402,8 @@ public void onFailure(String source, Exception e) {
.getState()
.nodes()
.getMasterNode();
assertThat(masterNode, notNullValue());
assertThat(masterNode.getName(), not(equalTo(master)));
assertThat(clusterManagerNode, notNullValue());
assertThat(clusterManagerNode.getName(), not(equalTo(master)));
});

partition.stopDisrupting();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,20 +479,20 @@ public boolean clearData(String nodeName) {

public void testNoInitialBootstrapAfterDetach() throws Exception {
internalCluster().setBootstrapMasterNodeIndex(0);
String masterNode = internalCluster().startMasterOnlyNode();
Settings masterNodeDataPathSettings = internalCluster().dataPathSettings(masterNode);
String clusterManagerNode = internalCluster().startMasterOnlyNode();
Settings clusterManagerNodeDataPathSettings = internalCluster().dataPathSettings(clusterManagerNode);
internalCluster().stopCurrentMasterNode();

final Environment environment = TestEnvironment.newEnvironment(
Settings.builder().put(internalCluster().getDefaultSettings()).put(masterNodeDataPathSettings).build()
Settings.builder().put(internalCluster().getDefaultSettings()).put(clusterManagerNodeDataPathSettings).build()
);
detachCluster(environment);

String node = internalCluster().startMasterOnlyNode(
Settings.builder()
// give the cluster 2 seconds to elect the master (it should not)
.put(DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING.getKey(), "2s")
.put(masterNodeDataPathSettings)
.put(clusterManagerNodeDataPathSettings)
.build()
);

Expand All @@ -504,8 +504,8 @@ public void testNoInitialBootstrapAfterDetach() throws Exception {

public void testCanRunUnsafeBootstrapAfterErroneousDetachWithoutLoosingMetadata() throws Exception {
internalCluster().setBootstrapMasterNodeIndex(0);
String masterNode = internalCluster().startMasterOnlyNode();
Settings masterNodeDataPathSettings = internalCluster().dataPathSettings(masterNode);
String clusterManagerNode = internalCluster().startMasterOnlyNode();
Settings clusterManagerNodeDataPathSettings = internalCluster().dataPathSettings(clusterManagerNode);
ClusterUpdateSettingsRequest req = new ClusterUpdateSettingsRequest().persistentSettings(
Settings.builder().put(INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey(), "1234kb")
);
Expand All @@ -514,17 +514,17 @@ public void testCanRunUnsafeBootstrapAfterErroneousDetachWithoutLoosingMetadata(
ClusterState state = internalCluster().client().admin().cluster().prepareState().execute().actionGet().getState();
assertThat(state.metadata().persistentSettings().get(INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey()), equalTo("1234kb"));

ensureReadOnlyBlock(false, masterNode);
ensureReadOnlyBlock(false, clusterManagerNode);

internalCluster().stopCurrentMasterNode();

final Environment environment = TestEnvironment.newEnvironment(
Settings.builder().put(internalCluster().getDefaultSettings()).put(masterNodeDataPathSettings).build()
Settings.builder().put(internalCluster().getDefaultSettings()).put(clusterManagerNodeDataPathSettings).build()
);
detachCluster(environment);
unsafeBootstrap(environment); // read-only block will remain same as one before bootstrap, in this case it is false

String masterNode2 = internalCluster().startMasterOnlyNode(masterNodeDataPathSettings);
String masterNode2 = internalCluster().startMasterOnlyNode(clusterManagerNodeDataPathSettings);
Copy link
Collaborator

Choose a reason for hiding this comment

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

masterNode2 -> clusterManagerNode2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed the variable name. 👍

ensureGreen();
ensureReadOnlyBlock(false, masterNode2);

Expand All @@ -534,8 +534,8 @@ public void testCanRunUnsafeBootstrapAfterErroneousDetachWithoutLoosingMetadata(

public void testUnsafeBootstrapWithApplyClusterReadOnlyBlockAsFalse() throws Exception {
internalCluster().setBootstrapMasterNodeIndex(0);
String masterNode = internalCluster().startMasterOnlyNode();
Settings masterNodeDataPathSettings = internalCluster().dataPathSettings(masterNode);
String clusterManagerNode = internalCluster().startMasterOnlyNode();
Settings clusterManagerNodeDataPathSettings = internalCluster().dataPathSettings(clusterManagerNode);
ClusterUpdateSettingsRequest req = new ClusterUpdateSettingsRequest().persistentSettings(
Settings.builder().put(INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey(), "1234kb")
);
Expand All @@ -544,18 +544,18 @@ public void testUnsafeBootstrapWithApplyClusterReadOnlyBlockAsFalse() throws Exc
ClusterState state = internalCluster().client().admin().cluster().prepareState().execute().actionGet().getState();
assertThat(state.metadata().persistentSettings().get(INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey()), equalTo("1234kb"));

ensureReadOnlyBlock(false, masterNode);
ensureReadOnlyBlock(false, clusterManagerNode);

internalCluster().stopCurrentMasterNode();

final Environment environment = TestEnvironment.newEnvironment(
Settings.builder().put(internalCluster().getDefaultSettings()).put(masterNodeDataPathSettings).build()
Settings.builder().put(internalCluster().getDefaultSettings()).put(clusterManagerNodeDataPathSettings).build()
);
unsafeBootstrap(environment, false, false);

String masterNode2 = internalCluster().startMasterOnlyNode(masterNodeDataPathSettings);
String clusterManagerNode2 = internalCluster().startMasterOnlyNode(clusterManagerNodeDataPathSettings);
ensureGreen();
ensureReadOnlyBlock(false, masterNode2);
ensureReadOnlyBlock(false, clusterManagerNode2);

state = internalCluster().client().admin().cluster().prepareState().execute().actionGet().getState();
assertThat(state.metadata().settings().get(INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey()), equalTo("1234kb"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ public void testNoShardRelocationsOccurWhenElectedMasterNodeFails() throws Excep
}

public void testHandleNodeJoin_incompatibleClusterState() throws InterruptedException, ExecutionException, TimeoutException {
String masterNode = internalCluster().startMasterOnlyNode();
String clusterManagerNode = internalCluster().startMasterOnlyNode();
String node1 = internalCluster().startNode();
ClusterService clusterService = internalCluster().getInstance(ClusterService.class, node1);
Coordinator coordinator = (Coordinator) internalCluster().getInstance(Discovery.class, masterNode);
Coordinator coordinator = (Coordinator) internalCluster().getInstance(Discovery.class, clusterManagerNode);
final ClusterState state = clusterService.state();
Metadata.Builder mdBuilder = Metadata.builder(state.metadata());
mdBuilder.putCustom(CustomMetadata.TYPE, new CustomMetadata("data"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void testFailedRecoveryOnAllocateStalePrimaryRequiresAnotherAllocateStale

// initial set up
final String indexName = "index42";
final String master = internalCluster().startMasterOnlyNode();
final String clusterManager = internalCluster().startMasterOnlyNode();
String node1 = internalCluster().startNode();
createIndex(
indexName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,26 +338,26 @@ public void testRejoinDocumentExistsInAllShardCopies() throws Exception {
// simulate handling of sending shard failure during an isolation
public void testSendingShardFailure() throws Exception {
List<String> nodes = startCluster(3);
String masterNode = internalCluster().getMasterName();
List<String> nonMasterNodes = nodes.stream().filter(node -> !node.equals(masterNode)).collect(Collectors.toList());
String nonMasterNode = randomFrom(nonMasterNodes);
String clusterManagerNode = internalCluster().getMasterName();
List<String> nonClusterManagerNodes = nodes.stream().filter(node -> !node.equals(clusterManagerNode)).collect(Collectors.toList());
String nonClusterManagerNode = randomFrom(nonClusterManagerNodes);
assertAcked(
prepareCreate("test").setSettings(
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 3).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 2)
)
);
ensureGreen();
String nonMasterNodeId = internalCluster().clusterService(nonMasterNode).localNode().getId();
String nonClusterManagerNodeId = internalCluster().clusterService(nonClusterManagerNode).localNode().getId();

// fail a random shard
ShardRouting failedShard = randomFrom(
clusterService().state().getRoutingNodes().node(nonMasterNodeId).shardsWithState(ShardRoutingState.STARTED)
clusterService().state().getRoutingNodes().node(nonClusterManagerNodeId).shardsWithState(ShardRoutingState.STARTED)
);
ShardStateAction service = internalCluster().getInstance(ShardStateAction.class, nonMasterNode);
ShardStateAction service = internalCluster().getInstance(ShardStateAction.class, nonClusterManagerNode);
CountDownLatch latch = new CountDownLatch(1);
AtomicBoolean success = new AtomicBoolean();

String isolatedNode = randomBoolean() ? masterNode : nonMasterNode;
String isolatedNode = randomBoolean() ? clusterManagerNode : nonClusterManagerNode;
TwoPartitions partitions = isolateNode(isolatedNode);
// we cannot use the NetworkUnresponsive disruption type here as it will swallow the "shard failed" request, calling neither
// onSuccess nor onFailure on the provided listener.
Expand Down Expand Up @@ -385,10 +385,10 @@ public void onFailure(Exception e) {
}
);

if (isolatedNode.equals(nonMasterNode)) {
assertNoMaster(nonMasterNode);
if (isolatedNode.equals(nonClusterManagerNode)) {
assertNoMaster(nonClusterManagerNode);
} else {
ensureStableCluster(2, nonMasterNode);
ensureStableCluster(2, nonClusterManagerNode);
}

// heal the partition
Expand All @@ -410,10 +410,10 @@ public void onFailure(Exception e) {
}

public void testCannotJoinIfMasterLostDataFolder() throws Exception {
String masterNode = internalCluster().startMasterOnlyNode();
String clusterManagerNode = internalCluster().startMasterOnlyNode();
String dataNode = internalCluster().startDataOnlyNode();

internalCluster().restartNode(masterNode, new InternalTestCluster.RestartCallback() {
internalCluster().restartNode(clusterManagerNode, new InternalTestCluster.RestartCallback() {
@Override
public boolean clearData(String nodeName) {
return true;
Expand Down Expand Up @@ -442,9 +442,9 @@ public boolean validateClusterForming() {
});

assertBusy(() -> {
assertFalse(internalCluster().client(masterNode).admin().cluster().prepareHealth().get().isTimedOut());
assertFalse(internalCluster().client(clusterManagerNode).admin().cluster().prepareHealth().get().isTimedOut());
assertTrue(
internalCluster().client(masterNode)
internalCluster().client(clusterManagerNode)
.admin()
.cluster()
.prepareHealth()
Expand Down
Loading