Skip to content

Commit

Permalink
Fix intermittant issue with number of requests
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied committed Sep 21, 2023
1 parent ca93497 commit ef6c383
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;

import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
import com.google.common.base.Stopwatch;
Expand Down Expand Up @@ -1768,6 +1769,7 @@ public void shouldDeleteSnapshot_negative() throws IOException {
@Test
public void shouldRestoreSnapshot_positive() throws IOException {
final String snapshotName = "restore-snapshot-positive";
final AtomicInteger countRequestsIssued = new AtomicInteger();
try (RestHighLevelClient restHighLevelClient = cluster.getRestHighLevelClient(LIMITED_WRITE_USER)) {
SnapshotSteps steps = new SnapshotSteps(restHighLevelClient);
// 1. create some documents
Expand Down Expand Up @@ -1805,7 +1807,10 @@ public void shouldRestoreSnapshot_positive() throws IOException {
Awaitility.await()
.ignoreExceptions()
.alias("Index contains proper number of documents restored from snapshot.")
.until(() -> restHighLevelClient.count(countRequest, DEFAULT).getCount() == 2);
.until(() -> {
countRequestsIssued.incrementAndGet();
return restHighLevelClient.count(countRequest, DEFAULT).getCount() == 2;
});

// 8. verify that document are present in restored index
assertThat(
Expand All @@ -1829,7 +1834,7 @@ public void shouldRestoreSnapshot_positive() throws IOException {
"/_snapshot/test-snapshot-repository/restore-snapshot-positive/_restore"
)
);
auditLogsRule.assertExactlyOne(userAuthenticated(LIMITED_WRITE_USER).withRestRequest(POST, "/restored_write_song_index/_count"));
auditLogsRule.assertExactly(countRequestsIssued.get(), userAuthenticated(LIMITED_WRITE_USER).withRestRequest(POST, "/restored_write_song_index/_count"));
auditLogsRule.assertExactly(2, userAuthenticated(LIMITED_WRITE_USER).withRestRequest(POST, "/_bulk"));
auditLogsRule.assertAtLeast(
1,
Expand Down

0 comments on commit ef6c383

Please sign in to comment.