From f7d272622379ef2a63881bbdb5492fd6e95e41c6 Mon Sep 17 00:00:00 2001 From: Lukasz Soszynski Date: Mon, 24 Oct 2022 15:45:47 +0200 Subject: [PATCH] Snapshot tests stability improved. An exception is not able to interrupt active waiting. Signed-off-by: Lukasz Soszynski --- .../java/org/opensearch/security/SearchOperationTest.java | 5 +++-- .../java/org/opensearch/security/SnapshotSteps.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/integrationTest/java/org/opensearch/security/SearchOperationTest.java b/src/integrationTest/java/org/opensearch/security/SearchOperationTest.java index 65fdf7f79d..a6702344b8 100644 --- a/src/integrationTest/java/org/opensearch/security/SearchOperationTest.java +++ b/src/integrationTest/java/org/opensearch/security/SearchOperationTest.java @@ -358,7 +358,7 @@ public void cleanData() throws ExecutionException, InterruptedException { if (indicesExistsResponse.isExists()) { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indexToBeDeleted); indices.delete(deleteIndexRequest).actionGet(); - Awaitility.await().until(() -> indices.exists(indicesExistsRequest).get().isExists() == false); + Awaitility.await().ignoreExceptions().until(() -> indices.exists(indicesExistsRequest).get().isExists() == false); } } @@ -1629,7 +1629,8 @@ public void shouldRestoreSnapshot_positive() throws IOException { // 7. wait until snapshot is restored CountRequest countRequest = new CountRequest(RESTORED_SONG_INDEX_NAME); - Awaitility.await().until(() -> restHighLevelClient.count(countRequest, DEFAULT).getCount() == 2); + Awaitility.await().ignoreExceptions().alias("Index contains proper number of documents restored from snapshot.") + .until(() -> restHighLevelClient.count(countRequest, DEFAULT).getCount() == 2); //8. verify that document are present in restored index assertThat(internalClient, clusterContainsDocumentWithFieldValue(RESTORED_SONG_INDEX_NAME, "Eins", FIELD_TITLE, TITLE_MAGNUM_OPUS)); diff --git a/src/integrationTest/java/org/opensearch/security/SnapshotSteps.java b/src/integrationTest/java/org/opensearch/security/SnapshotSteps.java index 04155e762f..0fbaf78435 100644 --- a/src/integrationTest/java/org/opensearch/security/SnapshotSteps.java +++ b/src/integrationTest/java/org/opensearch/security/SnapshotSteps.java @@ -56,7 +56,7 @@ public CreateSnapshotResponse createSnapshot(String repositoryName, String snaps public void waitForSnapshotCreation(String repositoryName, String snapshotName) { GetSnapshotsRequest getSnapshotsRequest = new GetSnapshotsRequest(repositoryName, new String[] { snapshotName }); - Awaitility.await().until(() -> { + Awaitility.await().alias("wait for snapshot creation").ignoreExceptions().until(() -> { GetSnapshotsResponse snapshotsResponse = snapshotClient.get(getSnapshotsRequest, DEFAULT); SnapshotInfo snapshotInfo = snapshotsResponse.getSnapshots().get(0); return SnapshotState.SUCCESS.equals(snapshotInfo.state());