Skip to content

Commit

Permalink
SnapshotDisruptionIT
Browse files Browse the repository at this point in the history
Without changes test fails, because Zen2 retries snapshot creation
as soon as network partition heals. This results into race between
creating snapshot and test cleanup logic (deleting index).
Zen1 on the other hand, also schedules retry, but it takes some time
after network partition heals, so cleanup logic executes latter and test
passes.
The check that snapshot is eventually created is added to the end of the
test
  • Loading branch information
Andrey Ershov committed Dec 7, 2018
1 parent 3395e2e commit edfa48a
Showing 1 changed file with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
.put(AbstractDisruptionTestCase.DEFAULT_SETTINGS)
.put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false)
.put(TestZenDiscovery.USE_ZEN2.getKey(), false) // requires more work
.put(DiscoverySettings.COMMIT_TIMEOUT_SETTING.getKey(), "30s")
.build();
}
Expand Down Expand Up @@ -133,7 +132,7 @@ public void clusterChanged(ClusterChangedEvent event) {

logger.info("--> wait until the snapshot is done");
assertBusy(() -> {
SnapshotsInProgress snapshots = dataNodeClient().admin().cluster().prepareState().setLocal(true).get().getState()
SnapshotsInProgress snapshots = dataNodeClient().admin().cluster().prepareState().setLocal(false).get().getState()
.custom(SnapshotsInProgress.TYPE);
if (snapshots != null && snapshots.entries().size() > 0) {
logger.info("Current snapshot state [{}]", snapshots.entries().get(0).state());
Expand All @@ -146,15 +145,9 @@ public void clusterChanged(ClusterChangedEvent event) {
logger.info("--> verify that snapshot was successful or no longer exist");
assertBusy(() -> {
try {
GetSnapshotsResponse snapshotsStatusResponse = dataNodeClient().admin().cluster().prepareGetSnapshots("test-repo")
.setSnapshots("test-snap-2").get();
SnapshotInfo snapshotInfo = snapshotsStatusResponse.getSnapshots().get(0);
assertEquals(SnapshotState.SUCCESS, snapshotInfo.state());
assertEquals(snapshotInfo.totalShards(), snapshotInfo.successfulShards());
assertEquals(0, snapshotInfo.failedShards());
logger.info("--> done verifying");
assertSnapshotExists("test-repo", "test-snap-2");
} catch (SnapshotMissingException exception) {
logger.info("--> snapshot doesn't exist");
logger.info("--> done verifying, snapshot doesn't exist");
}
}, 1, TimeUnit.MINUTES);

Expand All @@ -172,6 +165,21 @@ public void clusterChanged(ClusterChangedEvent event) {
cause = cause.getCause();
assertThat(cause, instanceOf(FailedToCommitClusterStateException.class));
}

logger.info("--> verify that snapshot eventually will be created due to retries");
assertBusy(() -> {
assertSnapshotExists("test-repo", "test-snap-2");
}, 1, TimeUnit.MINUTES);
}

private void assertSnapshotExists(String repository, String snapshot) {
GetSnapshotsResponse snapshotsStatusResponse = dataNodeClient().admin().cluster().prepareGetSnapshots(repository)
.setSnapshots(snapshot).get();
SnapshotInfo snapshotInfo = snapshotsStatusResponse.getSnapshots().get(0);
assertEquals(SnapshotState.SUCCESS, snapshotInfo.state());
assertEquals(snapshotInfo.totalShards(), snapshotInfo.successfulShards());
assertEquals(0, snapshotInfo.failedShards());
logger.info("--> done verifying, snapshot exists");
}

private void createRandomIndex(String idxName) throws InterruptedException {
Expand Down

0 comments on commit edfa48a

Please sign in to comment.