Skip to content

Commit a2a0632

Browse files
author
Andrey Ershov
committed
Switch more tests to zen2
1 parent 0dd73ef commit a2a0632

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

server/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,18 @@ public void testTwoNodesSingleDoc() throws Exception {
276276
}
277277

278278
public void testDanglingIndices() throws Exception {
279+
/*TODO This test test does not work with Zen2, because once master node looses its cluster state during restart
280+
it will start with term = 1, which is the same as the term data node has. Data node won't accept cluster state from master
281+
after the restart, because the term is the same, but version of the cluster state is greater on the data node.
282+
Consider adding term to JoinRequest, so that master node can bump its term if its current term is less than JoinRequest#term.
283+
*/
279284
logger.info("--> starting two nodes");
280-
281-
final String node_1 = internalCluster().startNodes(2,
282-
//TODO fails wih Zen2
283-
Settings.builder().put(TestZenDiscovery.USE_ZEN2.getKey(), false).build()).get(0);
285+
String masterNode = internalCluster().startNode(Settings.builder()
286+
.put(Settings.builder().put(TestZenDiscovery.USE_ZEN2.getKey(), false).build())
287+
.build());
288+
internalCluster().startDataOnlyNode(Settings.builder()
289+
.put(Settings.builder().put(TestZenDiscovery.USE_ZEN2.getKey(), false).build())
290+
.build());
284291

285292
logger.info("--> indexing a simple document");
286293
client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefreshPolicy(IMMEDIATE).get();
@@ -294,11 +301,11 @@ public void testDanglingIndices() throws Exception {
294301
}
295302
assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(true));
296303

