Skip to content

Commit

Permalink
Fix testSkipRefreshIfShardIsRefreshingAlready (#50856)
Browse files Browse the repository at this point in the history
The test checked queue size and active count, however,
ThreadPoolExecutor pulls out the request from the queue before marking
the worker active, risking that we think all tasks are done when they
are not. Now check on completed-tasks metric instead, which is
guaranteed to be monotonic.

Relates #50769
  • Loading branch information
henningandersen authored Jan 10, 2020
1 parent 4ec6ec2 commit 57518a0
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -432,19 +432,18 @@ protected long getShardWritingBytes(IndexShard shard) {
}
};
int iterations = randomIntBetween(10, 100);
ThreadPoolStats.Stats beforeStats = getRefreshThreadPoolStats();
for (int i = 0; i < iterations; i++) {
controller.forceCheck();
}
assertBusy(() -> {
ThreadPoolStats.Stats stats = getRefreshThreadPoolStats();
assertThat(stats.getQueue(), equalTo(0));
assertThat(stats.getActive(), equalTo(1));
assertThat(stats.getCompleted(), equalTo(beforeStats.getCompleted() + iterations - 1));
});
refreshLatch.get().countDown(); // allow refresh
assertBusy(() -> {
ThreadPoolStats.Stats stats = getRefreshThreadPoolStats();
assertThat(stats.getQueue(), equalTo(0));
assertThat(stats.getActive(), equalTo(0));
assertThat(stats.getCompleted(), equalTo(beforeStats.getCompleted() + iterations));
});
assertThat(shard.refreshStats().getTotal(), equalTo(refreshStats.getTotal() + 1));
closeShards(shard);
Expand Down

0 comments on commit 57518a0

Please sign in to comment.