Skip to content

Commit

Permalink
Correct import static org.opensearch.test.NodeRoles.nonClusterManager…
Browse files Browse the repository at this point in the history
…Node

Signed-off-by: Tianli Feng <[email protected]>
  • Loading branch information
Tianli Feng committed Jul 21, 2022
1 parent d00d1eb commit 803db9c
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.discovery.ClusterManagerNotDiscoveredException;
import org.opensearch.index.query.QueryBuilders;
import org.opensearch.test.NodeRoles;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.opensearch.test.OpenSearchIntegTestCase.ClusterScope;
import org.opensearch.test.OpenSearchIntegTestCase.Scope;
import org.opensearch.test.InternalTestCluster;

import java.io.IOException;

import static org.opensearch.test.NodeRoles.clusterManagerNode;
import static org.opensearch.test.NodeRoles.dataOnlyNode;
import static org.opensearch.test.NodeRoles.nonDataNode;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
Expand Down Expand Up @@ -129,7 +129,7 @@ public void testSimpleOnlyClusterManagerNodeElection() throws IOException {

logger.info("--> start previous cluster-manager node again");
final String nextClusterManagerEligibleNodeName = internalCluster().startNode(
Settings.builder().put(nonDataNode(NodeRoles.clusterManagerNode())).put(clusterManagerDataPathSettings)
Settings.builder().put(nonDataNode(clusterManagerNode())).put(clusterManagerDataPathSettings)
);
assertThat(
internalCluster().nonClusterManagerClient()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@
import org.opensearch.action.admin.cluster.health.ClusterHealthResponse;
import org.opensearch.common.Priority;
import org.opensearch.common.settings.Settings;
import org.opensearch.test.NodeRoles;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.opensearch.test.OpenSearchIntegTestCase.ClusterScope;
import org.opensearch.test.OpenSearchIntegTestCase.Scope;

import static org.opensearch.test.NodeRoles.nonClusterManagerNode;
import static org.opensearch.test.NodeRoles.nonDataNode;
import static org.hamcrest.Matchers.equalTo;

@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
public class UpdateSettingsValidationIT extends OpenSearchIntegTestCase {
public void testUpdateSettingsValidation() throws Exception {
internalCluster().startNodes(nonDataNode(), NodeRoles.nonClusterManagerNode(), NodeRoles.nonClusterManagerNode());
internalCluster().startNodes(nonDataNode(), nonClusterManagerNode(), nonClusterManagerNode());

createIndex("test");
NumShards test = getNumShards("test");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
import org.opensearch.indices.IndicesService;
import org.opensearch.indices.recovery.PeerRecoveryTargetService;
import org.opensearch.plugins.Plugin;
import org.opensearch.test.NodeRoles;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.opensearch.test.OpenSearchIntegTestCase.ClusterScope;
import org.opensearch.test.OpenSearchIntegTestCase.Scope;
Expand Down Expand Up @@ -112,8 +111,8 @@ protected void ensureClusterStateConsistency() throws IOException {

public void testIndexCleanup() throws Exception {
internalCluster().startNode(nonDataNode());
final String node_1 = internalCluster().startNode(NodeRoles.nonClusterManagerNode());
final String node_2 = internalCluster().startNode(NodeRoles.nonClusterManagerNode());
final String node_1 = internalCluster().startNode(nonClusterManagerNode());
final String node_2 = internalCluster().startNode(nonClusterManagerNode());
logger.info("--> creating index [test] with one shard and on replica");
assertAcked(
prepareCreate("test").setSettings(
Expand All @@ -134,7 +133,7 @@ public void testIndexCleanup() throws Exception {
assertThat(Files.exists(indexDirectory(node_2, index)), equalTo(true));

logger.info("--> starting node server3");
final String node_3 = internalCluster().startNode(NodeRoles.nonClusterManagerNode());
final String node_3 = internalCluster().startNode(nonClusterManagerNode());
logger.info("--> running cluster_health");
ClusterHealthResponse clusterHealth = client().admin()
.cluster()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
import org.opensearch.rest.action.admin.cluster.RestClusterStateAction;
import org.opensearch.rest.action.admin.cluster.RestGetRepositoriesAction;
import org.opensearch.snapshots.mockstore.MockRepository;
import org.opensearch.test.NodeRoles;
import org.opensearch.test.OpenSearchIntegTestCase.ClusterScope;
import org.opensearch.test.OpenSearchIntegTestCase.Scope;
import org.opensearch.test.InternalTestCluster;
Expand Down Expand Up @@ -125,6 +124,7 @@
import java.util.function.Consumer;

import static org.opensearch.index.seqno.RetentionLeaseActions.RETAIN_ALL;
import static org.opensearch.test.NodeRoles.nonClusterManagerNode;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertFutureThrows;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertRequestBuilderThrows;
Expand Down Expand Up @@ -760,7 +760,7 @@ public void testRegistrationFailure() {
internalCluster().startNode();
logger.info("--> start second node");
// Make sure the first node is elected as cluster-manager
internalCluster().startNode(NodeRoles.nonClusterManagerNode());
internalCluster().startNode(nonClusterManagerNode());
// Register mock repositories
for (int i = 0; i < 5; i++) {
clusterAdmin().preparePutRepository("test-repo" + i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.opensearch.cluster.node.DiscoveryNodeRole;
import org.opensearch.common.settings.Settings;
import org.opensearch.discovery.DiscoveryModule;
import org.opensearch.test.NodeRoles;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.test.transport.MockTransport;
import org.opensearch.transport.TransportRequest;
Expand All @@ -57,6 +56,7 @@
import static org.opensearch.cluster.coordination.ClusterBootstrapService.UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING;
import static org.opensearch.common.settings.Settings.builder;
import static org.opensearch.node.Node.NODE_NAME_SETTING;
import static org.opensearch.test.NodeRoles.nonClusterManagerNode;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
Expand Down Expand Up @@ -298,7 +298,7 @@ public void testFailBootstrapNonMasterEligibleNodeWithSingleNodeDiscovery() {
final Settings.Builder settings = Settings.builder()
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE)
.put(NODE_NAME_SETTING.getKey(), localNode.getName())
.put(NodeRoles.nonClusterManagerNode());
.put(nonClusterManagerNode());

assertThat(
expectThrows(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.opensearch.cluster.node.DiscoveryNodeRole;
import org.opensearch.common.settings.Settings;
import org.opensearch.discovery.DiscoveryModule;
import org.opensearch.test.NodeRoles;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.test.transport.MockTransport;
import org.opensearch.transport.TransportRequest;
Expand All @@ -64,6 +63,7 @@
import static org.opensearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING;
import static org.opensearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING;
import static org.opensearch.node.Node.NODE_NAME_SETTING;
import static org.opensearch.test.NodeRoles.nonClusterManagerNode;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.containsString;
Expand Down Expand Up @@ -680,7 +680,7 @@ public void testFailBootstrapNonClusterManagerEligibleNodeWithSingleNodeDiscover
final Settings.Builder settings = Settings.builder()
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE)
.put(NODE_NAME_SETTING.getKey(), localNode.getName())
.put(NodeRoles.nonClusterManagerNode());
.put(nonClusterManagerNode());

assertThat(
expectThrows(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
import org.opensearch.gateway.GatewayService;
import org.opensearch.monitor.StatusInfo;
import org.opensearch.test.MockLogAppender;
import org.opensearch.test.NodeRoles;

import java.io.IOException;
import java.util.Arrays;
Expand Down Expand Up @@ -91,6 +90,7 @@
import static org.opensearch.discovery.PeerFinder.DISCOVERY_FIND_PEERS_INTERVAL_SETTING;
import static org.opensearch.monitor.StatusInfo.Status.HEALTHY;
import static org.opensearch.monitor.StatusInfo.Status.UNHEALTHY;
import static org.opensearch.test.NodeRoles.nonClusterManagerNode;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsString;
Expand Down Expand Up @@ -1702,7 +1702,7 @@ public void testReconfiguresToExcludeClusterManagerIneligibleNodesInVotingConfig

chosenNode.close();
cluster.clusterNodes.replaceAll(
cn -> cn == chosenNode ? cn.restartedNode(Function.identity(), Function.identity(), NodeRoles.nonClusterManagerNode()) : cn
cn -> cn == chosenNode ? cn.restartedNode(Function.identity(), Function.identity(), nonClusterManagerNode()) : cn
);
cluster.stabilise();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import org.opensearch.env.TestEnvironment;
import org.opensearch.indices.breaker.NoneCircuitBreakerService;
import org.opensearch.node.Node;
import org.opensearch.test.NodeRoles;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.threadpool.TestThreadPool;
import org.opensearch.threadpool.ThreadPool;
Expand All @@ -76,6 +75,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import static org.opensearch.test.NodeRoles.nonClusterManagerNode;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.not;
Expand Down Expand Up @@ -405,7 +405,7 @@ public void testDataOnlyNodePersistence() throws Exception {
);
Settings settings = Settings.builder()
.put(ClusterName.CLUSTER_NAME_SETTING.getKey(), clusterName.value())
.put(NodeRoles.nonClusterManagerNode())
.put(nonClusterManagerNode())
.put(Node.NODE_NAME_SETTING.getKey(), "test")
.build();
final MockGatewayMetaState gateway = new MockGatewayMetaState(localNode, bigArrays);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.opensearch.common.transport.TransportAddress;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.snapshots.EmptySnapshotsInfoService;
import org.opensearch.test.NodeRoles;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.test.gateway.TestGatewayAllocator;
import org.hamcrest.Matchers;
Expand Down Expand Up @@ -131,7 +130,7 @@ public void testRecoverStateUpdateTask() throws Exception {
ClusterStateUpdateTask clusterStateUpdateTask = service.new RecoverStateUpdateTask();
String nodeId = randomAlphaOfLength(10);
DiscoveryNode clusterManagerNode = DiscoveryNode.createLocal(
settings(Version.CURRENT).put(NodeRoles.clusterManagerNode()).build(),
settings(Version.CURRENT).put(clusterManagerNode()).build(),
new TransportAddress(TransportAddress.META_ADDRESS, 9300),
nodeId
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.opensearch.cluster.node.DiscoveryNodeRole;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.test.NodeRoles;
import org.opensearch.test.OpenSearchTestCase;
import org.hamcrest.Matchers;

Expand All @@ -45,6 +44,7 @@
import java.util.HashSet;
import java.util.List;

import static org.opensearch.test.NodeRoles.nonClusterManagerNode;
import static org.opensearch.test.NodeRoles.nonDataNode;
import static org.opensearch.test.NodeRoles.removeRoles;
import static org.hamcrest.Matchers.equalTo;
Expand Down Expand Up @@ -240,7 +240,7 @@ public void testDefaultConnectionProfile() {
assertEquals(TransportSettings.TRANSPORT_COMPRESS.get(Settings.EMPTY), profile.getCompressionEnabled());
assertEquals(TransportSettings.PING_SCHEDULE.get(Settings.EMPTY), profile.getPingInterval());

profile = ConnectionProfile.buildDefaultConnectionProfile(NodeRoles.nonClusterManagerNode());
profile = ConnectionProfile.buildDefaultConnectionProfile(nonClusterManagerNode());
assertEquals(12, profile.getNumConnections());
assertEquals(1, profile.getNumConnectionsPerType(TransportRequestOptions.Type.PING));
assertEquals(6, profile.getNumConnectionsPerType(TransportRequestOptions.Type.REG));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.core.internal.io.IOUtils;
import org.opensearch.test.NodeRoles;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.test.transport.MockTransportService;
import org.opensearch.threadpool.TestThreadPool;
Expand All @@ -64,6 +63,7 @@
import java.util.function.BiFunction;

import static org.opensearch.test.NodeRoles.clusterManagerOnlyNode;
import static org.opensearch.test.NodeRoles.nonClusterManagerNode;
import static org.opensearch.test.NodeRoles.removeRoles;
import static org.hamcrest.Matchers.either;
import static org.hamcrest.Matchers.equalTo;
Expand Down Expand Up @@ -552,7 +552,7 @@ public void testRemoteNodeAttribute() throws IOException, InterruptedException {
public void testRemoteNodeRoles() throws IOException, InterruptedException {
final Settings settings = Settings.EMPTY;
final List<DiscoveryNode> knownNodes = new CopyOnWriteArrayList<>();
final Settings data = NodeRoles.nonClusterManagerNode();
final Settings data = nonClusterManagerNode();
final Settings dedicatedClusterManager = clusterManagerOnlyNode();
try (
MockTransportService c1N1 = startTransport("cluster_1_node_1", knownNodes, Version.CURRENT, dedicatedClusterManager);
Expand Down

0 comments on commit 803db9c

Please sign in to comment.