use of org.elasticsearch.test.InternalTestCluster in project elasticsearch by elastic.
the class MetaDataWriteDataNodesIT method getIndicesMetaDataOnNode.
private ImmutableOpenMap<String, IndexMetaData> getIndicesMetaDataOnNode(String nodeName) throws Exception {
GatewayMetaState nodeMetaState = ((InternalTestCluster) cluster()).getInstance(GatewayMetaState.class, nodeName);
MetaData nodeMetaData = nodeMetaState.loadMetaState();
return nodeMetaData.getIndices();
}
use of org.elasticsearch.test.InternalTestCluster in project elasticsearch by elastic.
the class InternalTestClusterTests method testTwoNodeCluster.
public void testTwoNodeCluster() throws Exception {
NodeConfigurationSource nodeConfigurationSource = new NodeConfigurationSource() {
@Override
public Settings nodeSettings(int nodeOrdinal) {
return Settings.builder().put(NetworkModule.HTTP_ENABLED.getKey(), false).put(NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(), 2).put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME).build();
}
@Override
public Settings transportClientSettings() {
return Settings.builder().put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME).build();
}
};
boolean enableHttpPipelining = randomBoolean();
String nodePrefix = "test";
Path baseDir = createTempDir();
InternalTestCluster cluster = new InternalTestCluster(randomLong(), baseDir, false, true, 2, 2, "test", nodeConfigurationSource, 0, enableHttpPipelining, nodePrefix, Arrays.asList(MockTcpTransportPlugin.class, TestZenDiscovery.TestPlugin.class), Function.identity());
try {
cluster.beforeTest(random(), 0.0);
assertMMNinNodeSetting(cluster, 2);
switch(randomInt(2)) {
case 0:
cluster.stopRandomDataNode();
assertMMNinClusterSetting(cluster, 1);
cluster.startNode();
assertMMNinClusterSetting(cluster, 2);
assertMMNinNodeSetting(cluster, 2);
break;
case 1:
cluster.rollingRestart(new InternalTestCluster.RestartCallback() {
@Override
public Settings onNodeStopped(String nodeName) throws Exception {
assertMMNinClusterSetting(cluster, 1);
return super.onNodeStopped(nodeName);
}
});
assertMMNinClusterSetting(cluster, 2);
break;
case 2:
cluster.fullRestart();
break;
}
assertMMNinNodeSetting(cluster, 2);
} finally {
cluster.close();
}
}
use of org.elasticsearch.test.InternalTestCluster in project elasticsearch by elastic.
the class InternalTestClusterTests method testInitializiationIsConsistent.
public void testInitializiationIsConsistent() {
long clusterSeed = randomLong();
boolean masterNodes = randomBoolean();
int minNumDataNodes = randomIntBetween(0, 9);
int maxNumDataNodes = randomIntBetween(minNumDataNodes, 10);
String clusterName = randomRealisticUnicodeOfCodepointLengthBetween(1, 10);
NodeConfigurationSource nodeConfigurationSource = NodeConfigurationSource.EMPTY;
int numClientNodes = randomIntBetween(0, 10);
boolean enableHttpPipelining = randomBoolean();
String nodePrefix = randomRealisticUnicodeOfCodepointLengthBetween(1, 10);
Path baseDir = createTempDir();
InternalTestCluster cluster0 = new InternalTestCluster(clusterSeed, baseDir, masterNodes, randomBoolean(), minNumDataNodes, maxNumDataNodes, clusterName, nodeConfigurationSource, numClientNodes, enableHttpPipelining, nodePrefix, Collections.emptyList(), Function.identity());
InternalTestCluster cluster1 = new InternalTestCluster(clusterSeed, baseDir, masterNodes, randomBoolean(), minNumDataNodes, maxNumDataNodes, clusterName, nodeConfigurationSource, numClientNodes, enableHttpPipelining, nodePrefix, Collections.emptyList(), Function.identity());
// TODO: this is not ideal - we should have a way to make sure ports are initialized in the same way
assertClusters(cluster0, cluster1, false);
}
use of org.elasticsearch.test.InternalTestCluster in project crate by crate.
the class AbstractDisruptionTestCase method startCluster.
List<String> startCluster(int numberOfNodes) {
InternalTestCluster internalCluster = internalCluster();
List<String> nodes = internalCluster.startNodes(numberOfNodes);
ensureStableCluster(numberOfNodes);
return nodes;
}
use of org.elasticsearch.test.InternalTestCluster in project crate by crate.
the class InternalTestClusterTests method testTwoNodeCluster.
public void testTwoNodeCluster() throws Exception {
String transportClient = getTestTransportType();
NodeConfigurationSource nodeConfigurationSource = new NodeConfigurationSource() {
@Override
public Settings nodeSettings(int nodeOrdinal) {
return Settings.builder().put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType()).putList(DISCOVERY_SEED_PROVIDERS_SETTING.getKey(), "file").putList(SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING.getKey()).build();
}
@Override
public Path nodeConfigPath(int nodeOrdinal) {
return null;
}
@Override
public Settings transportClientSettings() {
return Settings.builder().put(NetworkModule.TRANSPORT_TYPE_KEY, transportClient).build();
}
};
String nodePrefix = "test";
Path baseDir = createTempDir();
List<Class<? extends Plugin>> plugins = new ArrayList<>(mockPlugins());
plugins.add(NodeAttrCheckPlugin.class);
InternalTestCluster cluster = new InternalTestCluster(randomLong(), baseDir, false, true, 2, 2, "test", nodeConfigurationSource, 0, nodePrefix, plugins);
try {
cluster.beforeTest(random());
switch(randomInt(2)) {
case 0:
cluster.stopRandomDataNode();
cluster.startNode();
break;
case 1:
cluster.rollingRestart(InternalTestCluster.EMPTY_CALLBACK);
break;
case 2:
cluster.fullRestart();
break;
}
} finally {
cluster.close();
}
}
Aggregations