Fix AbstractSearchableSnapshotsRestTestCase.testClearCache (#58847)
Since #58728 part of searchable snapshot shard files are written in cache in an asynchronous manner in a dedicated thread pool. It means that even if a search query is successful and returns, there are still more bytes to write in the cached files on disk. On CI this can be slow; if we want to check that the cached_bytes_written has changed we need to check multiple times to give some time for the cached data to be effectively written.
This commit is contained in:
parent
c768467155
commit
ec4843f4df
|
@ -203,9 +203,11 @@ public abstract class AbstractSearchableSnapshotsRestTestCase extends ESRestTest
|
||||||
searchResults = search(restoredIndexName, QueryBuilders.matchAllQuery(), Boolean.TRUE);
|
searchResults = search(restoredIndexName, QueryBuilders.matchAllQuery(), Boolean.TRUE);
|
||||||
assertThat(extractValue(searchResults, "hits.total.value"), equalTo(numDocs));
|
assertThat(extractValue(searchResults, "hits.total.value"), equalTo(numDocs));
|
||||||
|
|
||||||
|
assertBusy(() -> {
|
||||||
final long bytesInCacheAfterSearch = sumCachedBytesWritten.apply(searchableSnapshotStats(restoredIndexName));
|
final long bytesInCacheAfterSearch = sumCachedBytesWritten.apply(searchableSnapshotStats(restoredIndexName));
|
||||||
assertThat(bytesInCacheAfterSearch, greaterThan(bytesInCacheBeforeClear));
|
assertThat(bytesInCacheAfterSearch, greaterThan(bytesInCacheBeforeClear));
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearCache(String restoredIndexName) throws IOException {
|
private void clearCache(String restoredIndexName) throws IOException {
|
||||||
|
@ -419,6 +421,6 @@ public abstract class AbstractSearchableSnapshotsRestTestCase extends ESRestTest
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
interface SearchableSnapshotsTestCaseBody {
|
interface SearchableSnapshotsTestCaseBody {
|
||||||
void runTest(String indexName, int numDocs) throws IOException;
|
void runTest(String indexName, int numDocs) throws Exception;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue