Skip to content

Commit f6d6aa6

Browse files
authored
Fix flaky test RemoteIndexRecoveryIT.testRerouteRecovery (opensearch-project#17228)
Signed-off-by: Sachin Kale <[email protected]>
1 parent 218f353 commit f6d6aa6

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexRecoveryIT.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ private void assertOnGoingRecoveryState(
250250
assertThat(state.getStage(), not(equalTo(Stage.DONE)));
251251
}
252252

253-
private void slowDownRecovery(ByteSizeValue shardSize) {
253+
public void slowDownRecovery(ByteSizeValue shardSize) {
254254
long chunkSize = Math.max(1, shardSize.getBytes() / 10);
255255
assertTrue(
256256
client().admin()
@@ -528,7 +528,7 @@ public void testRerouteRecovery() throws Exception {
528528
assertThat(indicesService.indexServiceSafe(index).getShard(0).recoveryStats().currentAsSource(), equalTo(1));
529529
indicesService = internalCluster().getInstance(IndicesService.class, nodeB);
530530
assertThat(indicesService.indexServiceSafe(index).getShard(0).recoveryStats().currentAsTarget(), equalTo(1));
531-
}, TimeValue.timeValueSeconds(10), TimeValue.timeValueMillis(500));
531+
}, TimeValue.timeValueSeconds(60), TimeValue.timeValueMillis(500));
532532

533533
logger.info("--> request recoveries");
534534
RecoveryResponse response = client().admin().indices().prepareRecoveries(INDEX_NAME).execute().actionGet();

server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteIndexRecoveryIT.java

+24
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010

1111
import org.opensearch.cluster.metadata.IndexMetadata;
1212
import org.opensearch.common.settings.Settings;
13+
import org.opensearch.core.common.unit.ByteSizeUnit;
14+
import org.opensearch.core.common.unit.ByteSizeValue;
1315
import org.opensearch.index.IndexModule;
1416
import org.opensearch.index.IndexSettings;
1517
import org.opensearch.indices.recovery.IndexRecoveryIT;
18+
import org.opensearch.indices.recovery.RecoverySettings;
1619
import org.opensearch.indices.replication.common.ReplicationType;
1720
import org.opensearch.test.OpenSearchIntegTestCase;
1821
import org.hamcrest.Matcher;
@@ -22,6 +25,7 @@
2225

2326
import java.nio.file.Path;
2427

28+
import static org.opensearch.indices.recovery.RecoverySettings.INDICES_RECOVERY_CHUNK_SIZE_SETTING;
2529
import static org.opensearch.remotestore.RemoteStoreBaseIntegTestCase.remoteStoreClusterSettings;
2630

2731
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0)
@@ -54,6 +58,26 @@ public Settings indexSettings() {
5458
.build();
5559
}
5660

61+
@Override
62+
public void slowDownRecovery(ByteSizeValue shardSize) {
63+
logger.info("--> shardSize: " + shardSize);
64+
long chunkSize = Math.max(1, shardSize.getBytes() / 50);
65+
assertTrue(
66+
client().admin()
67+
.cluster()
68+
.prepareUpdateSettings()
69+
.setTransientSettings(
70+
Settings.builder()
71+
// one chunk per sec..
72+
.put(RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey(), chunkSize, ByteSizeUnit.BYTES)
73+
// small chunks
74+
.put(INDICES_RECOVERY_CHUNK_SIZE_SETTING.getKey(), new ByteSizeValue(chunkSize, ByteSizeUnit.BYTES))
75+
)
76+
.get()
77+
.isAcknowledged()
78+
);
79+
}
80+
5781
@After
5882
public void teardown() {
5983
clusterAdmin().prepareCleanupRepository(REPOSITORY_NAME).get();

0 commit comments

Comments
 (0)