Skip to content

Commit

Permalink
Add assertBusy to failing snapshot tests (opensearch-project#16146) (o…
Browse files Browse the repository at this point in the history
…pensearch-project#16147)

(cherry picked from commit 43e7597)

Signed-off-by: Lakshya Taragi <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 3f71934 commit af5a3d1
Showing 1 changed file with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void testStatusApiConsistency() {
assertEquals(snapshotStatus.getStats().getTime(), snapshotInfo.endTime() - snapshotInfo.startTime());
}

public void testStatusAPICallForShallowCopySnapshot() {
public void testStatusAPICallForShallowCopySnapshot() throws Exception {
disableRepoConsistencyCheck("Remote store repository is being used for the test");
internalCluster().startClusterManagerOnlyNode();
internalCluster().startDataOnlyNode();
Expand All @@ -136,15 +136,24 @@ public void testStatusAPICallForShallowCopySnapshot() {
final String snapshot = "snapshot";
createFullSnapshot(snapshotRepoName, snapshot);

final SnapshotStatus snapshotStatus = getSnapshotStatus(snapshotRepoName, snapshot);
assertThat(snapshotStatus.getState(), is(SnapshotsInProgress.State.SUCCESS));
assertBusy(() -> {
final SnapshotStatus snapshotStatus = client().admin()
.cluster()
.prepareSnapshotStatus(snapshotRepoName)
.setSnapshots(snapshot)
.execute()
.actionGet()
.getSnapshots()
.get(0);
assertThat(snapshotStatus.getState(), is(SnapshotsInProgress.State.SUCCESS));

final SnapshotIndexShardStatus snapshotShardState = stateFirstShard(snapshotStatus, indexName);
assertThat(snapshotShardState.getStage(), is(SnapshotIndexShardStage.DONE));
assertThat(snapshotShardState.getStats().getTotalFileCount(), greaterThan(0));
assertThat(snapshotShardState.getStats().getTotalSize(), greaterThan(0L));
assertThat(snapshotShardState.getStats().getIncrementalFileCount(), greaterThan(0));
assertThat(snapshotShardState.getStats().getIncrementalSize(), greaterThan(0L));
final SnapshotIndexShardStatus snapshotShardState = stateFirstShard(snapshotStatus, indexName);
assertThat(snapshotShardState.getStage(), is(SnapshotIndexShardStage.DONE));
assertThat(snapshotShardState.getStats().getTotalFileCount(), greaterThan(0));
assertThat(snapshotShardState.getStats().getTotalSize(), greaterThan(0L));
assertThat(snapshotShardState.getStats().getIncrementalFileCount(), greaterThan(0));
assertThat(snapshotShardState.getStats().getIncrementalSize(), greaterThan(0L));
}, 20, TimeUnit.SECONDS);
}

public void testStatusAPICallInProgressSnapshot() throws Exception {
Expand Down Expand Up @@ -193,7 +202,7 @@ public void testExceptionOnMissingSnapBlob() throws IOException {
);
}

public void testExceptionOnMissingShardLevelSnapBlob() throws IOException {
public void testExceptionOnMissingShardLevelSnapBlob() throws Exception {
disableRepoConsistencyCheck("This test intentionally corrupts the repository");

final Path repoPath = randomRepoPath();
Expand All @@ -216,11 +225,12 @@ public void testExceptionOnMissingShardLevelSnapBlob() throws IOException {
repoPath.resolve(resolvePath(indexId, "0"))
.resolve(BlobStoreRepository.SNAPSHOT_PREFIX + snapshotInfo.snapshotId().getUUID() + ".dat")
);

expectThrows(
SnapshotMissingException.class,
() -> client().admin().cluster().prepareSnapshotStatus("test-repo").setSnapshots("test-snap").execute().actionGet()
);
assertBusy(() -> {
expectThrows(
SnapshotMissingException.class,
() -> client().admin().cluster().prepareSnapshotStatus("test-repo").setSnapshots("test-snap").execute().actionGet()
);
}, 20, TimeUnit.SECONDS);
}

public void testGetSnapshotsWithoutIndices() throws Exception {
Expand Down

0 comments on commit af5a3d1

Please sign in to comment.