-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Snapshot Interop] Adding more ITs for Snapshot Interoperability with… #9785
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,6 +157,11 @@ public void testCloneSnapshotIndex() throws Exception { | |
assertEquals(status1.getStats().getTotalSize(), status2.getStats().getTotalSize()); | ||
} | ||
|
||
/** | ||
* This test checks for lock file count in remote store after cloning the snapshot and also validates that | ||
* shard generation doesn't change after taking a shallow clone snapshot. | ||
* @throws Exception | ||
*/ | ||
public void testCloneShallowSnapshotIndex() throws Exception { | ||
disableRepoConsistencyCheck("This test uses remote store repository"); | ||
FeatureFlagSetter.set(FeatureFlags.REMOTE_STORE); | ||
|
@@ -168,16 +173,9 @@ public void testCloneShallowSnapshotIndex() throws Exception { | |
final Path snapshotRepoPath = randomRepoPath(); | ||
createRepository(snapshotRepoName, "fs", snapshotRepoPath); | ||
|
||
final String shallowSnapshotRepoName = "shallow-snapshot-repo-name"; | ||
final Path shallowSnapshotRepoPath = randomRepoPath(); | ||
createRepository(shallowSnapshotRepoName, "fs", snapshotRepoSettingsForShallowCopy(shallowSnapshotRepoPath)); | ||
|
||
final Path remoteStoreRepoPath = randomRepoPath(); | ||
createRepository(remoteStoreRepoName, "fs", remoteStoreRepoPath); | ||
|
||
final String indexName = "index-1"; | ||
createIndexWithRandomDocs(indexName, randomIntBetween(5, 10)); | ||
|
||
final String remoteStoreEnabledIndexName = "remote-index-1"; | ||
final Settings remoteStoreEnabledIndexSettings = getRemoteStoreBackedIndexSettings(); | ||
createIndex(remoteStoreEnabledIndexName, remoteStoreEnabledIndexSettings); | ||
|
@@ -187,21 +185,146 @@ public void testCloneShallowSnapshotIndex() throws Exception { | |
createFullSnapshot(snapshotRepoName, snapshot); | ||
assert (getLockFilesInRemoteStore(remoteStoreEnabledIndexName, remoteStoreRepoName).length == 0); | ||
|
||
indexRandomDocs(indexName, randomIntBetween(20, 100)); | ||
indexRandomDocs(remoteStoreEnabledIndexName, randomIntBetween(20, 100)); | ||
|
||
logger.info("Updating repo setting to enable shallow copy snapshots"); | ||
createRepository(snapshotRepoName, "fs", snapshotRepoSettingsForShallowCopy(snapshotRepoPath)); | ||
final String shallowSnapshot = "shallow-snapshot"; | ||
createFullSnapshot(shallowSnapshotRepoName, shallowSnapshot); | ||
createFullSnapshot(snapshotRepoName, shallowSnapshot); | ||
assert (getLockFilesInRemoteStore(remoteStoreEnabledIndexName, remoteStoreRepoName).length == 1); | ||
|
||
if (randomBoolean()) { | ||
assertAcked(admin().indices().prepareDelete(indexName)); | ||
} | ||
final RepositoryData repositoryData = getRepositoryData(snapshotRepoName); | ||
final IndexId indexId = repositoryData.resolveIndexId(remoteStoreEnabledIndexName); | ||
final int shardId = 0; | ||
final String currentShardGen = repositoryData.shardGenerations().getShardGen(indexId, shardId); | ||
|
||
final String sourceSnapshot = shallowSnapshot; | ||
final String targetSnapshot = "target-snapshot"; | ||
assertAcked(startClone(snapshotRepoName, sourceSnapshot, targetSnapshot, remoteStoreEnabledIndexName).get()); | ||
assert (getLockFilesInRemoteStore(remoteStoreEnabledIndexName, remoteStoreRepoName).length == 2); | ||
|
||
final RepositoryData updatedRepositoryData = getRepositoryData(snapshotRepoName); | ||
final String updatedShardGen = updatedRepositoryData.shardGenerations().getShardGen(indexId, shardId); | ||
assert (updatedShardGen.equals(currentShardGen)); | ||
} | ||
|
||
/** | ||
* This test checks that cloning a partial shallow copy snapshot fails. | ||
* @throws Exception | ||
*/ | ||
public void testShallowClonePartialSourceSnapshot() throws Exception { | ||
disableRepoConsistencyCheck("Remote store repository is being used in the test"); | ||
FeatureFlagSetter.set(FeatureFlags.REMOTE_STORE); | ||
|
||
internalCluster().startClusterManagerOnlyNode(); | ||
final String dataNode = internalCluster().startDataOnlyNode(); | ||
ensureStableCluster(2); | ||
final String clusterManagerNode = internalCluster().getClusterManagerName(); | ||
|
||
final String snapshotRepoName = "snapshot-repo-name"; | ||
final Path snapshotRepoPath = randomRepoPath(); | ||
createRepository(snapshotRepoName, "mock", snapshotRepoSettingsForShallowCopy(snapshotRepoPath)); | ||
|
||
final Path remoteStoreRepoPath = randomRepoPath(); | ||
createRepository("remote-store-repo-name", "fs", remoteStoreRepoPath); | ||
|
||
final String remoteStoreEnabledIndexName = "remote-index-1"; | ||
final Settings remoteStoreEnabledIndexSettings = getRemoteStoreBackedIndexSettings(); | ||
createIndex(remoteStoreEnabledIndexName, remoteStoreEnabledIndexSettings); | ||
indexRandomDocs(remoteStoreEnabledIndexName, randomIntBetween(5, 10)); | ||
|
||
// Creating a partial shallow copy snapshot | ||
final String snapshot = "snapshot"; | ||
blockNodeWithIndex(snapshotRepoName, remoteStoreEnabledIndexName); | ||
blockDataNode(snapshotRepoName, dataNode); | ||
|
||
final Client clusterManagerClient = internalCluster().clusterManagerClient(); | ||
final ActionFuture<CreateSnapshotResponse> snapshotFuture = clusterManagerClient.admin() | ||
.cluster() | ||
.prepareCreateSnapshot(snapshotRepoName, snapshot) | ||
.setWaitForCompletion(true) | ||
.execute(); | ||
|
||
awaitNumberOfSnapshotsInProgress(1); | ||
waitForBlock(dataNode, snapshotRepoName, TimeValue.timeValueSeconds(30L)); | ||
internalCluster().restartNode(dataNode); | ||
assertThat(snapshotFuture.get().getSnapshotInfo().state(), is(SnapshotState.PARTIAL)); | ||
|
||
unblockAllDataNodes(snapshotRepoName); | ||
ensureStableCluster(2, clusterManagerNode); | ||
|
||
final SnapshotException sne = expectThrows( | ||
SnapshotException.class, | ||
() -> startClone(clusterManagerClient, snapshotRepoName, snapshot, "target-snapshot", remoteStoreEnabledIndexName).actionGet( | ||
TimeValue.timeValueSeconds(30L) | ||
) | ||
); | ||
assertThat( | ||
sne.getMessage(), | ||
containsString( | ||
"Can't clone index [" | ||
+ getRepositoryData(snapshotRepoName).resolveIndexId(remoteStoreEnabledIndexName) | ||
+ "] because its snapshot was not successful." | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* This test checks that clone operation fails if there's a failure while cloning the lock file. | ||
* @throws Exception | ||
*/ | ||
public void testShallowCloneAcquireLockFailed() throws Exception { | ||
disableRepoConsistencyCheck("This test uses remote store repository"); | ||
FeatureFlagSetter.set(FeatureFlags.REMOTE_STORE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need this flag now as REMOTE_STORE is GA since 2.10. |
||
internalCluster().startClusterManagerOnlyNode(remoteStoreClusterSettings("remote-store-repo-name")); | ||
internalCluster().startDataOnlyNode(); | ||
|
||
logger.info("--> creating snapshot repository"); | ||
final String shallowSnapshotRepoName = "shallow-snapshot-repo-name"; | ||
final Path shallowSnapshotRepoPath = randomRepoPath(); | ||
createRepository(shallowSnapshotRepoName, "mock", snapshotRepoSettingsForShallowCopy(shallowSnapshotRepoPath)); | ||
|
||
logger.info("--> creating remote store repository"); | ||
final String remoteStoreRepoName = "remote-store-repo-name"; | ||
final Path remoteStoreRepoPath = randomRepoPath(); | ||
Settings.Builder remoteStoreRepoSettingsBuilder = Settings.builder().put("location", remoteStoreRepoPath); | ||
createRepository(remoteStoreRepoName, "mock", remoteStoreRepoSettingsBuilder); | ||
|
||
final String indexName = "index-1"; | ||
createIndexWithRandomDocs(indexName, randomIntBetween(5, 10)); | ||
|
||
final String remoteStoreEnabledIndexName = "remote-index-1"; | ||
final Settings remoteStoreEnabledIndexSettings = getRemoteStoreBackedIndexSettings(); | ||
createIndex(remoteStoreEnabledIndexName, remoteStoreEnabledIndexSettings); | ||
indexRandomDocs(remoteStoreEnabledIndexName, randomIntBetween(5, 10)); | ||
|
||
final String snapshot = "snapshot"; | ||
createFullSnapshot(shallowSnapshotRepoName, snapshot); | ||
|
||
assert (getLockFilesInRemoteStore(remoteStoreEnabledIndexName, remoteStoreRepoName).length == 1); | ||
assert (clusterAdmin().prepareGetSnapshots(shallowSnapshotRepoName).get().getSnapshots().size() == 1); | ||
|
||
logger.info("Updating repo settings"); | ||
remoteStoreRepoSettingsBuilder.putList("regexes_to_fail_io", "lock$"); | ||
createRepository(remoteStoreRepoName, "mock", remoteStoreRepoSettingsBuilder); | ||
|
||
final String sourceSnapshot = snapshot; | ||
final String targetSnapshot = "target-snapshot"; | ||
expectThrows( | ||
ExecutionException.class, | ||
() -> startClone(shallowSnapshotRepoName, sourceSnapshot, targetSnapshot, indexName, remoteStoreEnabledIndexName).get() | ||
); | ||
|
||
assert (getLockFilesInRemoteStore(remoteStoreEnabledIndexName, remoteStoreRepoName).length == 1); | ||
assert (clusterAdmin().prepareGetSnapshots(shallowSnapshotRepoName).get().getSnapshots().size() == 1); | ||
|
||
logger.info("Updating repo settings"); | ||
remoteStoreRepoSettingsBuilder.remove("regexes_to_fail_io"); | ||
createRepository(remoteStoreRepoName, "mock", remoteStoreRepoSettingsBuilder); | ||
|
||
assertAcked(startClone(shallowSnapshotRepoName, sourceSnapshot, targetSnapshot, indexName, remoteStoreEnabledIndexName).get()); | ||
logger.info("Lock files count: {}", getLockFilesInRemoteStore(remoteStoreEnabledIndexName, remoteStoreRepoName).length); | ||
assert (getLockFilesInRemoteStore(remoteStoreEnabledIndexName, remoteStoreRepoName).length == 2); | ||
assert (clusterAdmin().prepareGetSnapshots(shallowSnapshotRepoName).get().getSnapshots().size() == 2); | ||
} | ||
|
||
public void testShallowCloneNameAvailability() throws Exception { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can you move these common lines to a different method, so that they can be reused in other tests?