-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add Snapshot Resiliency Test for Master Failover during Delete #54866
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
Changes from 1 commit
7c34b37
c88dff7
1ca6517
50088b6
e7444b3
3370c84
9873a89
0e3f3eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,6 +96,7 @@ | |
| import org.elasticsearch.cluster.ClusterStateListener; | ||
| import org.elasticsearch.cluster.ESAllocationTestCase; | ||
| import org.elasticsearch.cluster.NodeConnectionsService; | ||
| import org.elasticsearch.cluster.SnapshotDeletionsInProgress; | ||
| import org.elasticsearch.cluster.SnapshotsInProgress; | ||
| import org.elasticsearch.cluster.action.index.MappingUpdatedAction; | ||
| import org.elasticsearch.cluster.action.index.NodeMappingRefreshAction; | ||
|
|
@@ -407,6 +408,49 @@ public void testSnapshotWithNodeDisconnects() { | |
| assertThat(snapshotIds, hasSize(1)); | ||
| } | ||
|
|
||
| public void testSnapshotDeleteWithMasterFailOvers() { | ||
| final int dataNodes = randomIntBetween(2, 10); | ||
| final int masterNodes = randomFrom(3, 5); | ||
| setupTestCluster(masterNodes, dataNodes); | ||
|
|
||
| String repoName = "repo"; | ||
| String snapshotName = "snapshot"; | ||
| final String index = "test"; | ||
| final int shards = randomIntBetween(1, 10); | ||
|
|
||
| final boolean waitForSnapshot = randomBoolean(); | ||
| final StepListener<CreateSnapshotResponse> createSnapshotResponseStepListener = new StepListener<>(); | ||
| continueOrDie(createRepoAndIndex(repoName, index, shards), createIndexResponse -> | ||
| testClusterNodes.randomMasterNodeSafe().client.admin().cluster().prepareCreateSnapshot(repoName, snapshotName) | ||
| .setWaitForCompletion(waitForSnapshot).execute(createSnapshotResponseStepListener)); | ||
|
|
||
| final AtomicBoolean snapshotDeleteResponded = new AtomicBoolean(false); | ||
| continueOrDie(createSnapshotResponseStepListener, createSnapshotResponse -> { | ||
| scheduleNow(this::disconnectOrRestartMasterNode); | ||
| testClusterNodes.randomDataNodeSafe().client.admin().cluster() | ||
| .prepareDeleteSnapshot(repoName, snapshotName).execute(ActionListener.wrap(() -> snapshotDeleteResponded.set(true))); | ||
| }); | ||
|
|
||
| runUntil(() -> testClusterNodes.randomMasterNode().map(master -> { | ||
| if (snapshotDeleteResponded.get() == false) { | ||
| return false; | ||
| } | ||
| final SnapshotDeletionsInProgress snapshotDeletionsInProgress = | ||
| master.clusterService.state().custom(SnapshotDeletionsInProgress.TYPE); | ||
| return snapshotDeletionsInProgress == null || snapshotDeletionsInProgress.getEntries().isEmpty(); | ||
| }).orElse(false), TimeUnit.MINUTES.toMillis(1L)); | ||
|
|
||
| clearDisruptionsAndAwaitSync(); | ||
|
|
||
| final TestClusterNodes.TestClusterNode randomMaster = testClusterNodes.randomMasterNode() | ||
| .orElseThrow(() -> new AssertionError("expected to find at least one active master node")); | ||
| SnapshotsInProgress finalSnapshotsInProgress = randomMaster.clusterService.state().custom(SnapshotsInProgress.TYPE); | ||
| assertThat(finalSnapshotsInProgress.entries(), empty()); | ||
| final Repository repository = randomMaster.repositoriesService.repository(repoName); | ||
| Collection<SnapshotId> snapshotIds = getRepositoryData(repository).getSnapshotIds(); | ||
| assertThat(snapshotIds, either(hasSize(1)).or(hasSize(0))); | ||
|
||
| } | ||
|
|
||
| public void testConcurrentSnapshotCreateAndDelete() { | ||
| setupTestCluster(randomFrom(1, 3, 5), randomIntBetween(2, 10)); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failover