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

Test: use local gateway by default #9476

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -32,7 +32,6 @@
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.junit.Test;

import java.io.IOException;
Expand All @@ -43,7 +42,6 @@
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
import static org.elasticsearch.test.ElasticsearchIntegrationTest.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
import static org.hamcrest.Matchers.*;

@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
Expand All @@ -57,7 +55,6 @@ public void simpleMinimumMasterNodes() throws Exception {
.put("discovery.zen.minimum_master_nodes", 2)
.put("discovery.zen.ping_timeout", "200ms")
.put("discovery.initial_state_timeout", "500ms")
.put("gateway.type", "local")
.build();

logger.info("--> start first node");
Expand Down Expand Up @@ -175,7 +172,6 @@ public void multipleNodesShutdownNonMasterNodes() throws Exception {
.put("discovery.zen.minimum_master_nodes", 3)
.put("discovery.zen.ping_timeout", "1s")
.put("discovery.initial_state_timeout", "500ms")
.put("gateway.type", "local")
.build();

logger.info("--> start first 2 nodes");
Expand Down Expand Up @@ -265,7 +261,6 @@ public void dynamicUpdateMinimumMasterNodes() throws InterruptedException, IOExc
.put("discovery.type", "zen")
.put("discovery.zen.ping_timeout", "400ms")
.put("discovery.initial_state_timeout", "500ms")
.put("gateway.type", "local")
.build();

logger.info("--> start 2 nodes");
Expand Down Expand Up @@ -318,8 +313,7 @@ public void testCanNotBringClusterDown() throws ExecutionException, InterruptedE
ImmutableSettings.Builder settings = settingsBuilder()
.put("discovery.type", "zen")
.put("discovery.zen.ping_timeout", "200ms")
.put("discovery.initial_state_timeout", "500ms")
.put("gateway.type", "local");
.put("discovery.initial_state_timeout", "500ms");

// set an initial value which is at least quorum to avoid split brains during initial startup
int initialMinMasterNodes = randomIntBetween(nodeCount / 2 + 1, nodeCount);
Expand Down
Expand Up @@ -70,7 +70,6 @@ public void rerouteWithCommands_disableAllocationSettings() throws Exception {
public void rerouteWithCommands_enableAllocationSettings() throws Exception {
Settings commonSettings = settingsBuilder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE, EnableAllocationDecider.Allocation.NONE.name())
.put("gateway.type", "local")
.build();
rerouteWithCommands(commonSettings);
}
Expand Down Expand Up @@ -141,7 +140,6 @@ public void rerouteWithAllocateLocalGateway_disableAllocationSettings() throws E
Settings commonSettings = settingsBuilder()
.put(DisableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_DISABLE_NEW_ALLOCATION, true)
.put(DisableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_DISABLE_ALLOCATION, true)
.put("gateway.type", "local")
.build();
rerouteWithAllocateLocalGateway(commonSettings);
}
Expand All @@ -150,7 +148,6 @@ public void rerouteWithAllocateLocalGateway_disableAllocationSettings() throws E
public void rerouteWithAllocateLocalGateway_enableAllocationSettings() throws Exception {
Settings commonSettings = settingsBuilder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE, EnableAllocationDecider.Allocation.NONE.name())
.put("gateway.type", "local")
.build();
rerouteWithAllocateLocalGateway(commonSettings);
}
Expand Down
Expand Up @@ -38,7 +38,6 @@
import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.InternalTestCluster.RestartCallback;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.junit.Test;

