Skip to content

Commit 3e044bf

Browse files
committed
modified testRelocationWhileIndexingRandom
1 parent 048f944 commit 3e044bf

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

server/src/internalClusterTest/java/org/elasticsearch/recovery/RelocationIT.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,13 @@ public void testRelocationWhileIndexingRandom() throws Exception {
276276
waitForDocs(numDocs, indexer);
277277
logger.info("--> {} docs indexed", numDocs);
278278

279+
IndicesService indicesService = internalCluster().getInstance(IndicesService.class, nodes[0]);
280+
IndexShard shard = indicesService.indexServiceSafe(resolveIndex("test")).getShard(0);
279281
if (throttleIndexing) {
280282
// Activate index throttling on "test" index primary shard
281-
IndicesService indicesService = internalCluster().getInstance(IndicesService.class, nodes[0]);
282-
IndexShard shard = indicesService.indexServiceSafe(resolveIndex("test")).getShard(0);
283283
shard.activateThrottling();
284284
// Verify that indexing is throttled for this shard
285-
assertBusy(() -> { assertThat(shard.getEngineOrNull().isThrottled(), equalTo(true)); });
285+
assertThat(shard.getEngineOrNull().isThrottled(), equalTo(true));
286286
}
287287
logger.info("--> starting relocations...");
288288
int nodeShiftBased = numberOfReplicas; // if we have replicas shift those
@@ -308,8 +308,22 @@ public void testRelocationWhileIndexingRandom() throws Exception {
308308
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
309309
indexer.pauseIndexing();
310310
logger.info("--> DONE relocate the shard from {} to {}", fromNode, toNode);
311+
if(throttleIndexing) {
312+
// Deactivate throttling on source shard to allow indexing threads to pass
313+
shard.deactivateThrottling();
314+
// Activate throttling on target shard before next relocation
315+
indicesService = internalCluster().getInstance(IndicesService.class, nodes[toNode]);
316+
shard = indicesService.indexServiceSafe(resolveIndex("test")).getShard(0);
317+
shard.activateThrottling();
318+
// Verify that indexing is throttled for this shard
319+
assertThat(shard.getEngineOrNull().isThrottled(), equalTo(true));
320+
}
311321
}
312322
logger.info("--> done relocations");
323+
// Deactivate throttling on the primary shard to allow indexing threads to pass
324+
if(throttleIndexing) {
325+
shard.deactivateThrottling();
326+
}
313327
logger.info("--> waiting for indexing threads to stop ...");
314328
indexer.stopAndAwaitStopped();
315329
logger.info("--> indexing threads stopped");

0 commit comments

Comments
 (0)