Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flakiness of RemoteRestoreSnapshotIT.testClusterManagerFailoverDuringSnapshotCreation #17589

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -1448,9 +1450,8 @@ public void testClusterManagerFailoverDuringSnapshotCreation() throws Exception

ensureStableCluster(4, internalCluster().getClusterManagerName());

final SnapshotInfo[] snapshotInfo = new SnapshotInfo[1];
final Boolean[] snapshotFailed = new Boolean[1];
snapshotFailed[0] = false;
final AtomicReference<SnapshotInfo> snapshotInfoRef = new AtomicReference<>();
final AtomicBoolean snapshotFailed = new AtomicBoolean(false);
Thread snapshotThread = new Thread(() -> {
try {
// Start snapshot creation
Expand All @@ -1459,10 +1460,10 @@ public void testClusterManagerFailoverDuringSnapshotCreation() throws Exception
.prepareCreateSnapshot(snapshotRepoName, snapshotName1)
.setWaitForCompletion(true)
.get();
snapshotInfo[0] = createSnapshotResponse.getSnapshotInfo();
snapshotInfoRef.set(createSnapshotResponse.getSnapshotInfo());

} catch (Exception e) {
snapshotFailed[0] = true;
snapshotFailed.set(true);
}
});
snapshotThread.start();
Expand All @@ -1482,10 +1483,11 @@ public void testClusterManagerFailoverDuringSnapshotCreation() throws Exception
repository.getRepositoryData(repositoryDataPlainActionFuture);

RepositoryData repositoryData = repositoryDataPlainActionFuture.get();
if (snapshotFailed[0]) {
assertFalse(repositoryData.getSnapshotIds().contains(snapshotInfo[0].snapshotId()));
SnapshotInfo snapshotInfo = snapshotInfoRef.get();
if (snapshotFailed.get()) {
assertTrue(repositoryData.getSnapshotIds().isEmpty());
} else {
assertTrue(repositoryData.getSnapshotIds().contains(snapshotInfo[0].snapshotId()));
assertTrue(repositoryData.getSnapshotIds().contains(snapshotInfo.snapshotId()));
}
}

Expand Down
Loading