diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/AbstractRollingUpgradeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/AbstractRollingUpgradeTest.java index 0bbdb9824a57d..3d7f76477c251 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/AbstractRollingUpgradeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/AbstractRollingUpgradeTest.java @@ -82,60 +82,36 @@ import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; /** - * Provides the ability to override a node's version and supported {@link IgniteFeature}s in order to - * simulate a Rolling Upgrade procedure. + * Overrides the version and the supported {@link IgniteFeature}s of a node to simulate a Rolling Upgrade. The versions below + * are fake and correspond to no real Ignite release. Features below the lowest one of a release are retired. + *
+ * Core    Features
+ * 2.18.0  0
+ * 2.19.0  0-1
+ * 2.19.1  0-1
+ * 2.19.2  0-2
+ * 2.19.3  0-2,6
+ * 2.20.0  2-5
+ * 2.20.1  2-6
+ * 2.21.0  6
+ * 2.21.1  6-7
  *
- * 

For testing purposes, the following "fake" Ignite versions and their corresponding - * {@link IgniteFeature}s have been introduced. These versions are used solely for testing and do not - * correspond to any actual Ignite releases. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
VersionFeatures
2.18.0not supported
2.19.0{@code IgniteFeatureSet [0]}
2.19.1{@code IgniteFeatureSet [0]}
2.19.2{@code IgniteFeatureSet [0 -> 2]}
2.19.3{@code IgniteFeatureSet [0 -> 2, 6]}
2.20.0{@code IgniteFeatureSet [0 -> 4]}
2.20.1{@code IgniteFeatureSet [0 -> 4, 6]}
2.21.0{@code IgniteFeatureSet [3 -> 6]}
2.21.1{@code IgniteFeatureSet [3 -> 7]}
+ * Plugin Features + * 0.9.0 none + * 1.0.0 0 + * 1.1.0 0-1 + * 2.0.0 1-3 + * 2.1.0 1-4 + * 3.0.0 4 + *

*/ public abstract class AbstractRollingUpgradeTest extends GridCommonAbstractTest { /** */ protected static final String TEST_DEFAULT_VER = "2.19.0"; + /** */ + protected static final String COMPONENT_VERSIONS_ATTRIBUTE = "test.component.versions"; + /** */ protected static final String VER_INCOMPATIBLE_ERR = "Joining node is not allowed to join the cluster because it is running a component with an incompatible version"; @@ -204,9 +180,12 @@ protected IgniteConfiguration getConfiguration(String igniteInstanceName, String IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); + cfg.setUserAttributes(F.asMap(COMPONENT_VERSIONS_ATTRIBUTE, ver)); TestVersions testVersions = TestVersions.parse(ver); + boolean pluginDeclaresFeatures = testVersions.containsPlugin() && pluginDeclaresFeatures(testVersions.pluginVersion()); + IgniteCoreFeatureSet testCoreFeatures = new IgniteCoreFeatureSet( IgniteProductVersion.fromString(testVersions.coreVersion()), IgniteFeatureSet.buildFrom(readDeclaredCoreFeatures(testVersions.coreVersion())) @@ -219,7 +198,7 @@ protected IgniteConfiguration getConfiguration(String igniteInstanceName, String /** {@inheritDoc} */ @Override public void initExtensions(PluginContext ctx, ExtensionRegistry registry) { - if (testVersions.containsPlugin()) { + if (pluginDeclaresFeatures) { registry.registerExtension( IgniteComponentFeatureSetProvider.class, new TestPluginComponentFeatureSetProvider(testVersions.pluginVersion())); @@ -269,6 +248,18 @@ public static Collection readDeclaredCoreFeatures(String ver) thr return IgniteFeatureSet.readDeclaredFeatures(cls); } + /** */ + private static boolean pluginDeclaresFeatures(String pluginVer) throws Exception { + try { + readDeclaredPluginFeatures(pluginVer); + + return true; + } + catch (ClassNotFoundException ignored) { + return false; + } + } + /** */ public static Collection readDeclaredPluginFeatures(String ver) throws Exception { Class cls = Class.forName( @@ -550,7 +541,7 @@ protected void finalizeClusterVersion(int nodeIdx, String expVer) throws Excepti /** */ protected void restartNode(int nodeIdx) throws Exception { - String ver = resolveNodeLocalCompoundVersion(nodeIdx); + String ver = nodeComponentVersions(grid(nodeIdx)); boolean isClient = grid(nodeIdx).context().clientNode(); stopGrid(nodeIdx); @@ -565,7 +556,7 @@ protected void forAllNodes(ConsumerX nodeProcessor) throws Exception { /** */ protected void checkUpgradeFailed(int nodeIdx, String targetVer, String errMsg) throws Exception { - String srcVer = resolveNodeLocalCompoundVersion(nodeIdx); + String srcVer = nodeComponentVersions(grid(nodeIdx)); boolean isClient = grid(nodeIdx).context().clientNode(); stopGrid(nodeIdx); @@ -576,8 +567,8 @@ protected void checkUpgradeFailed(int nodeIdx, String targetVer, String errMsg) } /** */ - protected String resolveNodeLocalCompoundVersion(int nodeIdx) { - return resolveCompoundVersion(ru(nodeIdx).features().localVersionFeatures()); + protected String nodeComponentVersions(Ignite node) { + return node.cluster().localNode().attribute(COMPONENT_VERSIONS_ATTRIBUTE); } /** */ @@ -642,7 +633,7 @@ protected static RollingUpgradeProcessor ru(Ignite ignite) { } /** */ - protected static class TestVersions { + public static class TestVersions { /** */ private final Map cmpVersions = new HashMap<>(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/CoreVersionRollingUpgradeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/CoreVersionRollingUpgradeTest.java index 8483d87647a3f..92d60c49df8ef 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/CoreVersionRollingUpgradeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/CoreVersionRollingUpgradeTest.java @@ -42,7 +42,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.events.EventType.EVT_CLIENT_NODE_RECONNECTED; import static org.apache.ignite.internal.TestRecordingCommunicationSpi.spi; -import static org.apache.ignite.internal.processors.rollingupgrade.feature.TestIgniteReleaseFeatures_2_19_2.VER_2_19_2_ID_1_FEATURE; +import static org.apache.ignite.internal.processors.rollingupgrade.feature.TestIgniteReleaseFeatures_2_19_2.VER_2_19_2_ID_2_FEATURE; import static org.apache.ignite.spi.discovery.tcp.TestBlockingTcpDiscoverySpi.blockingDiscovery; import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; @@ -211,7 +211,7 @@ public void testFeatureActivationListener() throws Exception { forAllNodes(nodeIdx -> { upgradeNodeVersion(nodeIdx, "2.19.2"); - checkFeatureActivationSubscription(nodeIdx, VER_2_19_2_ID_1_FEATURE, featureActivationLatch); + checkFeatureActivationSubscription(nodeIdx, VER_2_19_2_ID_2_FEATURE, featureActivationLatch); }); finalizeClusterVersion(1, "2.19.2"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_18_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_18_0.java index 7f19bd5e9ed91..a5258061a2e3c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_18_0.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_18_0.java @@ -20,5 +20,5 @@ /** */ public class TestIgniteReleaseFeatures_2_18_0 { /** */ - public static final IgniteFeature STUB_FEATURE = new IgniteCoreFeature(Integer.MAX_VALUE); + public static final IgniteFeature ROLLING_UPGRADE_FEATURE = new IgniteCoreFeature(0); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_19_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_19_0.java index 3cb497ee64701..45f45e81146e4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_19_0.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_19_0.java @@ -21,4 +21,7 @@ public class TestIgniteReleaseFeatures_2_19_0 { /** */ public static final IgniteFeature ROLLING_UPGRADE_FEATURE = new IgniteCoreFeature(0); + + /** */ + public static final IgniteFeature VER_2_19_0_ID_1_FEATURE = new IgniteCoreFeature(1); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_19_1.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_19_1.java index 38056daa0b428..e6efec6e3ad4b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_19_1.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_19_1.java @@ -20,5 +20,8 @@ /** */ public class TestIgniteReleaseFeatures_2_19_1 { /** */ - public static final IgniteFeature ROLLING_UPGRADE_FEATURE = TestIgniteReleaseFeatures_2_19_0.ROLLING_UPGRADE_FEATURE; + public static final IgniteFeature ROLLING_UPGRADE_FEATURE = new IgniteCoreFeature(0); + + /** */ + public static final IgniteFeature VER_2_19_0_ID_1_FEATURE = new IgniteCoreFeature(1); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_19_2.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_19_2.java index 0ad70357e73a9..5cddc7ba70ebe 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_19_2.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_19_2.java @@ -20,10 +20,10 @@ /** */ public class TestIgniteReleaseFeatures_2_19_2 { /** */ - public static final IgniteFeature ROLLING_UPGRADE_FEATURE = TestIgniteReleaseFeatures_2_19_1.ROLLING_UPGRADE_FEATURE; + public static final IgniteFeature ROLLING_UPGRADE_FEATURE = new IgniteCoreFeature(0); /** */ - public static final IgniteFeature VER_2_19_2_ID_1_FEATURE = new IgniteCoreFeature(1); + public static final IgniteFeature VER_2_19_0_ID_1_FEATURE = new IgniteCoreFeature(1); /** */ public static final IgniteFeature VER_2_19_2_ID_2_FEATURE = new IgniteCoreFeature(2); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_19_3.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_19_3.java index 7ede0b867f316..c0bca574ca3c8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_19_3.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_19_3.java @@ -20,14 +20,14 @@ /** */ public class TestIgniteReleaseFeatures_2_19_3 { /** */ - public static final IgniteFeature ROLLING_UPGRADE_FEATURE = TestIgniteReleaseFeatures_2_19_2.ROLLING_UPGRADE_FEATURE; + public static final IgniteFeature ROLLING_UPGRADE_FEATURE = new IgniteCoreFeature(0); /** */ - public static final IgniteFeature VER_2_19_2_ID_1_FEATURE = TestIgniteReleaseFeatures_2_19_2.VER_2_19_2_ID_1_FEATURE; + public static final IgniteFeature VER_2_19_0_ID_1_FEATURE = new IgniteCoreFeature(1); /** */ - public static final IgniteFeature VER_2_19_2_ID_2_FEATURE = TestIgniteReleaseFeatures_2_19_2.VER_2_19_2_ID_2_FEATURE; + public static final IgniteFeature VER_2_19_2_ID_2_FEATURE = new IgniteCoreFeature(2); - /** */ - public static final IgniteFeature VER_2_19_3_ID_6_FEATURE = TestIgniteReleaseFeatures_2_21_0.VER_2_21_0_ID_6_FEATURE; + /** Cherry-picked into 2.19.3 with the commit that introduced it in 2.20.1. */ + public static final IgniteFeature VER_2_19_3_ID_6_FEATURE = new IgniteCoreFeature(6); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_20_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_20_0.java index 94719dfd6aabb..cf9bf6375f784 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_20_0.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_20_0.java @@ -20,17 +20,14 @@ /** */ public class TestIgniteReleaseFeatures_2_20_0 { /** */ - public static final IgniteFeature ROLLING_UPGRADE_FEATURE = TestIgniteReleaseFeatures_2_19_2.ROLLING_UPGRADE_FEATURE; - - /** */ - public static final IgniteFeature VER_2_19_2_ID_1_FEATURE = TestIgniteReleaseFeatures_2_19_2.VER_2_19_2_ID_1_FEATURE; - - /** */ - public static final IgniteFeature VER_2_19_2_ID_2_FEATURE = TestIgniteReleaseFeatures_2_19_2.VER_2_19_2_ID_2_FEATURE; + public static final IgniteFeature VER_2_19_2_ID_2_FEATURE = new IgniteCoreFeature(2); /** */ public static final IgniteFeature VER_2_20_0_ID_3_FEATURE = new IgniteCoreFeature(3); /** */ public static final IgniteFeature VER_2_20_0_ID_4_FEATURE = new IgniteCoreFeature(4); + + /** */ + public static final IgniteFeature VER_2_20_0_ID_5_FEATURE = new IgniteCoreFeature(5); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_20_1.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_20_1.java index 4bb051bb631ab..d2f95bdecd862 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_20_1.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_20_1.java @@ -20,19 +20,16 @@ /** */ public class TestIgniteReleaseFeatures_2_20_1 { /** */ - public static final IgniteFeature ROLLING_UPGRADE_FEATURE = TestIgniteReleaseFeatures_2_20_0.ROLLING_UPGRADE_FEATURE; + public static final IgniteFeature VER_2_19_2_ID_2_FEATURE = new IgniteCoreFeature(2); /** */ - public static final IgniteFeature VER_2_19_2_ID_1_FEATURE = TestIgniteReleaseFeatures_2_20_0.VER_2_19_2_ID_1_FEATURE; + public static final IgniteFeature VER_2_20_0_ID_3_FEATURE = new IgniteCoreFeature(3); /** */ - public static final IgniteFeature VER_2_19_2_ID_2_FEATURE = TestIgniteReleaseFeatures_2_20_0.VER_2_19_2_ID_2_FEATURE; + public static final IgniteFeature VER_2_20_0_ID_4_FEATURE = new IgniteCoreFeature(4); /** */ - public static final IgniteFeature VER_2_20_0_ID_3_FEATURE = TestIgniteReleaseFeatures_2_20_0.VER_2_20_0_ID_3_FEATURE; - - /** */ - public static final IgniteFeature VER_2_20_0_ID_4_FEATURE = TestIgniteReleaseFeatures_2_20_0.VER_2_20_0_ID_4_FEATURE; + public static final IgniteFeature VER_2_20_0_ID_5_FEATURE = new IgniteCoreFeature(5); /** */ public static final IgniteFeature VER_2_20_1_ID_6_FEATURE = new IgniteCoreFeature(6); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_21_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_21_0.java index fe6b190119774..7790cb6e152ac 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_21_0.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_21_0.java @@ -19,15 +19,6 @@ /** */ public class TestIgniteReleaseFeatures_2_21_0 { - /** */ - public static final IgniteFeature VER_2_20_0_ID_3_FEATURE = TestIgniteReleaseFeatures_2_20_1.VER_2_20_0_ID_3_FEATURE; - - /** */ - public static final IgniteFeature VER_2_20_0_ID_4_FEATURE = TestIgniteReleaseFeatures_2_20_1.VER_2_20_0_ID_4_FEATURE; - - /** */ - public static final IgniteFeature VER_2_21_0_ID_5_FEATURE = new IgniteCoreFeature(5); - /** */ public static final IgniteFeature VER_2_21_0_ID_6_FEATURE = new IgniteCoreFeature(6); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_21_1.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_21_1.java index 6ec00046d1b51..99451aa0f9de8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_21_1.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestIgniteReleaseFeatures_2_21_1.java @@ -20,16 +20,7 @@ /** */ public class TestIgniteReleaseFeatures_2_21_1 { /** */ - public static final IgniteFeature VER_2_20_0_ID_3_FEATURE = TestIgniteReleaseFeatures_2_21_0.VER_2_20_0_ID_3_FEATURE; - - /** */ - public static final IgniteFeature VER_2_20_0_ID_4_FEATURE = TestIgniteReleaseFeatures_2_21_0.VER_2_20_0_ID_4_FEATURE; - - /** */ - public static final IgniteFeature VER_2_21_0_ID_5_FEATURE = TestIgniteReleaseFeatures_2_21_0.VER_2_21_0_ID_5_FEATURE; - - /** */ - public static final IgniteFeature VER_2_21_0_ID_6_FEATURE = TestIgniteReleaseFeatures_2_21_0.VER_2_21_0_ID_6_FEATURE; + public static final IgniteFeature VER_2_21_0_ID_6_FEATURE = new IgniteCoreFeature(6); /** */ public static final IgniteFeature VER_2_21_1_ID_7_FEATURE = new IgniteCoreFeature(7); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestPluginReleaseFeatures_1_1_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestPluginReleaseFeatures_1_1_0.java new file mode 100644 index 0000000000000..151c01605b5a8 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestPluginReleaseFeatures_1_1_0.java @@ -0,0 +1,27 @@ +/* + * 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.internal.processors.rollingupgrade.feature; + +/** */ +public class TestPluginReleaseFeatures_1_1_0 { + /** */ + public static final IgniteFeature VER_1_0_0_ID_0_FEATURE = new TestPluginFeature(0); + + /** */ + public static final IgniteFeature VER_1_1_0_ID_1_FEATURE = new TestPluginFeature(1); +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestPluginReleaseFeatures_2_0_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestPluginReleaseFeatures_2_0_0.java index 066d0403917df..536fa52790bad 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestPluginReleaseFeatures_2_0_0.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestPluginReleaseFeatures_2_0_0.java @@ -20,8 +20,11 @@ /** */ public class TestPluginReleaseFeatures_2_0_0 { /** */ - public static final IgniteFeature VER_1_0_0_ID_0_FEATURE = TestPluginReleaseFeatures_1_0_0.VER_1_0_0_ID_0_FEATURE; + public static final IgniteFeature VER_1_1_0_ID_1_FEATURE = new TestPluginFeature(1); /** */ - public static final IgniteFeature VER_2_0_0_ID_1_FEATURE = new TestPluginFeature(1); + public static final IgniteFeature VER_2_0_0_ID_2_FEATURE = new TestPluginFeature(2); + + /** */ + public static final IgniteFeature VER_2_0_0_ID_3_FEATURE = new TestPluginFeature(3); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestPluginReleaseFeatures_2_1_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestPluginReleaseFeatures_2_1_0.java index 385f7ded6a900..95459b6ab321e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestPluginReleaseFeatures_2_1_0.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestPluginReleaseFeatures_2_1_0.java @@ -20,11 +20,14 @@ /** */ public class TestPluginReleaseFeatures_2_1_0 { /** */ - public static final IgniteFeature VER_1_0_0_ID_0_FEATURE = TestPluginReleaseFeatures_2_0_0.VER_1_0_0_ID_0_FEATURE; + public static final IgniteFeature VER_1_1_0_ID_1_FEATURE = new TestPluginFeature(1); /** */ - public static final IgniteFeature VER_2_0_0_ID_1_FEATURE = TestPluginReleaseFeatures_2_0_0.VER_2_0_0_ID_1_FEATURE; + public static final IgniteFeature VER_2_0_0_ID_2_FEATURE = new TestPluginFeature(2); /** */ - public static final IgniteFeature VER_2_1_0_ID_2_FEATURE = new TestPluginFeature(2); + public static final IgniteFeature VER_2_0_0_ID_3_FEATURE = new TestPluginFeature(3); + + /** */ + public static final IgniteFeature VER_2_1_0_ID_4_FEATURE = new TestPluginFeature(4); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestPluginReleaseFeatures_3_0_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestPluginReleaseFeatures_3_0_0.java index d5c7b4f2e23b9..c9aabf6afb19a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestPluginReleaseFeatures_3_0_0.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/feature/TestPluginReleaseFeatures_3_0_0.java @@ -20,8 +20,5 @@ /** */ public class TestPluginReleaseFeatures_3_0_0 { /** */ - public static final IgniteFeature VER_3_0_0_ID_2_FEATURE = new TestPluginFeature(2); - - /** */ - public static final IgniteFeature VER_3_0_0_ID_3_FEATURE = new TestPluginFeature(3); + public static final IgniteFeature VER_2_1_0_ID_4_FEATURE = new TestPluginFeature(4); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/AbstractRollingUpgradeMessageTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/AbstractRollingUpgradeMessageTest.java new file mode 100644 index 0000000000000..ef6b76ba906e9 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/AbstractRollingUpgradeMessageTest.java @@ -0,0 +1,155 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicReference; +import org.apache.ignite.Ignite; +import org.apache.ignite.Ignition; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.managers.communication.GridMessageListener; +import org.apache.ignite.internal.processors.rollingupgrade.AbstractRollingUpgradeTest; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.plugin.extensions.communication.Message; +import org.apache.ignite.spi.MessagesPluginProvider; + +import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static org.apache.ignite.internal.managers.communication.GridIoPolicy.PUBLIC_POOL; +import static org.apache.ignite.internal.processors.rollingupgrade.message.TestMessageType.resolveTestMessageClasses; + +/** + * Test messages declare a class per release that changes them. Features below the lowest one of a release are retired. + * {@code +N} is a field introduced by feature N, {@code -N} is a field deprecated by feature N. + *
+ * Core    Features  TestCoreMessage
+ * 2.18.0  0         A B C
+ * 2.19.0  0-1       A B C D+1
+ * 2.19.2  0-2       A B C-2 D+1
+ * 2.19.3  0-2,6     A B C-2 D+1 F+6
+ * 2.20.0  2-5       A B-3 C-2 D-5 E+4
+ * 2.20.1  2-6       A B-3 C-2 D-5 E+4 F+6
+ * 2.21.0  6         A E F+6
+ *
+ * Plugin  Features  TestPluginMessage
+ * 0.9.0   none      A B C
+ * 1.0.0   0         A B C D+0
+ * 1.1.0   0-1       A B-1 C D+0
+ * 2.0.0   1-3       A B-1 C D-3 E+2
+ * 2.1.0   1-4       A B-1 C D-3 E+2 F+4
+ * 3.0.0   4         A C E F+4
+ * 
+ * 2.19.3 carries feature 6 cherry-picked from 2.20.1, so it can upgrade to 2.20.1 but not to 2.20.0. + * Core D and plugin D live through the whole cycle: introduced, deprecated once the introducing feature is retired, deleted once + * the deprecating feature is retired. + */ +public abstract class AbstractRollingUpgradeMessageTest extends AbstractRollingUpgradeTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName, String cmpVers) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName, cmpVers); + + cfg.setPluginProviders(F.concat(cfg.getPluginProviders(), new MessagesPluginProvider(resolveTestMessageClasses(cmpVers)))); + + return cfg; + } + + /** */ + protected void startServerNodes(String... vers) throws Exception { + IgniteEx first = startGrid(0, vers[0]); + + if (Arrays.stream(vers).distinct().count() > 1) + ru(first).enableVersionUpgrade(); + + for (int idx = 1; idx < vers.length; idx++) + startGrid(idx, vers[idx]); + } + + /** */ + protected T send(IgniteEx from, IgniteEx to, T msg) throws Exception { + AtomicReference got = new AtomicReference<>(); + CountDownLatch latch = new CountDownLatch(1); + + String topic = msg.getClass().getName(); + + GridMessageListener lsnr = (nodeId, rcvd, plc) -> { + got.set((T)rcvd); + + latch.countDown(); + }; + + to.context().io().addMessageListener(topic, lsnr); + + try { + ClusterNode rcvNode = from.context().discovery().node(to.localNode().id()); + + from.context().io().sendToCustomTopic(rcvNode, topic, msg, PUBLIC_POOL); + + assertTrue(latch.await(getTestTimeout(), MILLISECONDS)); + + return got.get(); + } + finally { + to.context().io().removeMessageListener(topic, lsnr); + } + } + + /** */ + protected TestMessage send(IgniteEx from, IgniteEx to, TestMessageType msgType) throws Exception { + return send(from, to, buildMessage(from, msgType)); + } + + /** */ + protected Map sendOverDiscovery(IgniteEx from, TestDiscoveryMessage msg) throws Exception { + List clusterNodes = Ignition.allGrids(); + + Map receivedMsgs = new ConcurrentHashMap<>(); + + CountDownLatch latch = new CountDownLatch(clusterNodes.size()); + + for (Ignite rcv : clusterNodes) { + ((IgniteEx)rcv).context().discovery().setCustomEventListener(TestDiscoveryMessage.class, (v, n, m) -> { + receivedMsgs.put(rcv.name(), m); + + latch.countDown(); + }); + } + + from.context().discovery().sendCustomEvent(msg); + + assertTrue(latch.await(getTestTimeout(), MILLISECONDS)); + + receivedMsgs.remove(from.name()); + + return receivedMsgs; + } + + /** */ + protected Map sendOverDiscovery(IgniteEx from, TestMessageType msgType) throws Exception { + return sendOverDiscovery(from, buildMessage(from, msgType)); + } + + /** */ + protected TestDiscoveryMessage buildMessage(IgniteEx node, TestMessageType msgType) throws Exception { + return msgType.build(nodeComponentVersions(node), ru(node).features()::isActive); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/RollingUpgradeMessageSerializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/RollingUpgradeMessageSerializationTest.java index 8ba97aa82c1c7..a895b73a01ed6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/RollingUpgradeMessageSerializationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/RollingUpgradeMessageSerializationTest.java @@ -20,21 +20,11 @@ import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Supplier; +import java.util.UUID; import org.apache.ignite.Ignite; import org.apache.ignite.Ignition; -import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.managers.communication.GridIoPolicy; -import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; -import org.apache.ignite.internal.processors.rollingupgrade.AbstractRollingUpgradeTest; -import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.spi.MessagesPluginProvider; +import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode; import org.junit.Test; import static org.apache.ignite.internal.processors.rollingupgrade.message.TestMessage.A; @@ -43,58 +33,81 @@ import static org.apache.ignite.internal.processors.rollingupgrade.message.TestMessage.D; import static org.apache.ignite.internal.processors.rollingupgrade.message.TestMessage.E; import static org.apache.ignite.internal.processors.rollingupgrade.message.TestMessage.F; +import static org.apache.ignite.internal.processors.rollingupgrade.message.TestMessageType.CONTAINER_MSG; +import static org.apache.ignite.internal.processors.rollingupgrade.message.TestMessageType.CORE_MSG; +import static org.apache.ignite.internal.processors.rollingupgrade.message.TestMessageType.DEFAULT_REGISTRY_MSG; +import static org.apache.ignite.internal.processors.rollingupgrade.message.TestMessageType.PLUGIN_MSG; +import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; /** */ -public class RollingUpgradeMessageSerializationTest extends AbstractRollingUpgradeTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName, String ver) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName, ver); - - cfg.setPluginProviders(org.apache.ignite.internal.util.typedef.F.concat( - cfg.getPluginProviders(), - new MessagesPluginProvider( - TestCoreMessage.class, - TestPluginMessage.class, - TestDefaultRegistryMessage.class)) - ); - - return cfg; +public class RollingUpgradeMessageSerializationTest extends AbstractRollingUpgradeMessageTest { + /** */ + @Test + public void testSameOldVersion() throws Exception { + checkMutualCoreMessageSend("2.19.0", "2.19.0", A, B, C, D, null, null); } /** */ @Test - public void testSameOldVersion() throws Exception { - checkMutualCoreMessageSend("2.19.0", "2.19.0", A, B, C, null, null, null); + public void testIntroducedField() throws Exception { + checkMutualCoreMessageSend("2.18.0", "2.19.0", A, B, C, null, null, null); } /** */ @Test public void testMixedPair() throws Exception { - checkMutualCoreMessageSend("2.19.0", "2.20.0", A, B, C, null, null, null); + checkMutualCoreMessageSend("2.19.0", "2.20.0", A, B, C, D, null, null); } /** */ @Test public void testSameNewVersion() throws Exception { - checkMutualCoreMessageSend("2.20.0", "2.20.0", A, B, C, D, E, null); + checkMutualCoreMessageSend("2.20.0", "2.20.0", A, null, null, null, E, null); + } + + /** */ + @Test + public void testDeprecatedFieldEmptyAfterFinalization() throws Exception { + checkMutualCoreMessageSend("2.19.2", "2.19.2", A, B, null, D, null, null); + } + + /** */ + @Test + public void testDeprecationUnknownToOlderPeer() throws Exception { + checkMutualCoreMessageSend("2.19.2", "2.20.0", A, B, null, D, null, null); + } + + /** */ + @Test + public void testDeprecationKnownToOlderPeer() throws Exception { + checkMutualCoreMessageSend("2.20.0", "2.20.1", A, null, null, null, E, null); + } + + /** */ + @Test + public void testDeprecatedFieldDropped() throws Exception { + checkMutualCoreMessageSend("2.20.0", "2.21.0", A, null, null, null, E, null); } /** */ @Test - public void testWindowOpenSameVersion() throws Exception { - checkMutualCoreMessageSend("2.19.2", "2.19.2", A, B, C, D, null, null); + public void testDeprecatedFieldDroppedNewFieldShared() throws Exception { + checkMutualCoreMessageSend("2.20.1", "2.21.0", A, null, null, null, E, F); } /** */ @Test - public void testWindowOpenMixedPair() throws Exception { - checkMutualCoreMessageSend("2.19.2", "2.20.0", A, B, C, D, null, null); + public void testBackportedFeature() throws Exception { + checkMutualCoreMessageSend("2.19.3", "2.20.1", A, B, null, D, null, F); } /** */ @Test - public void testWindowClosed() throws Exception { - checkMutualCoreMessageSend("2.20.0", "2.20.1", A, null, C, null, E, null); + public void testNestedMessages() throws Exception { + startServerNodes("2.20.0", "2.21.0"); + + checkNestedMessages(grid(0), grid(1), A, null, null, null, E, null); + checkNestedMessages(grid(1), grid(0), A, null, null, null, E, null); } /** */ @@ -106,7 +119,7 @@ public void testDiscoveryNewerClient() throws Exception { startClientGrid(1, "2.20.0"); - checkCoreMessageBroadcast(srv, A, B, C, null, null, null); + checkCoreMessageBroadcast(srv, A, B, C, D, null, null); } /** */ @@ -120,7 +133,7 @@ public void testDiscoveryClientOriginated() throws Exception { startClientGrid(2, "2.19.0"); - checkCoreMessageBroadcast(cli1, A, B, C, null, null, null); + checkCoreMessageBroadcast(cli1, A, B, C, D, null, null); } /** */ @@ -134,13 +147,38 @@ public void testDiscoveryClientsOnDifferentVersions() throws Exception { upgradeNodeVersion(0, "2.20.0"); upgradeNodeVersion(1, "2.20.0"); + stopGrid(0); + IgniteEx newVerCli = startClientGrid(2, "2.20.0"); IgniteEx oldVerCli = startClientGrid(3, "2.19.0"); - Map receivedMsgs = sendOverDiscovery(grid(1), TestCoreMessage.build()); + Map receivedMsgs = sendOverDiscovery(grid(1), CORE_MSG); assertFields(A, B, C, D, E, null, receivedMsgs.get(newVerCli.name())); - assertFields(A, B, C, null, null, null, receivedMsgs.get(oldVerCli.name())); + assertFields(A, B, C, D, null, null, receivedMsgs.get(oldVerCli.name())); + + checkMutualCoreMessageSend(newVerCli, oldVerCli, A, B, C, D, null, null); + } + + /** */ + @Test + public void testDiscoveryClientRouterChange() throws Exception { + IgniteEx oldVerSrv = startGrid(0, "2.19.0"); + + ru(oldVerSrv).enableVersionUpgrade(); + + IgniteEx cli = startClientGrid(1, "2.20.0"); + IgniteEx newVerSrv = startGrid(2, "2.20.0"); + + assertEquals(oldVerSrv.localNode().id(), routerId(cli)); + + assertFields(A, B, C, D, null, null, sendOverDiscovery(newVerSrv, CORE_MSG).get(cli.name())); + + stopGrid(0); + + assertTrue(waitForCondition(() -> newVerSrv.localNode().id().equals(routerId(cli)), getTestTimeout())); + + assertFields(A, B, C, D, E, null, sendOverDiscovery(newVerSrv, CORE_MSG).get(cli.name())); } /** */ @@ -152,7 +190,7 @@ public void testCommunicationWithClient() throws Exception { IgniteEx client = startClientGrid(1, "2.20.0"); - checkMutualCoreMessageSend(srv, client, A, B, C, null, null, null); + checkMutualCoreMessageSend(srv, client, A, B, C, D, null, null); } /** */ @@ -160,7 +198,7 @@ public void testCommunicationWithClient() throws Exception { public void testDefaultRegistryMixedPair() throws Exception { startServerNodes("2.19.0", "2.20.0"); - checkMutualMessageSend(grid(0), grid(1), TestDefaultRegistryMessage::build, A, null, C, D, E, F); + checkMutualMessageSend(grid(0), grid(1), DEFAULT_REGISTRY_MSG, A, null, C, D, E, F); } /** */ @@ -170,7 +208,7 @@ public void testDiscoveryUniformRing() throws Exception { startGrid(1, "2.20.0"); startGrid(2, "2.20.0"); - checkCoreMessageBroadcast(grid(1), A, B, C, D, E, null); + checkCoreMessageBroadcast(grid(1), A, null, null, null, E, null); } /** */ @@ -183,16 +221,36 @@ public void testDiscoveryMixedRing() throws Exception { startGrid(1, "2.20.0"); startGrid(2, "2.20.0"); - checkCoreMessageBroadcast(grid(1), A, B, C, null, null, null); + checkCoreMessageBroadcast(grid(1), A, B, C, D, null, null); + } + + /** */ + @Test + public void testDiscoveryRingSendFromNewerNode() throws Exception { + startGrid(0, "2.19.0"); + + ru(0).enableVersionUpgrade(); + + IgniteEx newVerCrd = startGrid(1, "2.20.0"); + IgniteEx oldVerSrv = startGrid(2, "2.19.0"); + + stopGrid(0); + + IgniteEx newVerSrv = startGrid(3, "2.20.0"); + + Map receivedMsgs = sendOverDiscovery(newVerSrv, CORE_MSG); + + assertFields(A, B, C, D, E, null, receivedMsgs.get(newVerCrd.name())); + assertFields(A, B, C, D, null, null, receivedMsgs.get(oldVerSrv.name())); } /** */ @Test - public void testCommunicationUpgradeOpensWindow() throws Exception { + public void testDeprecatedFieldKeptUntilFinalization() throws Exception { startGrid(0, "2.19.0"); startGrid(1, "2.19.0"); - checkMutualCoreMessageSend(grid(0), grid(1), A, B, C, null, null, null); + checkMutualCoreMessageSend(grid(0), grid(1), A, B, C, D, null, null); ru(1).enableVersionUpgrade(); @@ -208,17 +266,17 @@ public void testCommunicationUpgradeAgreesNewFeature() throws Exception { startGrid(0, "2.19.2"); startGrid(1, "2.19.2"); - checkMutualCoreMessageSend(grid(0), grid(1), A, B, C, D, null, null); + checkMutualCoreMessageSend(grid(0), grid(1), A, B, null, D, null, null); ru(1).enableVersionUpgrade(); upgradeNodeVersion(0, "2.19.2", "2.20.0"); - checkMutualCoreMessageSend(grid(0), grid(1), A, B, C, D, null, null); + checkMutualCoreMessageSend(grid(0), grid(1), A, B, null, D, null, null); upgradeNodeVersion(1, "2.19.2", "2.20.0"); - checkMutualCoreMessageSend(grid(0), grid(1), A, B, C, D, E, null); + checkMutualCoreMessageSend(grid(0), grid(1), A, B, null, D, E, null); } /** */ @@ -226,9 +284,9 @@ public void testCommunicationUpgradeAgreesNewFeature() throws Exception { public void testPluginDiffersCoreMatches() throws Exception { startServerNodes("2.20.0 | 1.0.0", "2.20.0 | 2.0.0"); - checkMutualCoreMessageSend(grid(0), grid(1), A, B, C, D, E, null); + checkMutualCoreMessageSend(grid(0), grid(1), A, null, null, null, E, null); - checkMutualMessageSend(grid(0), grid(1), TestPluginMessage::build, A, B, C, D, null, null); + checkMutualMessageSend(grid(0), grid(1), PLUGIN_MSG, A, B, C, D, null, null); } /** */ @@ -236,97 +294,148 @@ public void testPluginDiffersCoreMatches() throws Exception { public void testPluginSameVersion() throws Exception { startServerNodes("2.20.0 | 2.0.0", "2.20.0 | 2.0.0"); - checkMutualCoreMessageSend(grid(0), grid(1), A, B, C, D, E, null); + checkMutualCoreMessageSend(grid(0), grid(1), A, null, null, null, E, null); + + checkMutualMessageSend(grid(0), grid(1), PLUGIN_MSG, A, null, C, null, E, null); + } + + /** */ + @Test + public void testPluginDeprecatedFieldDropped() throws Exception { + startServerNodes("2.20.0 | 2.0.0", "2.20.0 | 3.0.0"); - checkMutualMessageSend(grid(0), grid(1), TestPluginMessage::build, A, B, C, D, E, null); + checkMutualMessageSend(grid(0), grid(1), PLUGIN_MSG, A, null, C, null, E, null); } /** */ @Test - public void testPluginMissingOnClient() throws Exception { - IgniteEx srv = startGrid(0, "2.20.0 | 2.0.0"); + public void testCoreAndPluginDiffer() throws Exception { + startServerNodes("2.19.2 | 1.0.0", "2.20.0 | 2.0.0"); + + checkMutualCoreMessageSend(grid(0), grid(1), A, B, null, D, null, null); + + checkMutualMessageSend(grid(0), grid(1), PLUGIN_MSG, A, B, C, D, null, null); + } + + /** */ + @Test + public void testPluginWithoutFeaturesOnClient() throws Exception { + IgniteEx srv = startGrid(0, "2.20.0 | 1.1.0"); ru(srv).enableVersionUpgrade(); - IgniteEx cli = startClientGrid(1, "2.20.0"); + IgniteEx cli = startClientGrid(1, "2.20.0 | 0.9.0"); - checkMutualMessageSend(srv, cli, TestPluginMessage::build, A, B, C, null, null, null); + checkReceivedMessageFields(srv, cli, PLUGIN_MSG, A, null, C, null, null, null); + checkReceivedMessageFields(cli, srv, PLUGIN_MSG, A, B, C, null, null, null); - checkMutualCoreMessageSend(srv, cli, A, B, C, D, E, null); + checkMutualCoreMessageSend(srv, cli, A, null, null, null, E, null); } /** */ @Test public void testWholeUpgradeProcess() throws Exception { - startGrid(0, "2.19.0"); - startGrid(1, "2.19.0"); - startClientGrid(2, "2.19.0"); + startGrid(0, "2.18.0"); + startGrid(1, "2.18.0"); + startClientGrid(2, "2.18.0"); checkMessagesTransmissionBetweenAllNodes(A, B, C, null, null, null); ru(1).enableVersionUpgrade(); - checkMessagesTransmissionBetweenAllNodes(A, B, C, null, null, null); - - upgradeNodeVersion(0, "2.19.0", "2.19.2"); + upgradeNodeVersion(0, "2.18.0", "2.19.0"); checkMessagesTransmissionBetweenAllNodes(A, B, C, null, null, null); - upgradeNodeVersion(1, "2.19.0", "2.19.2"); + upgradeNodeVersion(1, "2.18.0", "2.19.0"); checkMutualCoreMessageSend(grid(0), grid(1), A, B, C, D, null, null); checkMutualCoreMessageSend(grid(0), grid(2), A, B, C, null, null, null); checkMutualCoreMessageSend(grid(1), grid(2), A, B, C, null, null, null); + upgradeNodeVersion(2, "2.18.0", "2.19.0"); + + checkMessagesTransmissionBetweenAllNodes(A, B, C, D, null, null); + + finalizeClusterVersion(0, "2.19.0"); + + checkMessagesTransmissionBetweenAllNodes(A, B, C, D, null, null); + + ru(1).enableVersionUpgrade(); + + upgradeNodeVersion(0, "2.19.0", "2.19.2"); + + checkMessagesTransmissionBetweenAllNodes(A, B, C, D, null, null); + + upgradeNodeVersion(1, "2.19.0", "2.19.2"); + + checkMessagesTransmissionBetweenAllNodes(A, B, C, D, null, null); + upgradeNodeVersion(2, "2.19.0", "2.19.2"); checkMessagesTransmissionBetweenAllNodes(A, B, C, D, null, null); finalizeClusterVersion(0, "2.19.2"); - checkMessagesTransmissionBetweenAllNodes(A, B, C, D, null, null); + checkMessagesTransmissionBetweenAllNodes(A, B, null, D, null, null); ru(1).enableVersionUpgrade(); upgradeNodeVersion(0, "2.19.2", "2.20.0"); - checkMessagesTransmissionBetweenAllNodes(A, B, C, D, null, null); + checkMessagesTransmissionBetweenAllNodes(A, B, null, D, null, null); upgradeNodeVersion(1, "2.19.2", "2.20.0"); - checkMutualCoreMessageSend(grid(0), grid(1), A, B, C, D, E, null); - checkMutualCoreMessageSend(grid(0), grid(2), A, B, C, D, null, null); - checkMutualCoreMessageSend(grid(1), grid(2), A, B, C, D, null, null); + checkMutualCoreMessageSend(grid(0), grid(1), A, B, null, D, E, null); + checkMutualCoreMessageSend(grid(0), grid(2), A, B, null, D, null, null); + checkMutualCoreMessageSend(grid(1), grid(2), A, B, null, D, null, null); upgradeNodeVersion(2, "2.19.2", "2.20.0"); - checkMessagesTransmissionBetweenAllNodes(A, B, C, D, E, null); + checkMessagesTransmissionBetweenAllNodes(A, B, null, D, E, null); finalizeClusterVersion(0, "2.20.0"); - checkMessagesTransmissionBetweenAllNodes(A, B, C, D, E, null); + checkMessagesTransmissionBetweenAllNodes(A, null, null, null, E, null); ru(1).enableVersionUpgrade(); upgradeNodeVersion(0, "2.20.0", "2.20.1"); - checkMutualCoreMessageSend(grid(0), grid(1), A, null, C, null, E, null); - checkMutualCoreMessageSend(grid(0), grid(2), A, null, C, null, E, null); - checkMutualCoreMessageSend(grid(1), grid(2), A, B, C, D, E, null); + checkMessagesTransmissionBetweenAllNodes(A, null, null, null, E, null); upgradeNodeVersion(1, "2.20.0", "2.20.1"); - checkMutualCoreMessageSend(grid(0), grid(1), A, B, C, D, E, F); - checkMutualCoreMessageSend(grid(0), grid(2), A, null, C, null, E, null); - checkMutualCoreMessageSend(grid(1), grid(2), A, null, C, null, E, null); + checkMutualCoreMessageSend(grid(0), grid(1), A, null, null, null, E, F); + checkMutualCoreMessageSend(grid(0), grid(2), A, null, null, null, E, null); + checkMutualCoreMessageSend(grid(1), grid(2), A, null, null, null, E, null); upgradeNodeVersion(2, "2.20.0", "2.20.1"); - checkMessagesTransmissionBetweenAllNodes(A, B, C, D, E, F); + checkMessagesTransmissionBetweenAllNodes(A, null, null, null, E, F); finalizeClusterVersion(0, "2.20.1"); - checkMessagesTransmissionBetweenAllNodes(A, B, C, D, E, F); + checkMessagesTransmissionBetweenAllNodes(A, null, null, null, E, F); + + ru(1).enableVersionUpgrade(); + + upgradeNodeVersion(0, "2.20.1", "2.21.0"); + + checkMessagesTransmissionBetweenAllNodes(A, null, null, null, E, F); + + upgradeNodeVersion(1, "2.20.1", "2.21.0"); + + checkMessagesTransmissionBetweenAllNodes(A, null, null, null, E, F); + + upgradeNodeVersion(2, "2.20.1", "2.21.0"); + + checkMessagesTransmissionBetweenAllNodes(A, null, null, null, E, F); + + finalizeClusterVersion(0, "2.21.0"); + + checkMessagesTransmissionBetweenAllNodes(A, null, null, null, E, F); } /** */ @@ -375,7 +484,7 @@ private void checkMutualCoreMessageSend( String expE, String expF ) throws Exception { - checkMutualMessageSend(first, second, TestCoreMessage::build, expA, expB, expC, expD, expE, expF); + checkMutualMessageSend(first, second, CORE_MSG, expA, expB, expC, expD, expE, expF); } /** */ @@ -388,17 +497,17 @@ private void checkCoreMessageBroadcast( String expE, String expF ) throws Exception { - Collection receivedMsgs = sendOverDiscovery(from, TestCoreMessage.build()).values(); + Collection receivedMsgs = sendOverDiscovery(from, CORE_MSG).values(); - for (TestCoreMessage msg : receivedMsgs) - assertFields(expA, expB, expC, expD, expE, expF, msg); + for (TestDiscoveryMessage rcvd : receivedMsgs) + assertFields(expA, expB, expC, expD, expE, expF, rcvd); } /** */ - private void checkMutualMessageSend( + private void checkMutualMessageSend( IgniteEx first, IgniteEx second, - Supplier msgFactory, + TestMessageType msgType, String expA, String expB, String expC, @@ -406,15 +515,15 @@ private void checkMutualMessage String expE, String expF ) throws Exception { - checkReceivedMessageFields(first, second, msgFactory, expA, expB, expC, expD, expE, expF); - checkReceivedMessageFields(second, first, msgFactory, expA, expB, expC, expD, expE, expF); + checkReceivedMessageFields(first, second, msgType, expA, expB, expC, expD, expE, expF); + checkReceivedMessageFields(second, first, msgType, expA, expB, expC, expD, expE, expF); } /** */ - private void checkReceivedMessageFields( + private void checkReceivedMessageFields( IgniteEx from, IgniteEx to, - Supplier msgFactory, + TestMessageType msgType, String expA, String expB, String expC, @@ -422,72 +531,40 @@ private void checkReceivedMessa String expE, String expF ) throws Exception { - assertFields(expA, expB, expC, expD, expE, expF, send(from, to, msgFactory.get())); - - assertFields(expA, expB, expC, expD, expE, expF, sendOverDiscovery(from, msgFactory.get()).get(to.name())); - } - - /** */ - private T send(IgniteEx from, IgniteEx to, T msg) throws Exception { - AtomicReference got = new AtomicReference<>(); - CountDownLatch latch = new CountDownLatch(1); + assertFields(expA, expB, expC, expD, expE, expF, send(from, to, msgType)); - String topic = msg.getClass().getName(); - - to.context().io().addMessageListener(topic, (nodeId, rcvd, plc) -> { - got.set((T)rcvd); - - latch.countDown(); - }); - - ClusterNode rcvNode = from.context().discovery().node(to.localNode().id()); - - from.context().io().sendToCustomTopic(rcvNode, topic, msg, GridIoPolicy.PUBLIC_POOL); - - assertTrue(latch.await(getTestTimeout(), TimeUnit.MILLISECONDS)); - - return got.get(); + assertFields(expA, expB, expC, expD, expE, expF, sendOverDiscovery(from, msgType).get(to.name())); } /** */ - private Map sendOverDiscovery( + private void checkNestedMessages( IgniteEx from, - T msg + IgniteEx to, + String expA, + String expB, + String expC, + String expD, + String expE, + String expF ) throws Exception { - List clusterNodes = Ignition.allGrids(); - - Map receivedMsgs = new ConcurrentHashMap<>(); - - CountDownLatch latch = new CountDownLatch(clusterNodes.size()); + List receivedMsgs = List.of( + send(from, to, CONTAINER_MSG), + sendOverDiscovery(from, CONTAINER_MSG).get(to.name()) + ); - for (Ignite rcv : clusterNodes) { - String name = rcv.name(); + for (TestMessage rcvd : receivedMsgs) { + List nestedMsgs = rcvd.nestedMessages(); - ((IgniteEx)rcv).context().discovery().setCustomEventListener((Class)msg.getClass(), - (v, n, m) -> { - receivedMsgs.put(name, m); + assertEquals(6, nestedMsgs.size()); - latch.countDown(); - }); + for (TestMessage nestedMsg : nestedMsgs) + assertFields(expA, expB, expC, expD, expE, expF, nestedMsg); } - - from.context().discovery().sendCustomEvent(msg); - - assertTrue(latch.await(getTestTimeout(), TimeUnit.MILLISECONDS)); - - receivedMsgs.remove(from.name()); - - return receivedMsgs; } /** */ - private void startServerNodes(String firstVer, String secondVer) throws Exception { - IgniteEx first = startGrid(0, firstVer); - - if (!firstVer.equals(secondVer)) - ru(first).enableVersionUpgrade(); - - startGrid(1, secondVer); + private static UUID routerId(IgniteEx cli) { + return ((TcpDiscoveryNode)cli.localNode()).clientRouterNodeId(); } /** */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestContainerMessage_2_20_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestContainerMessage_2_20_0.java new file mode 100644 index 0000000000000..dc73b0d4847de --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestContainerMessage_2_20_0.java @@ -0,0 +1,89 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; +import org.apache.ignite.internal.Compress; +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; + +/** */ +public class TestContainerMessage_2_20_0 extends TestDiscoveryMessage { + /** */ + @Order(0) + TestCoreMessage_2_20_0 msg; + + /** */ + @Order(1) + List list; + + /** */ + @Order(2) + Map map; + + /** */ + @Order(3) + TestCoreMessage_2_20_0[] arr; + + /** */ + @Compress + @Order(4) + TestCoreMessage_2_20_0 compressedMsg; + + /** */ + @Compress + @Order(5) + Map compressedMap; + + /** {@inheritDoc} */ + @Override public void fill(Predicate featureStatusProvider) { + msg = nestedMessage(featureStatusProvider); + list = List.of(nestedMessage(featureStatusProvider)); + map = Map.of(0, nestedMessage(featureStatusProvider)); + arr = new TestCoreMessage_2_20_0[] {nestedMessage(featureStatusProvider)}; + compressedMsg = nestedMessage(featureStatusProvider); + compressedMap = Map.of(0, nestedMessage(featureStatusProvider)); + } + + /** {@inheritDoc} */ + @Override public List nestedMessages() { + List res = new ArrayList<>(); + + res.add(msg); + res.addAll(list); + res.addAll(map.values()); + res.addAll(List.of(arr)); + res.add(compressedMsg); + res.addAll(compressedMap.values()); + + return res; + } + + /** */ + private static TestCoreMessage_2_20_0 nestedMessage(Predicate featureStatusProvider) { + TestCoreMessage_2_20_0 msg = new TestCoreMessage_2_20_0(); + + msg.fill(featureStatusProvider); + + return msg; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestContainerMessage_2_21_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestContainerMessage_2_21_0.java new file mode 100644 index 0000000000000..7749d2b4c63f4 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestContainerMessage_2_21_0.java @@ -0,0 +1,89 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; +import org.apache.ignite.internal.Compress; +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; + +/** */ +public class TestContainerMessage_2_21_0 extends TestDiscoveryMessage { + /** */ + @Order(0) + TestCoreMessage_2_21_0 msg; + + /** */ + @Order(1) + List list; + + /** */ + @Order(2) + Map map; + + /** */ + @Order(3) + TestCoreMessage_2_21_0[] arr; + + /** */ + @Compress + @Order(4) + TestCoreMessage_2_21_0 compressedMsg; + + /** */ + @Compress + @Order(5) + Map compressedMap; + + /** {@inheritDoc} */ + @Override public void fill(Predicate featureStatusProvider) { + msg = nestedMessage(featureStatusProvider); + list = List.of(nestedMessage(featureStatusProvider)); + map = Map.of(0, nestedMessage(featureStatusProvider)); + arr = new TestCoreMessage_2_21_0[] {nestedMessage(featureStatusProvider)}; + compressedMsg = nestedMessage(featureStatusProvider); + compressedMap = Map.of(0, nestedMessage(featureStatusProvider)); + } + + /** {@inheritDoc} */ + @Override public List nestedMessages() { + List res = new ArrayList<>(); + + res.add(msg); + res.addAll(list); + res.addAll(map.values()); + res.addAll(List.of(arr)); + res.add(compressedMsg); + res.addAll(compressedMap.values()); + + return res; + } + + /** */ + private static TestCoreMessage_2_21_0 nestedMessage(Predicate featureStatusProvider) { + TestCoreMessage_2_21_0 msg = new TestCoreMessage_2_21_0(); + + msg.fill(featureStatusProvider); + + return msg; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_18_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_18_0.java new file mode 100644 index 0000000000000..1b67c3c1ba642 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_18_0.java @@ -0,0 +1,59 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import java.util.function.Predicate; +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; + +/** */ +public class TestCoreMessage_2_18_0 extends TestDiscoveryMessage { + /** */ + @Order(0) + String fldA; + + /** */ + @Order(1) + String fldB; + + /** */ + @Order(2) + String fldC; + + /** {@inheritDoc} */ + @Override public void fill(Predicate featureStatusProvider) { + fldA = A; + fldB = B; + fldC = C; + } + + /** {@inheritDoc} */ + @Override public String fldA() { + return fldA; + } + + /** {@inheritDoc} */ + @Override public String fldB() { + return fldB; + } + + /** {@inheritDoc} */ + @Override public String fldC() { + return fldC; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_19_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_19_0.java new file mode 100644 index 0000000000000..fa2676662d0d2 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_19_0.java @@ -0,0 +1,72 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import java.util.function.Predicate; +import org.apache.ignite.internal.FeatureGated; +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; +import org.apache.ignite.internal.processors.rollingupgrade.feature.TestIgniteReleaseFeatures_2_19_0; + +/** */ +@FeatureGated(registry = TestIgniteReleaseFeatures_2_19_0.class) +public class TestCoreMessage_2_19_0 extends TestDiscoveryMessage { + /** */ + @Order(0) + String fldA; + + /** */ + @Order(1) + String fldB; + + /** */ + @Order(2) + String fldC; + + /** */ + @Order(value = 3, introducedBy = "VER_2_19_0_ID_1_FEATURE") + String fldD; + + /** {@inheritDoc} */ + @Override public void fill(Predicate featureStatusProvider) { + fldA = A; + fldB = B; + fldC = C; + fldD = D; + } + + /** {@inheritDoc} */ + @Override public String fldA() { + return fldA; + } + + /** {@inheritDoc} */ + @Override public String fldB() { + return fldB; + } + + /** {@inheritDoc} */ + @Override public String fldC() { + return fldC; + } + + /** {@inheritDoc} */ + @Override public String fldD() { + return fldD; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_19_2.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_19_2.java new file mode 100644 index 0000000000000..e3e8c6398e36d --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_19_2.java @@ -0,0 +1,77 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import java.util.function.Predicate; +import org.apache.ignite.internal.FeatureGated; +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; +import org.apache.ignite.internal.processors.rollingupgrade.feature.TestIgniteReleaseFeatures_2_19_2; + +import static org.apache.ignite.internal.processors.rollingupgrade.feature.TestIgniteReleaseFeatures_2_19_2.VER_2_19_2_ID_2_FEATURE; + +/** */ +@FeatureGated(registry = TestIgniteReleaseFeatures_2_19_2.class) +public class TestCoreMessage_2_19_2 extends TestDiscoveryMessage { + /** */ + @Order(0) + String fldA; + + /** */ + @Order(1) + String fldB; + + /** */ + @Order(value = 2, deprecatedBy = "VER_2_19_2_ID_2_FEATURE") + String fldC; + + /** */ + @Order(value = 3, introducedBy = "VER_2_19_0_ID_1_FEATURE") + String fldD; + + /** {@inheritDoc} */ + @Override public void fill(Predicate featureStatusProvider) { + fldA = A; + fldB = B; + + if (!featureStatusProvider.test(VER_2_19_2_ID_2_FEATURE)) + fldC = C; + + fldD = D; + } + + /** {@inheritDoc} */ + @Override public String fldA() { + return fldA; + } + + /** {@inheritDoc} */ + @Override public String fldB() { + return fldB; + } + + /** {@inheritDoc} */ + @Override public String fldC() { + return fldC; + } + + /** {@inheritDoc} */ + @Override public String fldD() { + return fldD; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_19_3.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_19_3.java new file mode 100644 index 0000000000000..1d71c2edab440 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_19_3.java @@ -0,0 +1,87 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import java.util.function.Predicate; +import org.apache.ignite.internal.FeatureGated; +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; +import org.apache.ignite.internal.processors.rollingupgrade.feature.TestIgniteReleaseFeatures_2_19_3; + +import static org.apache.ignite.internal.processors.rollingupgrade.feature.TestIgniteReleaseFeatures_2_19_3.VER_2_19_2_ID_2_FEATURE; + +/** */ +@FeatureGated(registry = TestIgniteReleaseFeatures_2_19_3.class) +public class TestCoreMessage_2_19_3 extends TestDiscoveryMessage { + /** */ + @Order(0) + String fldA; + + /** */ + @Order(1) + String fldB; + + /** */ + @Order(value = 2, deprecatedBy = "VER_2_19_2_ID_2_FEATURE") + String fldC; + + /** */ + @Order(value = 3, introducedBy = "VER_2_19_0_ID_1_FEATURE") + String fldD; + + /** */ + @Order(value = 4, introducedBy = "VER_2_19_3_ID_6_FEATURE") + String fldF; + + /** {@inheritDoc} */ + @Override public void fill(Predicate featureStatusProvider) { + fldA = A; + fldB = B; + + if (!featureStatusProvider.test(VER_2_19_2_ID_2_FEATURE)) + fldC = C; + + fldD = D; + fldF = F; + } + + /** {@inheritDoc} */ + @Override public String fldA() { + return fldA; + } + + /** {@inheritDoc} */ + @Override public String fldB() { + return fldB; + } + + /** {@inheritDoc} */ + @Override public String fldC() { + return fldC; + } + + /** {@inheritDoc} */ + @Override public String fldD() { + return fldD; + } + + /** {@inheritDoc} */ + @Override public String fldF() { + return fldF; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_20_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_20_0.java new file mode 100644 index 0000000000000..a4a2194219e96 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_20_0.java @@ -0,0 +1,93 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import java.util.function.Predicate; +import org.apache.ignite.internal.FeatureGated; +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; +import org.apache.ignite.internal.processors.rollingupgrade.feature.TestIgniteReleaseFeatures_2_20_0; + +import static org.apache.ignite.internal.processors.rollingupgrade.feature.TestIgniteReleaseFeatures_2_20_0.VER_2_19_2_ID_2_FEATURE; +import static org.apache.ignite.internal.processors.rollingupgrade.feature.TestIgniteReleaseFeatures_2_20_0.VER_2_20_0_ID_3_FEATURE; +import static org.apache.ignite.internal.processors.rollingupgrade.feature.TestIgniteReleaseFeatures_2_20_0.VER_2_20_0_ID_5_FEATURE; + +/** */ +@FeatureGated(registry = TestIgniteReleaseFeatures_2_20_0.class) +public class TestCoreMessage_2_20_0 extends TestDiscoveryMessage { + /** */ + @Order(0) + String fldA; + + /** */ + @Order(value = 1, deprecatedBy = "VER_2_20_0_ID_3_FEATURE") + String fldB; + + /** */ + @Order(value = 2, deprecatedBy = "VER_2_19_2_ID_2_FEATURE") + String fldC; + + /** */ + @Order(value = 3, deprecatedBy = "VER_2_20_0_ID_5_FEATURE") + String fldD; + + /** */ + @Order(value = 4, introducedBy = "VER_2_20_0_ID_4_FEATURE") + String fldE; + + /** {@inheritDoc} */ + @Override public void fill(Predicate featureStatusProvider) { + fldA = A; + + if (!featureStatusProvider.test(VER_2_20_0_ID_3_FEATURE)) + fldB = B; + + if (!featureStatusProvider.test(VER_2_19_2_ID_2_FEATURE)) + fldC = C; + + if (!featureStatusProvider.test(VER_2_20_0_ID_5_FEATURE)) + fldD = D; + + fldE = E; + } + + /** {@inheritDoc} */ + @Override public String fldA() { + return fldA; + } + + /** {@inheritDoc} */ + @Override public String fldB() { + return fldB; + } + + /** {@inheritDoc} */ + @Override public String fldC() { + return fldC; + } + + /** {@inheritDoc} */ + @Override public String fldD() { + return fldD; + } + + /** {@inheritDoc} */ + @Override public String fldE() { + return fldE; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_20_1.java similarity index 63% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_20_1.java index 35234fac1a5ac..434e76c382ad1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_20_1.java @@ -17,16 +17,19 @@ package org.apache.ignite.internal.processors.rollingupgrade.message; +import java.util.function.Predicate; import org.apache.ignite.internal.FeatureGated; import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; import org.apache.ignite.internal.processors.rollingupgrade.feature.TestIgniteReleaseFeatures_2_20_1; -import org.apache.ignite.lang.IgniteUuid; -import org.jetbrains.annotations.Nullable; + +import static org.apache.ignite.internal.processors.rollingupgrade.feature.TestIgniteReleaseFeatures_2_20_1.VER_2_19_2_ID_2_FEATURE; +import static org.apache.ignite.internal.processors.rollingupgrade.feature.TestIgniteReleaseFeatures_2_20_1.VER_2_20_0_ID_3_FEATURE; +import static org.apache.ignite.internal.processors.rollingupgrade.feature.TestIgniteReleaseFeatures_2_20_1.VER_2_20_0_ID_5_FEATURE; /** */ @FeatureGated(registry = TestIgniteReleaseFeatures_2_20_1.class) -public class TestCoreMessage extends DiscoveryCustomMessage implements TestMessage { +public class TestCoreMessage_2_20_1 extends TestDiscoveryMessage { /** */ @Order(0) String fldA; @@ -36,43 +39,36 @@ public class TestCoreMessage extends DiscoveryCustomMessage implements TestMessa String fldB; /** */ - @Order(2) + @Order(value = 2, deprecatedBy = "VER_2_19_2_ID_2_FEATURE") String fldC; /** */ - @Order(value = 3, introducedBy = "VER_2_19_2_ID_1_FEATURE", deprecatedBy = "VER_2_20_0_ID_3_FEATURE") + @Order(value = 3, deprecatedBy = "VER_2_20_0_ID_5_FEATURE") String fldD; /** */ - @Order(value = 4, introducedBy = "VER_2_20_0_ID_3_FEATURE") + @Order(value = 4, introducedBy = "VER_2_20_0_ID_4_FEATURE") String fldE; /** */ @Order(value = 5, introducedBy = "VER_2_20_1_ID_6_FEATURE") String fldF; - /** */ - public TestCoreMessage() { - super(IgniteUuid.randomUuid()); - } - /** {@inheritDoc} */ - @Nullable @Override public DiscoveryCustomMessage ackMessage() { - return null; - } + @Override public void fill(Predicate featureStatusProvider) { + fldA = A; - /** */ - public static TestCoreMessage build() { - TestCoreMessage msg = new TestCoreMessage(); + if (!featureStatusProvider.test(VER_2_20_0_ID_3_FEATURE)) + fldB = B; + + if (!featureStatusProvider.test(VER_2_19_2_ID_2_FEATURE)) + fldC = C; - msg.fldA = A; - msg.fldB = B; - msg.fldC = C; - msg.fldD = D; - msg.fldE = E; - msg.fldF = F; + if (!featureStatusProvider.test(VER_2_20_0_ID_5_FEATURE)) + fldD = D; - return msg; + fldE = E; + fldF = F; } /** {@inheritDoc} */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_21_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_21_0.java new file mode 100644 index 0000000000000..8aaeb19db9f8b --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestCoreMessage_2_21_0.java @@ -0,0 +1,62 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import java.util.function.Predicate; +import org.apache.ignite.internal.FeatureGated; +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; +import org.apache.ignite.internal.processors.rollingupgrade.feature.TestIgniteReleaseFeatures_2_21_0; + +/** */ +@FeatureGated(registry = TestIgniteReleaseFeatures_2_21_0.class) +public class TestCoreMessage_2_21_0 extends TestDiscoveryMessage { + /** */ + @Order(0) + String fldA; + + /** */ + @Order(1) + String fldE; + + /** */ + @Order(value = 2, introducedBy = "VER_2_21_0_ID_6_FEATURE") + String fldF; + + /** {@inheritDoc} */ + @Override public void fill(Predicate featureStatusProvider) { + fldA = A; + fldE = E; + fldF = F; + } + + /** {@inheritDoc} */ + @Override public String fldA() { + return fldA; + } + + /** {@inheritDoc} */ + @Override public String fldE() { + return fldE; + } + + /** {@inheritDoc} */ + @Override public String fldF() { + return fldF; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestDefaultRegistryMessage.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestDefaultRegistryMessage_2_19_0.java similarity index 68% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestDefaultRegistryMessage.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestDefaultRegistryMessage_2_19_0.java index 02e6173990b11..0a16983de37a0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestDefaultRegistryMessage.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestDefaultRegistryMessage_2_19_0.java @@ -17,13 +17,12 @@ package org.apache.ignite.internal.processors.rollingupgrade.message; +import java.util.function.Predicate; import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; -import org.apache.ignite.lang.IgniteUuid; -import org.jetbrains.annotations.Nullable; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; /** */ -public class TestDefaultRegistryMessage extends DiscoveryCustomMessage implements TestMessage { +public class TestDefaultRegistryMessage_2_19_0 extends TestDiscoveryMessage { /** */ @Order(0) String fldA; @@ -45,31 +44,17 @@ public class TestDefaultRegistryMessage extends DiscoveryCustomMessage implement String fldE; /** */ - @Order(value = 5, introducedBy = "ROLLING_UPGRADE_FEATURE") + @Order(5) String fldF; - /** */ - public TestDefaultRegistryMessage() { - super(IgniteUuid.randomUuid()); - } - /** {@inheritDoc} */ - @Nullable @Override public DiscoveryCustomMessage ackMessage() { - return null; - } - - /** */ - public static TestDefaultRegistryMessage build() { - TestDefaultRegistryMessage msg = new TestDefaultRegistryMessage(); - - msg.fldA = A; - msg.fldB = B; - msg.fldC = C; - msg.fldD = D; - msg.fldE = E; - msg.fldF = F; - - return msg; + @Override public void fill(Predicate featureStatusProvider) { + fldA = A; + fldB = B; + fldC = C; + fldD = D; + fldE = E; + fldF = F; } /** {@inheritDoc} */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestDefaultRegistryMessage_2_20_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestDefaultRegistryMessage_2_20_0.java new file mode 100644 index 0000000000000..aedab36bf4449 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestDefaultRegistryMessage_2_20_0.java @@ -0,0 +1,89 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import java.util.function.Predicate; +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; + +/** */ +public class TestDefaultRegistryMessage_2_20_0 extends TestDiscoveryMessage { + /** */ + @Order(0) + String fldA; + + /** */ + @Order(value = 1, deprecatedBy = "ROLLING_UPGRADE_FEATURE") + String fldB; + + /** */ + @Order(2) + String fldC; + + /** */ + @Order(3) + String fldD; + + /** */ + @Order(4) + String fldE; + + /** */ + @Order(5) + String fldF; + + /** {@inheritDoc} */ + @Override public void fill(Predicate featureStatusProvider) { + fldA = A; + fldB = B; + fldC = C; + fldD = D; + fldE = E; + fldF = F; + } + + /** {@inheritDoc} */ + @Override public String fldA() { + return fldA; + } + + /** {@inheritDoc} */ + @Override public String fldB() { + return fldB; + } + + /** {@inheritDoc} */ + @Override public String fldC() { + return fldC; + } + + /** {@inheritDoc} */ + @Override public String fldD() { + return fldD; + } + + /** {@inheritDoc} */ + @Override public String fldE() { + return fldE; + } + + /** {@inheritDoc} */ + @Override public String fldF() { + return fldF; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestDiscoveryMessage.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestDiscoveryMessage.java new file mode 100644 index 0000000000000..5a8ab24965f3c --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestDiscoveryMessage.java @@ -0,0 +1,35 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; +import org.apache.ignite.lang.IgniteUuid; +import org.jetbrains.annotations.Nullable; + +/** */ +public abstract class TestDiscoveryMessage extends DiscoveryCustomMessage implements TestMessage { + /** */ + protected TestDiscoveryMessage() { + super(IgniteUuid.randomUuid()); + } + + /** {@inheritDoc} */ + @Nullable @Override public DiscoveryCustomMessage ackMessage() { + return null; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestMessage.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestMessage.java index 15c639bf6fdaa..3427dd3f90898 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestMessage.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestMessage.java @@ -17,41 +17,71 @@ package org.apache.ignite.internal.processors.rollingupgrade.message; +import java.util.List; +import java.util.function.Predicate; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; + /** */ public interface TestMessage { /** */ - public static final String A = "A"; + String A = "A"; + + /** */ + String B = "B"; /** */ - public static final String B = "B"; + String C = "C"; /** */ - public static final String C = "C"; + String D = "D"; /** */ - public static final String D = "D"; + String E = "E"; /** */ - public static final String E = "E"; + String F = "F"; + + /** + * Fills the message with data. The implementation must take into account the final feature state of the release this + * message belongs to. This should imitate how Ignite processors fill messages with RU in mind (e.g. if the feature that + * deprecated a field is active, the field is not filled). + * + * @param featureStatusProvider Tells whether a feature is active in the cluster. + */ + void fill(Predicate featureStatusProvider); /** */ - public static final String F = "F"; + default String fldA() { + return null; + } /** */ - public String fldA(); + default String fldB() { + return null; + } /** */ - public String fldB(); + default String fldC() { + return null; + } /** */ - public String fldC(); + default String fldD() { + return null; + } /** */ - public String fldD(); + default String fldE() { + return null; + } /** */ - public String fldE(); + default String fldF() { + return null; + } /** */ - public String fldF(); + default List nestedMessages() { + return List.of(); + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestMessageType.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestMessageType.java new file mode 100644 index 0000000000000..bae4ba3f105f7 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestMessageType.java @@ -0,0 +1,86 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import java.util.Arrays; +import java.util.function.Predicate; +import org.apache.ignite.internal.processors.rollingupgrade.AbstractRollingUpgradeTest.TestVersions; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; +import org.apache.ignite.plugin.extensions.communication.Message; +import org.jetbrains.annotations.Nullable; + +/** */ +public enum TestMessageType { + /** */ + CORE_MSG("TestCoreMessage"), + + /** */ + PLUGIN_MSG("TestPluginMessage"), + + /** */ + DEFAULT_REGISTRY_MSG("TestDefaultRegistryMessage"), + + /** */ + CONTAINER_MSG("TestContainerMessage"); + + /** */ + private final String clsName; + + /** */ + TestMessageType(String clsName) { + this.clsName = clsName; + } + + /** */ + @Nullable private Class resolveClass(String cmpVers) { + TestVersions vers = TestVersions.parse(cmpVers); + + if (this == PLUGIN_MSG && !vers.containsPlugin()) + return null; + + String cmpVer = this == PLUGIN_MSG ? vers.pluginVersion() : vers.coreVersion(); + + String release = '_' + cmpVer.replace('.', '_'); + + try { + return Class.forName(TestMessageType.class.getPackageName() + '.' + clsName + release).asSubclass(Message.class); + } + catch (ClassNotFoundException ignored) { + return null; + } + } + + /** */ + public TestDiscoveryMessage build(String cmpVers, Predicate featureStatusProvider) throws Exception { + Class msgCls = resolveClass(cmpVers); + + if (msgCls == null) + throw new AssertionError("Failed to resolve test message class [type=" + this + ", cmpVers=" + cmpVers + ']'); + + TestDiscoveryMessage msg = (TestDiscoveryMessage)msgCls.getConstructor().newInstance(); + + msg.fill(featureStatusProvider); + + return msg; + } + + /** */ + public static Class[] resolveTestMessageClasses(String cmpVers) { + return Arrays.stream(values()).map(msgType -> msgType.resolveClass(cmpVers)).toArray(Class[]::new); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_0_9_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_0_9_0.java new file mode 100644 index 0000000000000..9ea108e029a27 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_0_9_0.java @@ -0,0 +1,59 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import java.util.function.Predicate; +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; + +/** */ +public class TestPluginMessage_0_9_0 extends TestDiscoveryMessage { + /** */ + @Order(0) + String fldA; + + /** */ + @Order(1) + String fldB; + + /** */ + @Order(2) + String fldC; + + /** {@inheritDoc} */ + @Override public void fill(Predicate featureStatusProvider) { + fldA = A; + fldB = B; + fldC = C; + } + + /** {@inheritDoc} */ + @Override public String fldA() { + return fldA; + } + + /** {@inheritDoc} */ + @Override public String fldB() { + return fldB; + } + + /** {@inheritDoc} */ + @Override public String fldC() { + return fldC; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_1_0_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_1_0_0.java new file mode 100644 index 0000000000000..a6cac2b867340 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_1_0_0.java @@ -0,0 +1,72 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import java.util.function.Predicate; +import org.apache.ignite.internal.FeatureGated; +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; +import org.apache.ignite.internal.processors.rollingupgrade.feature.TestPluginReleaseFeatures_1_0_0; + +/** */ +@FeatureGated(registry = TestPluginReleaseFeatures_1_0_0.class) +public class TestPluginMessage_1_0_0 extends TestDiscoveryMessage { + /** */ + @Order(0) + String fldA; + + /** */ + @Order(1) + String fldB; + + /** */ + @Order(2) + String fldC; + + /** */ + @Order(value = 3, introducedBy = "VER_1_0_0_ID_0_FEATURE") + String fldD; + + /** {@inheritDoc} */ + @Override public void fill(Predicate featureStatusProvider) { + fldA = A; + fldB = B; + fldC = C; + fldD = D; + } + + /** {@inheritDoc} */ + @Override public String fldA() { + return fldA; + } + + /** {@inheritDoc} */ + @Override public String fldB() { + return fldB; + } + + /** {@inheritDoc} */ + @Override public String fldC() { + return fldC; + } + + /** {@inheritDoc} */ + @Override public String fldD() { + return fldD; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_1_1_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_1_1_0.java new file mode 100644 index 0000000000000..e8ac881aaf000 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_1_1_0.java @@ -0,0 +1,77 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import java.util.function.Predicate; +import org.apache.ignite.internal.FeatureGated; +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; +import org.apache.ignite.internal.processors.rollingupgrade.feature.TestPluginReleaseFeatures_1_1_0; + +import static org.apache.ignite.internal.processors.rollingupgrade.feature.TestPluginReleaseFeatures_1_1_0.VER_1_1_0_ID_1_FEATURE; + +/** */ +@FeatureGated(registry = TestPluginReleaseFeatures_1_1_0.class) +public class TestPluginMessage_1_1_0 extends TestDiscoveryMessage { + /** */ + @Order(0) + String fldA; + + /** */ + @Order(value = 1, deprecatedBy = "VER_1_1_0_ID_1_FEATURE") + String fldB; + + /** */ + @Order(2) + String fldC; + + /** */ + @Order(value = 3, introducedBy = "VER_1_0_0_ID_0_FEATURE") + String fldD; + + /** {@inheritDoc} */ + @Override public void fill(Predicate featureStatusProvider) { + fldA = A; + + if (!featureStatusProvider.test(VER_1_1_0_ID_1_FEATURE)) + fldB = B; + + fldC = C; + fldD = D; + } + + /** {@inheritDoc} */ + @Override public String fldA() { + return fldA; + } + + /** {@inheritDoc} */ + @Override public String fldB() { + return fldB; + } + + /** {@inheritDoc} */ + @Override public String fldC() { + return fldC; + } + + /** {@inheritDoc} */ + @Override public String fldD() { + return fldD; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_2_0_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_2_0_0.java new file mode 100644 index 0000000000000..47e7eb04b26c9 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_2_0_0.java @@ -0,0 +1,91 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import java.util.function.Predicate; +import org.apache.ignite.internal.FeatureGated; +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; +import org.apache.ignite.internal.processors.rollingupgrade.feature.TestPluginReleaseFeatures_2_0_0; + +import static org.apache.ignite.internal.processors.rollingupgrade.feature.TestPluginReleaseFeatures_2_0_0.VER_1_1_0_ID_1_FEATURE; +import static org.apache.ignite.internal.processors.rollingupgrade.feature.TestPluginReleaseFeatures_2_0_0.VER_2_0_0_ID_3_FEATURE; + +/** */ +@FeatureGated(registry = TestPluginReleaseFeatures_2_0_0.class) +public class TestPluginMessage_2_0_0 extends TestDiscoveryMessage { + /** */ + @Order(0) + String fldA; + + /** */ + @Order(value = 1, deprecatedBy = "VER_1_1_0_ID_1_FEATURE") + String fldB; + + /** */ + @Order(2) + String fldC; + + /** */ + @Order(value = 3, deprecatedBy = "VER_2_0_0_ID_3_FEATURE") + String fldD; + + /** */ + @Order(value = 4, introducedBy = "VER_2_0_0_ID_2_FEATURE") + String fldE; + + /** {@inheritDoc} */ + @Override public void fill(Predicate featureStatusProvider) { + fldA = A; + + if (!featureStatusProvider.test(VER_1_1_0_ID_1_FEATURE)) + fldB = B; + + fldC = C; + + if (!featureStatusProvider.test(VER_2_0_0_ID_3_FEATURE)) + fldD = D; + + fldE = E; + } + + /** {@inheritDoc} */ + @Override public String fldA() { + return fldA; + } + + /** {@inheritDoc} */ + @Override public String fldB() { + return fldB; + } + + /** {@inheritDoc} */ + @Override public String fldC() { + return fldC; + } + + /** {@inheritDoc} */ + @Override public String fldD() { + return fldD; + } + + /** {@inheritDoc} */ + @Override public String fldE() { + return fldE; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_2_1_0.java similarity index 65% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_2_1_0.java index f901f7667bf54..6756f4e993efb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_2_1_0.java @@ -17,22 +17,24 @@ package org.apache.ignite.internal.processors.rollingupgrade.message; +import java.util.function.Predicate; import org.apache.ignite.internal.FeatureGated; import org.apache.ignite.internal.Order; -import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; import org.apache.ignite.internal.processors.rollingupgrade.feature.TestPluginReleaseFeatures_2_1_0; -import org.apache.ignite.lang.IgniteUuid; -import org.jetbrains.annotations.Nullable; + +import static org.apache.ignite.internal.processors.rollingupgrade.feature.TestPluginReleaseFeatures_2_1_0.VER_1_1_0_ID_1_FEATURE; +import static org.apache.ignite.internal.processors.rollingupgrade.feature.TestPluginReleaseFeatures_2_1_0.VER_2_0_0_ID_3_FEATURE; /** */ @FeatureGated(registry = TestPluginReleaseFeatures_2_1_0.class) -public class TestPluginMessage extends DiscoveryCustomMessage implements TestMessage { +public class TestPluginMessage_2_1_0 extends TestDiscoveryMessage { /** */ @Order(0) String fldA; /** */ - @Order(value = 1, deprecatedBy = "VER_2_0_0_ID_1_FEATURE") + @Order(value = 1, deprecatedBy = "VER_1_1_0_ID_1_FEATURE") String fldB; /** */ @@ -40,39 +42,31 @@ public class TestPluginMessage extends DiscoveryCustomMessage implements TestMes String fldC; /** */ - @Order(value = 3, introducedBy = "VER_1_0_0_ID_0_FEATURE", deprecatedBy = "VER_2_0_0_ID_1_FEATURE") + @Order(value = 3, deprecatedBy = "VER_2_0_0_ID_3_FEATURE") String fldD; /** */ - @Order(value = 4, introducedBy = "VER_2_0_0_ID_1_FEATURE") + @Order(value = 4, introducedBy = "VER_2_0_0_ID_2_FEATURE") String fldE; /** */ - @Order(value = 5, introducedBy = "VER_2_1_0_ID_2_FEATURE") + @Order(value = 5, introducedBy = "VER_2_1_0_ID_4_FEATURE") String fldF; - /** */ - public TestPluginMessage() { - super(IgniteUuid.randomUuid()); - } - /** {@inheritDoc} */ - @Nullable @Override public DiscoveryCustomMessage ackMessage() { - return null; - } + @Override public void fill(Predicate featureStatusProvider) { + fldA = A; - /** */ - public static TestPluginMessage build() { - TestPluginMessage msg = new TestPluginMessage(); + if (!featureStatusProvider.test(VER_1_1_0_ID_1_FEATURE)) + fldB = B; + + fldC = C; - msg.fldA = A; - msg.fldB = B; - msg.fldC = C; - msg.fldD = D; - msg.fldE = E; - msg.fldF = F; + if (!featureStatusProvider.test(VER_2_0_0_ID_3_FEATURE)) + fldD = D; - return msg; + fldE = E; + fldF = F; } /** {@inheritDoc} */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_3_0_0.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_3_0_0.java new file mode 100644 index 0000000000000..791512b0cebf6 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/message/TestPluginMessage_3_0_0.java @@ -0,0 +1,72 @@ +/* + * 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.internal.processors.rollingupgrade.message; + +import java.util.function.Predicate; +import org.apache.ignite.internal.FeatureGated; +import org.apache.ignite.internal.Order; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; +import org.apache.ignite.internal.processors.rollingupgrade.feature.TestPluginReleaseFeatures_3_0_0; + +/** */ +@FeatureGated(registry = TestPluginReleaseFeatures_3_0_0.class) +public class TestPluginMessage_3_0_0 extends TestDiscoveryMessage { + /** */ + @Order(0) + String fldA; + + /** */ + @Order(1) + String fldC; + + /** */ + @Order(2) + String fldE; + + /** */ + @Order(value = 3, introducedBy = "VER_2_1_0_ID_4_FEATURE") + String fldF; + + /** {@inheritDoc} */ + @Override public void fill(Predicate featureStatusProvider) { + fldA = A; + fldC = C; + fldE = E; + fldF = F; + } + + /** {@inheritDoc} */ + @Override public String fldA() { + return fldA; + } + + /** {@inheritDoc} */ + @Override public String fldC() { + return fldC; + } + + /** {@inheritDoc} */ + @Override public String fldE() { + return fldE; + } + + /** {@inheritDoc} */ + @Override public String fldF() { + return fldF; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/MessagesPluginProvider.java b/modules/core/src/test/java/org/apache/ignite/spi/MessagesPluginProvider.java index 0090d11cc3c56..f4b7fb9cbcd62 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/MessagesPluginProvider.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/MessagesPluginProvider.java @@ -43,7 +43,8 @@ public MessagesPluginProvider(Class... msgs) { short directType = CoreMessagesProvider.MAX_MESSAGE_ID + 1; for (Class msg : msgs) { - f.register(directType, loadSerializer(msg), marshaller(msg)); + if (msg != null) + f.register(directType, loadSerializer(msg), marshaller(msg)); directType++; }