297-
logger.info("--> restarting the nodes");
298-
internalCluster().fullRestart(new RestartCallback() {
304+
logger.info("--> restarting master node, while clearing its data");
305+
internalCluster().restartNode(masterNode, new RestartCallback() {
299306
@Override
300307
public boolean clearData(String nodeName) {
301-
return node_1.equals(nodeName);
308+
return true;
302309
}
303310
});
304311

@@ -328,14 +335,14 @@ public boolean clearData(String nodeName) {
328335
*/
329336
public void testIndexDeletionWhenNodeRejoins() throws Exception {
330337
final String indexName = "test-index-del-on-node-rejoin-idx";
331-
final int numNodes = 2;
338+
// We need at least 3 nodes to make sure, that once one node is stopped, remaining nodes can elect a new master
339+
final int numNodes = 3;
332340

333341
final List<String> nodes;
334342
logger.info("--> starting a cluster with " + numNodes + " nodes");
343+
335344
nodes = internalCluster().startNodes(numNodes,
336-
Settings.builder().put(IndexGraveyard.SETTING_MAX_TOMBSTONES.getKey(), randomIntBetween(10, 100))
337-
//TODO fails with Zen2
338-
.put(TestZenDiscovery.USE_ZEN2.getKey(), false).build());
345+
Settings.builder().put(IndexGraveyard.SETTING_MAX_TOMBSTONES.getKey(), randomIntBetween(10, 100)).build());
339346
logger.info("--> create an index");
340347
createIndex(indexName);
341348

@@ -355,6 +362,7 @@ public Settings onNodeStopped(final String nodeName) throws Exception {
355362
final Client client = client(otherNode);
356363
client.admin().indices().prepareDelete(indexName).execute().actionGet();
357364
assertFalse(client.admin().indices().prepareExists(indexName).execute().actionGet().isExists());
365+
logger.info("--> deleted");
358366
return super.onNodeStopped(nodeName);
359367
}
360368
});

server/src/test/java/org/elasticsearch/index/shard/RemoveCorruptedShardDataCommandIT.java

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
import org.elasticsearch.test.ESIntegTestCase;
7171
import org.elasticsearch.test.InternalSettingsPlugin;
7272
import org.elasticsearch.test.InternalTestCluster;
73-
import org.elasticsearch.test.discovery.TestZenDiscovery;
7473
import org.elasticsearch.test.engine.MockEngineSupport;
7574
import org.elasticsearch.test.transport.MockTransportService;
7675

@@ -102,13 +101,6 @@
102101
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 0)
103102
public class RemoveCorruptedShardDataCommandIT extends ESIntegTestCase {
104103

105-
@Override
106-
protected Settings nodeSettings(int nodeOrdinal) {
107-
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
108-
.put(TestZenDiscovery.USE_ZEN2.getKey(), false) // no state persistence yet
109-
.build();
110-
}
111-
112104
@Override
113105
protected Collection<Class<? extends Plugin>> nodePlugins() {
114106
return Arrays.asList(MockTransportService.TestPlugin.class, MockEngineFactoryPlugin.class, InternalSettingsPlugin.class);
@@ -260,7 +252,7 @@ public Settings onNodeStopped(String nodeName) throws Exception {
260252
}
261253

262254
public void testCorruptTranslogTruncation() throws Exception {
263-
internalCluster().startNodes(2, Settings.EMPTY);
255+
internalCluster().startNodes(2);
264256

265257
final String node1 = internalCluster().getNodeNames()[0];
266258
final String node2 = internalCluster().getNodeNames()[1];
@@ -436,10 +428,10 @@ public Settings onNodeStopped(String nodeName) throws Exception {
436428
}
437429

438430
public void testCorruptTranslogTruncationOfReplica() throws Exception {
439-
internalCluster().startNodes(2, Settings.EMPTY);
431+
internalCluster().startMasterOnlyNode();
440432

441-
final String node1 = internalCluster().getNodeNames()[0];
442-
final String node2 = internalCluster().getNodeNames()[1];
433+
final String node1 = internalCluster().startDataOnlyNode();
434+
final String node2 = internalCluster().startDataOnlyNode();
443435
logger.info("--> nodes name: {}, {}", node1, node2);
444436

445437
final String indexName = "test";
@@ -481,12 +473,11 @@ public void testCorruptTranslogTruncationOfReplica() throws Exception {
481473
final ShardId shardId = new ShardId(resolveIndex(indexName), 0);
482474
final Set<Path> translogDirs = getDirs(node2, shardId, ShardPath.TRANSLOG_FOLDER_NAME);
483475

484-
// stop the cluster nodes. we don't use full restart so the node start up order will be the same
485-
// and shard roles will be maintained
476+
// stop data nodes. After the restart the 1st node will be primary and the 2nd node will be replica
486477
internalCluster().stopRandomDataNode();
487478
internalCluster().stopRandomDataNode();
488479

489-
// Corrupt the translog file(s)
480+
// Corrupt the translog file(s) on the replica
490481
logger.info("--> corrupting translog");
491482
TestTranslog.corruptRandomTranslogFile(logger, random(), translogDirs);
492483

@@ -555,8 +546,10 @@ public Settings onNodeStopped(String nodeName) throws Exception {
555546
}
556547

557548
public void testResolvePath() throws Exception {
549+
internalCluster().startMasterOnlyNode();
550+
558551
final int numOfNodes = randomIntBetween(1, 5);
559-
final List<String> nodeNames = internalCluster().startNodes(numOfNodes, Settings.EMPTY);
552+
final List<String> nodeNames = internalCluster().startNodes(numOfNodes);
560553

561554
final String indexName = "test" + randomInt(100);
562555
assertAcked(prepareCreate(indexName).setSettings(Settings.builder()

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ private NodeConfigurationSource createNodeConfigurationSource() {
188188
builder.put(IndicesStore.INDICES_STORE_DELETE_SHARD_TIMEOUT.getKey(), new TimeValue(1, TimeUnit.SECONDS));
189189
builder.putList(DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey()); // empty list disables a port scan for other nodes
190190
builder.putList(DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), "file");
191-
builder.put(TestZenDiscovery.USE_ZEN2.getKey(), false); // some tests do full cluster restarts
192191
builder.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType());
193192
builder.put(XPackSettings.SECURITY_ENABLED.getKey(), false);
194193
builder.put(XPackSettings.MONITORING_ENABLED.getKey(), false);

0 commit comments

Comments
 (0)