Fix testSyncFailsIfOperationIsInFlight (#46269)
testSyncFailsIfOperationIsInFlight could fail due to the index request spawing a GCP sync (new since 7.4). Test now waits for it to finish before testing that flushed sync fails.
This commit is contained in:
parent
3d4b8e01c7
commit
2383acaa89
|
@ -38,7 +38,6 @@ import org.elasticsearch.threadpool.ThreadPool;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
|
||||
|
@ -110,12 +109,18 @@ public class SyncedFlushSingleNodeTests extends ESSingleNodeTestCase {
|
|||
assertTrue(response.success());
|
||||
}
|
||||
|
||||
public void testSyncFailsIfOperationIsInFlight() throws InterruptedException, ExecutionException {
|
||||
public void testSyncFailsIfOperationIsInFlight() throws Exception {
|
||||
createIndex("test");
|
||||
client().prepareIndex("test", "test", "1").setSource("{}", XContentType.JSON).get();
|
||||
IndexService test = getInstanceFromNode(IndicesService.class).indexService(resolveIndex("test"));
|
||||
IndexShard shard = test.getShardOrNull(0);
|
||||
|
||||
// wait for the GCP sync spawned from the index request above to complete to avoid that request disturbing the check below
|
||||
assertBusy(() -> {
|
||||
assertEquals(0, shard.getLastSyncedGlobalCheckpoint());
|
||||
assertEquals(0, shard.getActiveOperationsCount());
|
||||
});
|
||||
|
||||
SyncedFlushService flushService = getInstanceFromNode(SyncedFlushService.class);
|
||||
final ShardId shardId = shard.shardId();
|
||||
PlainActionFuture<Releasable> fut = new PlainActionFuture<>();
|
||||
|
|
Loading…
Reference in New Issue