-
Notifications
You must be signed in to change notification settings - Fork 1.9k
IGNITE-29050 Introduce snapshot deletion command #13577
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
Open
Vladsz83
wants to merge
86
commits into
apache:master
Choose a base branch
from
Vladsz83:Introduce-snapshot-deletion-command
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
86 commits
Select commit
Hold shift + click to select a range
eb6273c
neuroslop
Vladsz83 d9aa470
IGNITE-29037 Refactored Message Factory usage in TCP Discovery implem…
petrov-mg 7042aec
raw
Vladsz83 682a21c
raw
Vladsz83 bcc72c4
Merge branch 'master' into support-snapshot-lists
Vladsz83 3ab443a
raw
Vladsz83 9171c7e
raw
Vladsz83 de68328
+ snpPath
Vladsz83 f0996e9
better tests
Vladsz83 80c7644
own test
Vladsz83 c8d1c25
Merge branch 'master' into snp-delete
Vladsz83 fc11a5f
+ test
Vladsz83 8a007e3
Simplification
Vladsz83 97ab26c
+ restore test
Vladsz83 fbb2cf8
+ create test
Vladsz83 2ed26ad
reimpl tests
Vladsz83 9b0e5ff
better IgniteClusterSnapshotDeleteTest
Vladsz83 b09e0b3
+incr test
Vladsz83 71717c2
raw
Vladsz83 7148da6
+ feature support test
Vladsz83 d36c642
+ IgniteClusterSnapshotDeleteTest
Vladsz83 9a658df
fix
Vladsz83 35a4c9d
Merge branch 'master' into Introduce-snapshot-deletion-command
Vladsz83 d715c66
test fix + doc
Vladsz83 e6aa330
+ RU test. + many small fixes.
Vladsz83 4233322
review fixes
Vladsz83 b11f389
test fix
Vladsz83 37cb071
Merge branch 'master' into IGNITE-29050-Introduce-snapshot-deletion-c…
Vladsz83 f00d266
+ tests
Vladsz83 57909f4
+ tests
Vladsz83 edd86d7
Merge branch 'master' into Introduce-snapshot-deletion-command
Vladsz83 7e82295
+ delete-deletePath test
Vladsz83 ed9cc3a
+ another delete-deletePath tests
Vladsz83 bb1dfec
+ test pf deletion repeat on restarted offline node
Vladsz83 129b090
+ stop-node test, fixes
Vladsz83 4249205
revert delete cancel flag
Vladsz83 b7c182d
+ RU test
Vladsz83 a67c484
Merge branch 'master' into IGNITE-29050-Introduce-snapshot-deletion-c…
Vladsz83 a0425cb
+ raw testDeletionInIgnite
Vladsz83 d30d4f9
in-ignite deleteion test fix
Vladsz83 852904f
Major fix of testDeleteNotSnapshotSharedDirectory(), reimpl of snp tr…
Vladsz83 f416646
+ delete tests .Checkstyle
Vladsz83 bb9d486
- all in node tree
Vladsz83 eae0892
better delete tests
Vladsz83 c04edd7
fixes
Vladsz83 6596432
test fixes, fixes
Vladsz83 4977c26
test fixes, fixes
Vladsz83 3da6b6a
review fixes, checkstyle.
Vladsz83 6c076ae
fixes
Vladsz83 0f09da9
+ baseline check and warning
Vladsz83 219c572
+ baseline check and warning
Vladsz83 d8ce7d8
review fixes
Vladsz83 ab3043c
Merge remote-tracking branch 'my/Introduce-snapshot-deletion-command'…
Vladsz83 95bc7a1
fixes
Vladsz83 501a6b9
ru fixes
Vladsz83 23fe41c
ru fixes
Vladsz83 0e96740
doc fix
Vladsz83 204acaa
+ corrupted metafile test
Vladsz83 e6086d6
manual review, review fixes
Vladsz83 d4c7e88
test fixes
Vladsz83 2b2cc21
flaky fixes
Vladsz83 b1e8d98
+ doc, + test fix
Vladsz83 9d493a0
doc fix
Vladsz83 1dd3d53
fix of the confirmation promt.
Vladsz83 2092624
review fixes
Vladsz83 0dd70d4
review fix
Vladsz83 3b0da46
review fix
Vladsz83 be040de
revert test
Vladsz83 1f5ffbc
Merge branch 'master' into IGNITE-29050-Introduce-snapshot-deletion-c…
Vladsz83 045ad6a
Merge branch 'master' into IGNITE-29050-Introduce-snapshot-deletion-c…
Vladsz83 4a0f8b2
review fixes
Vladsz83 b3f1213
review fixes
Vladsz83 b4af64c
Merge remote-tracking branch 'my/Introduce-snapshot-deletion-command'…
Vladsz83 67122e0
review fixes
Vladsz83 6fe41e1
review fixes
Vladsz83 e4ae1db
- sync
Vladsz83 ddf9c1c
review fix
Vladsz83 4a29b49
review fixes
Vladsz83 e491071
review fixes
Vladsz83 16cc24c
review fixes
Vladsz83 6d05812
review fixes
Vladsz83 c14969e
+ RU task test
Vladsz83 e01aadf
+ character case name tests
Vladsz83 b887fcd
fixes
Vladsz83 8db6b4a
review fixes
Vladsz83 4c16a2c
Merge remote-tracking branch 'my/Introduce-snapshot-deletion-command'…
Vladsz83 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
244 changes: 244 additions & 0 deletions
244
...ol-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerDeleteSnapshotTest.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,244 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.ignite.util; | ||
|
|
||
| import java.io.File; | ||
| import java.nio.file.DirectoryStream; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.Paths; | ||
| import java.util.Collection; | ||
| import org.apache.ignite.IgniteDataStreamer; | ||
| import org.apache.ignite.configuration.IgniteConfiguration; | ||
| import org.apache.ignite.internal.IgniteEx; | ||
| import org.apache.ignite.internal.management.snapshot.SnapshotDeleteCommand; | ||
| import org.apache.ignite.internal.util.typedef.F; | ||
| import org.apache.ignite.internal.util.typedef.internal.U; | ||
| import org.apache.ignite.testframework.GridTestUtils; | ||
| import org.junit.Test; | ||
| import org.junit.runners.Parameterized.Parameter; | ||
| import org.junit.runners.Parameterized.Parameters; | ||
|
|
||
| import static java.nio.file.Files.newDirectoryStream; | ||
| import static org.apache.ignite.cluster.ClusterState.ACTIVE; | ||
| import static org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK; | ||
| import static org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.snp; | ||
| import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; | ||
| import static org.junit.Assume.assumeTrue; | ||
|
|
||
| /** Test for the command '--snapshot delete'. */ | ||
| public class GridCommandHandlerDeleteSnapshotTest extends GridCommandHandlerAbstractTest { | ||
| /** Value: -1 - do not use, 1 - server node, 0 - client node. */ | ||
| @Parameter(1) | ||
| public int extraNodeIsServer = -1; | ||
|
|
||
| /** */ | ||
| @Parameter(2) | ||
| public boolean incremental; | ||
|
|
||
| /** */ | ||
| @Parameter(3) | ||
| public boolean changeBaseline; | ||
|
|
||
| /** */ | ||
| @Parameter(4) | ||
| public boolean customPath; | ||
|
|
||
| /** */ | ||
| @Parameter(5) | ||
| public boolean separatedWorkDir; | ||
|
|
||
| /** */ | ||
| @Parameters(name = "client={0},useExtraNode={1},inc={2},chBaseln={3},cstSnpPath={4},ownWorkDir={5}") | ||
| public static Collection<?> parameters() { | ||
| return GridTestUtils.cartesianProduct( | ||
| commandHandlers(), | ||
| F.asList(-1, 1, 0), // Use extra node (do not use at all, server node, client node); | ||
| F.asList(false, true), // Add incremental snapshot; | ||
| F.asList(false, true), // Change baseline; | ||
| F.asList(false, true), // Use custom snapshot path; | ||
| F.asList(false, true) // Separated (own) work directory. | ||
| ); | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override protected void afterTest() throws Exception { | ||
| super.afterTest(); | ||
|
|
||
| stopAllGrids(); | ||
|
|
||
| cleanPersistenceDir(); | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override protected void beforeTest() throws Exception { | ||
| super.beforeTest(); | ||
|
|
||
| /** Handy if test running is interrupted and {@link #afterTest()} isn't invoked. */ | ||
|
Vladsz83 marked this conversation as resolved.
|
||
| cleanPersistenceDir(); | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override protected void cleanPersistenceDir() throws Exception { | ||
| super.cleanPersistenceDir(); | ||
|
|
||
| // Also cleans separated snapshot working directories and custom snapshot paths. | ||
| try (DirectoryStream<Path> files = newDirectoryStream(Paths.get(U.defaultWorkDirectory()))) { | ||
| for (Path path : files) | ||
| U.delete(path); | ||
| } | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { | ||
| IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); | ||
|
|
||
| if (separatedWorkDir) | ||
| cfg.setWorkDirectory(new File(U.defaultWorkDirectory(), igniteInstanceName).getAbsolutePath()); | ||
|
|
||
| return cfg; | ||
| } | ||
|
|
||
| /** */ | ||
| @Test | ||
| public void testSnapshotDelete() throws Exception { | ||
|
Vladsz83 marked this conversation as resolved.
|
||
| // A custom snapshot path actually puts snapshots in a shared directory. This skews the results when dedicated | ||
| // work directories are set. | ||
| assumeTrue(!customPath || !separatedWorkDir); | ||
|
|
||
| int entriesCnt = 100; | ||
| int initNodes = 3; | ||
|
|
||
| walCompactionEnabled(incremental); | ||
|
|
||
| IgniteEx ig = (IgniteEx)startGridsMultiThreaded(initNodes); | ||
|
|
||
| if (changeBaseline) { | ||
| ig.cluster().baselineAutoAdjustEnabled(false); | ||
|
|
||
| ig.cluster().setBaselineTopology(ig.cluster().topologyVersion()); | ||
| } | ||
|
|
||
| ig.cluster().state(ACTIVE); | ||
|
|
||
| createCacheAndPreload(ig, entriesCnt); | ||
|
|
||
| File cstSnpsRoot = customPath | ||
| ? new File(grid(0).context().pdsFolderResolver().fileTree().snapshotsRoot(), "ex_snapshots") | ||
| : null; | ||
| File snpDir = new File(customPath ? cstSnpsRoot : ig.context().pdsFolderResolver().fileTree().snapshotsRoot(), "testSnapshot"); | ||
|
|
||
| snp(ig).createSnapshot("testSnapshot", customPath ? cstSnpsRoot.getAbsolutePath() : null, false, false) | ||
| .get(getTestTimeout()); | ||
|
|
||
| if (incremental) { | ||
| for (int i = 0; i < 3; ++i) { | ||
| int dataIdx = entriesCnt + entriesCnt / 4 * i; | ||
|
|
||
| try (IgniteDataStreamer<Object, Object> streamer = ig.dataStreamer(DEFAULT_CACHE_NAME)) { | ||
| for (int d = dataIdx; d < dataIdx + entriesCnt / 4; ++d) | ||
| streamer.addData(d, d); | ||
| } | ||
|
|
||
| snp(ig).createSnapshot("testSnapshot", customPath ? cstSnpsRoot.getAbsolutePath() : null, true, false) | ||
| .get(getTestTimeout()); | ||
| } | ||
| } | ||
|
|
||
| String baselineGone = null; | ||
|
|
||
| // Optionally restarts with the same servers number, but changed baseline. The snapshot is kept on the same | ||
| // previous nodes independently of the baseline. | ||
| if (changeBaseline) { | ||
| baselineGone = grid(initNodes - 1).name(); | ||
|
|
||
| ig.destroyCache(DEFAULT_CACHE_NAME); | ||
| awaitPartitionMapExchange(); | ||
|
|
||
| stopAllGrids(); | ||
|
|
||
| ig = (IgniteEx)startGridsMultiThreaded(initNodes - 1); | ||
|
|
||
| ig.cluster().setBaselineTopology(ig.cluster().topologyVersion()); | ||
|
|
||
| startGrid(initNodes - 1); | ||
|
|
||
| assertEquals(initNodes - 1, ig.cluster().currentBaselineTopology().size()); | ||
| assertEquals(initNodes, ig.cluster().nodes().size()); | ||
| } | ||
|
|
||
| // Optionally adds extra server or client node. | ||
| if (extraNodeIsServer == 1) | ||
| startGrid(initNodes); | ||
| else if (extraNodeIsServer == 0) | ||
| startGrid(CLIENT_NODE_NAME_PREFIX); | ||
|
|
||
| injectTestSystemOut(); | ||
|
|
||
| // Tests missing snapshot deletion. | ||
| if (customPath) { | ||
| assertEquals(EXIT_CODE_OK, execute(newCommandHandler(), "--snapshot", "delete", "--src", | ||
| cstSnpsRoot.getAbsolutePath(), "wrongSnapshot")); | ||
|
|
||
| assertEquals(EXIT_CODE_OK, execute(newCommandHandler(), "--snapshot", "delete", "--src", | ||
| cstSnpsRoot.getAbsolutePath() + "_wrongPath", "testSnapshot")); | ||
| } | ||
| else | ||
| assertEquals(EXIT_CODE_OK, execute(newCommandHandler(), "--snapshot", "delete", "wrongSnapshot")); | ||
|
|
||
| String out = testOut.toString(); | ||
|
|
||
| assertFalse(out.contains(SnapshotDeleteCommand.REMOVED_PREF)); | ||
| assertFalse(out.contains(SnapshotDeleteCommand.NODE_NOT_FOUND_PREF)); | ||
| assertTrue(out.contains(SnapshotDeleteCommand.NOT_FOUND)); | ||
|
|
||
| testOut.reset(); | ||
| assertTrue(testOut.toString().isEmpty()); | ||
|
|
||
| if (customPath) { | ||
| assertEquals(EXIT_CODE_OK, execute(newCommandHandler(), "--snapshot", "delete", "--src", | ||
| cstSnpsRoot.getAbsolutePath(), "testSnapshot")); | ||
| } | ||
| else | ||
| assertEquals(EXIT_CODE_OK, execute(newCommandHandler(), "--snapshot", "delete", "testSnapshot")); | ||
|
|
||
| out = testOut.toString(); | ||
|
|
||
| if (changeBaseline) | ||
| assertTrue(out.contains(SnapshotDeleteCommand.MISSING_BASELINES + "[cnt=1]: " + baselineGone)); | ||
|
|
||
| if (separatedWorkDir) { | ||
| // When the nodes use own separated work directory, we expect a strict result. | ||
| assertTrue(out.contains(SnapshotDeleteCommand.REMOVED_PREF + "[cnt=%d]:".formatted(initNodes))); | ||
|
|
||
| if (extraNodeIsServer == 1) | ||
| assertTrue(out.contains(SnapshotDeleteCommand.NODE_NOT_FOUND_PREF + "[cnt=1]:")); | ||
| else if (extraNodeIsServer == 0) | ||
| assertFalse(out.contains(SnapshotDeleteCommand.NODE_NOT_FOUND_PREF)); | ||
| } | ||
| else { | ||
| // When nodes use a shared work directory, there is a race for the delete operation. One node can get faster | ||
| // than others and remove snapshot completely quickly. The others might not find snapshot files. We can be | ||
| // only sure that at least one node removes snapshot. | ||
| assertTrue(out.contains(SnapshotDeleteCommand.REMOVED_PREF) || out.contains(SnapshotDeleteCommand.UNSURED_DELETION_PREF)); | ||
| } | ||
|
|
||
| assertFalse(out.contains("Snapshot not found on current server nodes")); | ||
|
|
||
| assertTrue(waitForCondition(() -> !snpDir.exists(), getTestTimeout())); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.