import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
Expand All @@ -62,7 +61,7 @@ public class LocalGatewayIndexStateTests extends ElasticsearchIntegrationTest {
public void testMappingMetaDataParsed() throws Exception {

logger.info("--> starting 1 nodes");
internalCluster().startNode(settingsBuilder().put("gateway.type", "local"));
internalCluster().startNode();

logger.info("--> creating test index, with meta routing");
client().admin().indices().prepareCreate("test")
Expand Down Expand Up @@ -91,7 +90,7 @@ public void testMappingMetaDataParsed() throws Exception {
public void testSimpleOpenClose() throws Exception {

logger.info("--> starting 2 nodes");
internalCluster().startNodesAsync(2, settingsBuilder().put("gateway.type", "local").build()).get();
internalCluster().startNodesAsync(2).get();

logger.info("--> creating test index");
createIndex("test");
Expand Down Expand Up @@ -194,7 +193,7 @@ public void testJustMasterNode() throws Exception {
logger.info("--> cleaning nodes");

logger.info("--> starting 1 master node non data");
internalCluster().startNode(settingsBuilder().put("node.data", false).put("gateway.type", "local").build());
internalCluster().startNode(settingsBuilder().put("node.data", false).build());

logger.info("--> create an index");
client().admin().indices().prepareCreate("test").execute().actionGet();
Expand All @@ -203,7 +202,7 @@ public void testJustMasterNode() throws Exception {
internalCluster().closeNonSharedNodes(false);

logger.info("--> starting 1 master node non data again");
internalCluster().startNode(settingsBuilder().put("node.data", false).put("gateway.type", "local").build());
internalCluster().startNode(settingsBuilder().put("node.data", false).build());

logger.info("--> waiting for test index to be created");
ClusterHealthResponse health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setIndices("test").execute().actionGet();
Expand All @@ -219,8 +218,8 @@ public void testJustMasterNodeAndJustDataNode() throws Exception {
logger.info("--> cleaning nodes");

logger.info("--> starting 1 master node non data");
internalCluster().startNode(settingsBuilder().put("node.data", false).put("gateway.type", "local").build());
internalCluster().startNode(settingsBuilder().put("node.master", false).put("gateway.type", "local").build());
internalCluster().startNode(settingsBuilder().put("node.data", false).build());
internalCluster().startNode(settingsBuilder().put("node.master", false).build());

logger.info("--> create an index");
client().admin().indices().prepareCreate("test").execute().actionGet();
Expand All @@ -236,8 +235,8 @@ public void testTwoNodesSingleDoc() throws Exception {
logger.info("--> cleaning nodes");

logger.info("--> starting 2 nodes");
internalCluster().startNode(settingsBuilder().put("gateway.type", "local").build());
internalCluster().startNode(settingsBuilder().put("gateway.type", "local").build());
internalCluster().startNode();
internalCluster().startNode();

logger.info("--> indexing a simple document");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefresh(true).execute().actionGet();
Expand Down Expand Up @@ -274,9 +273,8 @@ public void testTwoNodesSingleDoc() throws Exception {

@Test
public void testDanglingIndicesConflictWithAlias() throws Exception {
Settings settings = settingsBuilder().put("gateway.type", "local").build();
logger.info("--> starting two nodes");
internalCluster().startNodesAsync(2, settings).get();
internalCluster().startNodesAsync(2).get();

logger.info("--> indexing a simple document");
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefresh(true).execute().actionGet();
Expand Down Expand Up @@ -304,7 +302,7 @@ public void testDanglingIndicesConflictWithAlias() throws Exception {
assertAcked(client().admin().indices().prepareAliases().addAlias("test2", "test"));

logger.info("--> starting node back up");
internalCluster().startNode(settings);
internalCluster().startNode();

ensureGreen();

Expand Down Expand Up @@ -337,7 +335,7 @@ public void run() {
@Test
public void testDanglingIndicesAutoImportYes() throws Exception {
Settings settings = settingsBuilder()
.put("gateway.type", "local").put("gateway.local.auto_import_dangled", "yes")
.put("gateway.local.auto_import_dangled", "yes")
.put("gateway.local.dangling_timeout", randomIntBetween(0, 120))
.build();
logger.info("--> starting two nodes");
Expand Down Expand Up @@ -393,7 +391,7 @@ public Settings onNodeStopped(String nodeName) throws Exception {
@Test
public void testDanglingIndicesAutoImportClose() throws Exception {
Settings settings = settingsBuilder()
.put("gateway.type", "local").put("gateway.local.auto_import_dangled", "closed")
.put("gateway.local.auto_import_dangled", "closed")
.build();


Expand Down Expand Up @@ -456,7 +454,7 @@ public Settings onNodeStopped(String nodeName) throws Exception {
@Test
public void testDanglingIndicesNoAutoImport() throws Exception {
Settings settings = settingsBuilder()
.put("gateway.type", "local").put("gateway.local.auto_import_dangled", "no")
.put("gateway.local.auto_import_dangled", "no")
.build();
logger.info("--> starting two nodes");
final String node_1 = internalCluster().startNodesAsync(2, settings).get().get(0);
Expand Down Expand Up @@ -518,7 +516,7 @@ public Settings onNodeStopped(String nodeName) throws Exception {
@Test
public void testDanglingIndicesNoAutoImportStillDanglingAndCreatingSameIndex() throws Exception {
Settings settings = settingsBuilder()
.put("gateway.type", "local").put("gateway.local.auto_import_dangled", "no")
.put("gateway.local.auto_import_dangled", "no")
.build();

logger.info("--> starting two nodes");
Expand Down
Expand Up @@ -37,7 +37,7 @@
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.test.ElasticsearchIntegrationTest.*;
import static org.elasticsearch.test.ElasticsearchIntegrationTest.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.*;
Expand All @@ -57,7 +57,7 @@ protected int numberOfReplicas() {
@Slow
public void testChangeInitialShardsRecovery() throws Exception {
logger.info("--> starting 3 nodes");
final String[] nodes = internalCluster().startNodesAsync(3, settingsBuilder().put("gateway.type", "local").build()).get().toArray(new String[0]);
final String[] nodes = internalCluster().startNodesAsync(3).get().toArray(new String[0]);

createIndex("test");
ensureGreen();
Expand All @@ -78,11 +78,6 @@ public void testChangeInitialShardsRecovery() throws Exception {
final String nodeToRemove = nodes[between(0,2)];
logger.info("--> restarting 1 nodes -- kill 2");
internalCluster().fullRestart(new RestartCallback() {
@Override
public Settings onNodeStopped(String nodeName) throws Exception {
return settingsBuilder().put("gateway.type", "local").build();
}

@Override
public boolean doRestart(String nodeName) {
return nodeToRemove.equals(nodeName);
Expand Down Expand Up @@ -123,7 +118,7 @@ public boolean apply(Object input) {
public void testQuorumRecovery() throws Exception {

logger.info("--> starting 3 nodes");
internalCluster().startNodesAsync(3, settingsBuilder().put("gateway.type", "local").build()).get();
internalCluster().startNodesAsync(3).get();
// we are shutting down nodes - make sure we don't have 2 clusters if we test network
setMinimumMasterNodes(2);

Expand Down
Expand Up @@ -56,15 +56,11 @@
@Slow
public class SimpleRecoveryLocalGatewayTests extends ElasticsearchIntegrationTest {

private ImmutableSettings.Builder settingsBuilder() {
return ImmutableSettings.settingsBuilder().put("gateway.type", "local");
}

@Test
@Slow
public void testOneNodeRecoverFromGateway() throws Exception {

internalCluster().startNode(settingsBuilder().build());
internalCluster().startNode();

String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("appAccountIds").field("type", "string").endObject().endObject()
Expand Down Expand Up @@ -113,7 +109,7 @@ public void testOneNodeRecoverFromGateway() throws Exception {
@Slow
public void testSingleNodeNoFlush() throws Exception {

internalCluster().startNode(settingsBuilder().build());
internalCluster().startNode();

String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties").startObject("field").field("type", "string").endObject().startObject("num").field("type", "integer").endObject().endObject()
Expand Down Expand Up @@ -201,7 +197,7 @@ SETTING_NUMBER_OF_REPLICAS, randomIntBetween(0, 1)
@Slow
public void testSingleNodeWithFlush() throws Exception {

internalCluster().startNode(settingsBuilder().build());
internalCluster().startNode();
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject().field("field", "value1").endObject()).execute().actionGet();
flush();
client().prepareIndex("test", "type1", "2").setSource(jsonBuilder().startObject().field("field", "value2").endObject()).execute().actionGet();
Expand Down Expand Up @@ -235,8 +231,8 @@ public void testSingleNodeWithFlush() throws Exception {
@Slow
public void testTwoNodeFirstNodeCleared() throws Exception {

final String firstNode = internalCluster().startNode(settingsBuilder().build());
internalCluster().startNode(settingsBuilder().build());
final String firstNode = internalCluster().startNode();
internalCluster().startNode();

client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject().field("field", "value1").endObject()).execute().actionGet();
flush();
Expand All @@ -253,7 +249,7 @@ public void testTwoNodeFirstNodeCleared() throws Exception {
internalCluster().fullRestart(new RestartCallback() {
@Override
public Settings onNodeStopped(String nodeName) throws Exception {
return settingsBuilder().put("gateway.recover_after_nodes", 2).build();
return ImmutableSettings.settingsBuilder().put("gateway.recover_after_nodes", 2).build();
}

@Override
Expand All @@ -275,7 +271,7 @@ public boolean clearData(String nodeName) {
@Slow
public void testLatestVersionLoaded() throws Exception {
// clean two nodes
internalCluster().startNodesAsync(2, settingsBuilder().put("gateway.recover_after_nodes", 2).build()).get();
internalCluster().startNodesAsync(2, ImmutableSettings.settingsBuilder().put("gateway.recover_after_nodes", 2).build()).get();

client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject().field("field", "value1").endObject()).execute().actionGet();
client().admin().indices().prepareFlush().execute().actionGet();
Expand Down Expand Up @@ -345,7 +341,7 @@ public void doAfterNodes(int numNodes, Client client) throws Exception {
@Test
@Slow
public void testReusePeerRecovery() throws Exception {
ImmutableSettings.Builder settings = settingsBuilder()
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder()
.put("action.admin.cluster.node.shutdown.delay", "10ms")
.put(MockFSDirectoryService.CHECK_INDEX_ON_CLOSE, false)
.put("gateway.recover_after_nodes", 4)
Expand Down Expand Up @@ -373,10 +369,10 @@ public void testReusePeerRecovery() throws Exception {
// if we run into a relocation the reuse count will be 0 and this fails the test. We are testing here if
// we reuse the files on disk after full restarts for replicas.
client().admin().cluster().prepareUpdateSettings()
.setPersistentSettings(settingsBuilder().put(BalancedShardsAllocator.SETTING_THRESHOLD, 100.0f)).get();
.setPersistentSettings(ImmutableSettings.settingsBuilder().put(BalancedShardsAllocator.SETTING_THRESHOLD, 100.0f)).get();
// Disable allocations while we are closing nodes
client().admin().cluster().prepareUpdateSettings()
.setTransientSettings(settingsBuilder()
.setTransientSettings(ImmutableSettings.settingsBuilder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE, EnableAllocationDecider.Allocation.NONE))
.get();
logger.info("--> full cluster restart");
Expand All @@ -388,7 +384,7 @@ public void testReusePeerRecovery() throws Exception {
logger.info("--> shutting down the nodes");
// Disable allocations while we are closing nodes
client().admin().cluster().prepareUpdateSettings()
.setTransientSettings(settingsBuilder()
.setTransientSettings(ImmutableSettings.settingsBuilder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE, EnableAllocationDecider.Allocation.NONE))
.get();
logger.info("--> full cluster restart");
Expand Down Expand Up @@ -424,11 +420,11 @@ public void testReusePeerRecovery() throws Exception {
public void testRecoveryDifferentNodeOrderStartup() throws Exception {
// we need different data paths so we make sure we start the second node fresh

final String node_1 = internalCluster().startNode(settingsBuilder().put("path.data", "data/data1").build());
final String node_1 = internalCluster().startNode(ImmutableSettings.settingsBuilder().put("path.data", "data/data1").build());

client().prepareIndex("test", "type1", "1").setSource("field", "value").execute().actionGet();

internalCluster().startNode(settingsBuilder().put("path.data", "data/data2").build());
internalCluster().startNode(ImmutableSettings.settingsBuilder().put("path.data", "data/data2").build());

ensureGreen();

Expand Down
Expand Up @@ -89,7 +89,7 @@ protected Settings nodeSettings(int nodeOrdinal) {
return ImmutableSettings.builder()
// we really need local GW here since this also checks for corruption etc.
// and we need to make sure primaries are not just trashed if we don't have replicas
.put(super.nodeSettings(nodeOrdinal)).put("gateway.type", "local")
.put(super.nodeSettings(nodeOrdinal))
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, MockTransportService.class.getName())
// speed up recoveries
.put(RecoverySettings.INDICES_RECOVERY_CONCURRENT_STREAMS, 10)
Expand Down