Wait for background refresh in testAutomaticRefresh (#45661)
If the background refresh is running, but not finished yet then the document might not be visible to the next search. Thus, if scheduledRefresh returns false, we need to wait until the background refresh is done. Closes #45571
This commit is contained in:
parent
99b21d50b8
commit
e9759b2b33
|
@ -710,10 +710,16 @@ public class IndexShardIT extends ESSingleNodeTestCase {
|
|||
// with ZERO we are guaranteed to see the doc since we will wait for a refresh in the background
|
||||
assertFalse(hasRefreshed);
|
||||
assertTrue(shard.isSearchIdle());
|
||||
} else if (randomTimeValue == null){
|
||||
// with null we are guaranteed to see the doc since do execute the refresh.
|
||||
// we can't assert on hasRefreshed since it might have been refreshed in the background on the shard concurrently
|
||||
assertFalse(shard.isSearchIdle());
|
||||
} else {
|
||||
if (randomTimeValue == null) {
|
||||
assertFalse(shard.isSearchIdle());
|
||||
}
|
||||
// we can't assert on hasRefreshed since it might have been refreshed in the background on the shard concurrently.
|
||||
// and if the background refresh wins the refresh race (both call maybeRefresh), the document might not be visible
|
||||
// until the background refresh is done.
|
||||
if (hasRefreshed == false) {
|
||||
ensureNoPendingScheduledRefresh(indexService.getThreadPool());
|
||||
}
|
||||
}
|
||||
CountDownLatch started = new CountDownLatch(1);
|
||||
Thread t = new Thread(() -> {
|
||||
|
|
Loading…
Reference in New Issue