Fix checkstyle LineLength issues in UpdateShardAllocationSettingsIT

This commit is contained in:
Christoph Büscher 2017-02-28 20:14:28 +01:00
parent 0ae6bc36fa
commit 98b7023318
1 changed files with 20 additions and 7 deletions

View File

@ -42,34 +42,47 @@ public class UpdateShardAllocationSettingsIT extends ESIntegTestCase {
*/ */
public void testEnableRebalance() throws InterruptedException { public void testEnableRebalance() throws InterruptedException {
final String firstNode = internalCluster().startNode(); final String firstNode = internalCluster().startNode();
client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE)).get(); client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE))
.get();
// we test with 2 shards since otherwise it's pretty fragile if there are difference in the num or shards such that // we test with 2 shards since otherwise it's pretty fragile if there are difference in the num or shards such that
// all shards are relocated to the second node which is not what we want here. It's solely a test for the settings to take effect // all shards are relocated to the second node which is not what we want here. It's solely a test for the settings to take effect
final int numShards = 2; final int numShards = 2;
assertAcked(prepareCreate("test").setSettings(Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0).put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numShards))); assertAcked(prepareCreate("test").setSettings(Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
assertAcked(prepareCreate("test_1").setSettings(Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0).put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numShards))); .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numShards)));
assertAcked(prepareCreate("test_1").setSettings(Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numShards)));
ensureGreen(); ensureGreen();
assertAllShardsOnNodes("test", firstNode); assertAllShardsOnNodes("test", firstNode);
assertAllShardsOnNodes("test_1", firstNode); assertAllShardsOnNodes("test_1", firstNode);
final String secondNode = internalCluster().startNode(); final String secondNode = internalCluster().startNode();
// prevent via index setting but only on index test // prevent via index setting but only on index test
client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE)).get(); client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder()
.put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE))
.get();
client().admin().cluster().prepareReroute().get(); client().admin().cluster().prepareReroute().get();
ensureGreen(); ensureGreen();
assertAllShardsOnNodes("test", firstNode); assertAllShardsOnNodes("test", firstNode);
assertAllShardsOnNodes("test_1", firstNode); assertAllShardsOnNodes("test_1", firstNode);
// now enable the index test to relocate since index settings override cluster settings // now enable the index test to relocate since index settings override cluster settings
client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), randomBoolean() ? EnableAllocationDecider.Rebalance.PRIMARIES : EnableAllocationDecider.Rebalance.ALL)).get(); client().admin().indices().prepareUpdateSettings("test")
.setSettings(Settings.builder().put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING.getKey(),
randomBoolean() ? EnableAllocationDecider.Rebalance.PRIMARIES : EnableAllocationDecider.Rebalance.ALL))
.get();
logger.info("--> balance index [test]"); logger.info("--> balance index [test]");
client().admin().cluster().prepareReroute().get(); client().admin().cluster().prepareReroute().get();
ensureGreen("test"); ensureGreen("test");
Set<String> test = assertAllShardsOnNodes("test", firstNode, secondNode); Set<String> test = assertAllShardsOnNodes("test", firstNode, secondNode);
assertThat("index: [test] expected to be rebalanced on both nodes", test.size(), equalTo(2)); assertThat("index: [test] expected to be rebalanced on both nodes", test.size(), equalTo(2));
// flip the cluster wide setting such that we can also balance for index test_1 eventually we should have one shard of each index on each node // flip the cluster wide setting such that we can also balance for index
client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), randomBoolean() ? EnableAllocationDecider.Rebalance.PRIMARIES : EnableAllocationDecider.Rebalance.ALL)).get(); // test_1 eventually we should have one shard of each index on each node
client().admin().cluster().prepareUpdateSettings()
.setTransientSettings(Settings.builder().put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(),
randomBoolean() ? EnableAllocationDecider.Rebalance.PRIMARIES : EnableAllocationDecider.Rebalance.ALL))
.get();
logger.info("--> balance index [test_1]"); logger.info("--> balance index [test_1]");
client().admin().cluster().prepareReroute().get(); client().admin().cluster().prepareReroute().get();
ensureGreen("test_1"); ensureGreen("test_1");