[TEST] ensure green before we filter allocations otherwise follow up ensureGreen() will fail

This commit is contained in:
Simon Willnauer 2016-06-06 18:14:05 +02:00
parent d8056c8213
commit d594d6c07c
1 changed files with 8 additions and 0 deletions

View File

@ -300,6 +300,10 @@ public class CreateIndexIT extends ESIntegTestCase {
assertTrue("at least 2 nodes but was: " + dataNodes.size(), dataNodes.size() >= 2); assertTrue("at least 2 nodes but was: " + dataNodes.size(), dataNodes.size() >= 2);
DiscoveryNode[] discoveryNodes = dataNodes.values().toArray(DiscoveryNode.class); DiscoveryNode[] discoveryNodes = dataNodes.values().toArray(DiscoveryNode.class);
String mergeNode = discoveryNodes[0].getName(); String mergeNode = discoveryNodes[0].getName();
// ensure all shards are allocated otherwise the ensure green below might not succeed since we require the merge node
// if we change the setting too quickly we will end up with one replica unassigned which can't be assigned anymore due
// to the require._name below.
ensureGreen();
// relocate all shards to one node such that we can merge it. // relocate all shards to one node such that we can merge it.
client().admin().indices().prepareUpdateSettings("source") client().admin().indices().prepareUpdateSettings("source")
.setSettings(Settings.builder() .setSettings(Settings.builder()
@ -343,6 +347,10 @@ public class CreateIndexIT extends ESIntegTestCase {
DiscoveryNode[] discoveryNodes = dataNodes.values().toArray(DiscoveryNode.class); DiscoveryNode[] discoveryNodes = dataNodes.values().toArray(DiscoveryNode.class);
String spareNode = discoveryNodes[0].getName(); String spareNode = discoveryNodes[0].getName();
String mergeNode = discoveryNodes[1].getName(); String mergeNode = discoveryNodes[1].getName();
// ensure all shards are allocated otherwise the ensure green below might not succeed since we require the merge node
// if we change the setting too quickly we will end up with one replica unassigned which can't be assigned anymore due
// to the require._name below.
ensureGreen();
// relocate all shards to one node such that we can merge it. // relocate all shards to one node such that we can merge it.
client().admin().indices().prepareUpdateSettings("source") client().admin().indices().prepareUpdateSettings("source")
.setSettings(Settings.builder().put("index.routing.allocation.require._name", mergeNode) .setSettings(Settings.builder().put("index.routing.allocation.require._name", mergeNode)