[Test] make recovery slow down in rerouteRecoveryTest aware of index size

This commit is contained in:
Boaz Leskes 2014-06-30 10:54:45 +02:00
parent a72c167be2
commit c907ce325e
1 changed files with 13 additions and 7 deletions

View File

@ -28,6 +28,7 @@ import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.cluster.routing.allocation.command.MoveAllocationCommand; import org.elasticsearch.cluster.routing.allocation.command.MoveAllocationCommand;
import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.indices.recovery.RecoveryState.Stage; import org.elasticsearch.indices.recovery.RecoveryState.Stage;
import org.elasticsearch.indices.recovery.RecoveryState.Type; import org.elasticsearch.indices.recovery.RecoveryState.Type;
@ -100,18 +101,23 @@ public class IndexRecoveryTests extends ElasticsearchIntegrationTest {
assertThat(state.getStage(), not(equalTo(Stage.DONE))); assertThat(state.getStage(), not(equalTo(Stage.DONE)));
} }
private void slowDownRecovery() { private void slowDownRecovery(ByteSizeValue shardSize) {
long chunkSize = shardSize.bytes() / 10;
assertTrue(client().admin().cluster().prepareUpdateSettings() assertTrue(client().admin().cluster().prepareUpdateSettings()
.setTransientSettings(ImmutableSettings.builder() .setTransientSettings(ImmutableSettings.builder()
// let the default file chunk wait 2 seconds, not to delay the test for too long // one chunk per sec..
.put(RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC, "256kb")) .put(RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC, chunkSize)
.put(RecoverySettings.INDICES_RECOVERY_FILE_CHUNK_SIZE, chunkSize)
)
.get().isAcknowledged()); .get().isAcknowledged());
} }
private void restoreRecoverySpeed() { private void restoreRecoverySpeed() {
assertTrue(client().admin().cluster().prepareUpdateSettings() assertTrue(client().admin().cluster().prepareUpdateSettings()
.setTransientSettings(ImmutableSettings.builder() .setTransientSettings(ImmutableSettings.builder()
.put(RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC, "20mb")) .put(RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC, "20mb")
.put(RecoverySettings.INDICES_RECOVERY_FILE_CHUNK_SIZE, "512kb")
)
.get().isAcknowledged()); .get().isAcknowledged());
} }
@ -208,7 +214,7 @@ public class IndexRecoveryTests extends ElasticsearchIntegrationTest {
String nodeA = internalCluster().startNode(settingsBuilder().put("gateway.type", "local")); String nodeA = internalCluster().startNode(settingsBuilder().put("gateway.type", "local"));
logger.info("--> create index on node: {}", nodeA); logger.info("--> create index on node: {}", nodeA);
createAndPopulateIndex(INDEX_NAME, 1, SHARD_COUNT, REPLICA_COUNT); ByteSizeValue shardSize = createAndPopulateIndex(INDEX_NAME, 1, SHARD_COUNT, REPLICA_COUNT).getShards()[0].getStats().getStore().size();
logger.info("--> start node B"); logger.info("--> start node B");
String nodeB = internalCluster().startNode(settingsBuilder().put("gateway.type", "local")); String nodeB = internalCluster().startNode(settingsBuilder().put("gateway.type", "local"));
@ -216,7 +222,7 @@ public class IndexRecoveryTests extends ElasticsearchIntegrationTest {
ensureGreen(); ensureGreen();
logger.info("--> slowing down recoveries"); logger.info("--> slowing down recoveries");
slowDownRecovery(); slowDownRecovery(shardSize);
logger.info("--> move shard from: {} to: {}", nodeA, nodeB); logger.info("--> move shard from: {} to: {}", nodeA, nodeB);
client().admin().cluster().prepareReroute() client().admin().cluster().prepareReroute()
@ -263,7 +269,7 @@ public class IndexRecoveryTests extends ElasticsearchIntegrationTest {
assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes("3").get().isTimedOut()); assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes("3").get().isTimedOut());
logger.info("--> slowing down recoveries"); logger.info("--> slowing down recoveries");
slowDownRecovery(); slowDownRecovery(shardSize);
logger.info("--> move replica shard from: {} to: {}", nodeA, nodeC); logger.info("--> move replica shard from: {} to: {}", nodeA, nodeC);
client().admin().cluster().prepareReroute() client().admin().cluster().prepareReroute()