mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-22 21:05:23 +00:00
Without replicas we won't actually get any relocations going when removing the node constraints in this test. Adjusted the code to force relocations by forbidding nodes that hold primaries instead. Also, fixed the timeouts and asserted that we actually get relocations. Fixes #46276
This commit is contained in:
parent
40e9353947
commit
20cb95ca5e
@ -2110,8 +2110,12 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||
.put("compress", randomBoolean())
|
||||
.put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES)));
|
||||
|
||||
// Create index on 1 nodes and make sure each node has a primary by setting no replicas
|
||||
assertAcked(prepareCreate("test-idx", 1, Settings.builder().put("number_of_replicas", 0)));
|
||||
// Create index on two nodes and make sure each node has a primary by setting no replicas
|
||||
assertAcked(prepareCreate("test-idx", 2, Settings.builder()
|
||||
.put(SETTING_NUMBER_OF_REPLICAS, 0)
|
||||
.put(SETTING_NUMBER_OF_SHARDS, between(2, 10))));
|
||||
|
||||
ensureGreen("test-idx");
|
||||
|
||||
logger.info("--> indexing some data");
|
||||
for (int i = 0; i < 100; i++) {
|
||||
@ -2121,11 +2125,13 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||
assertThat(client.prepareSearch("test-idx").setSize(0).get().getHits().getTotalHits().value, equalTo(100L));
|
||||
|
||||
logger.info("--> start relocations");
|
||||
allowNodes("test-idx", internalCluster().numDataNodes());
|
||||
allowNodes("test-idx", 1);
|
||||
|
||||
logger.info("--> wait for relocations to start");
|
||||
|
||||
waitForRelocationsToStart("test-idx", TimeValue.timeValueMillis(300));
|
||||
assertBusy(() -> assertThat(
|
||||
client().admin().cluster().prepareHealth("test-idx").execute().actionGet().getRelocatingShards(), greaterThan(0)),
|
||||
1L, TimeUnit.MINUTES);
|
||||
|
||||
logger.info("--> snapshot");
|
||||
client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(false).setIndices("test-idx").get();
|
||||
@ -2744,11 +2750,6 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||
timeout.millis(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private boolean waitForRelocationsToStart(final String index, TimeValue timeout) throws InterruptedException {
|
||||
return awaitBusy(() -> client().admin().cluster().prepareHealth(index).execute().actionGet().getRelocatingShards() > 0,
|
||||
timeout.millis(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public void testSnapshotName() throws Exception {
|
||||
disableRepoConsistencyCheck("This test does not create any data in the repository");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user