Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <pre>
* 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
*
* <p>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.
*
* <table border="1">
* <tr>
* <th>Version</th>
* <th>Features</th>
* </tr>
* <tr>
* <td>2.18.0</td>
* <td>not supported</td>
* </tr>
* <tr>
* <td>2.19.0</td>
* <td>{@code IgniteFeatureSet [0]}</td>
* </tr>
* <tr>
* <td>2.19.1</td>
* <td>{@code IgniteFeatureSet [0]}</td>
* </tr>
* <tr>
* <td>2.19.2</td>
* <td>{@code IgniteFeatureSet [0 -> 2]}</td>
* </tr>
* <tr>
* <td>2.19.3</td>
* <td>{@code IgniteFeatureSet [0 -> 2, 6]}</td>
* </tr>
* <tr>
* <td>2.20.0</td>
* <td>{@code IgniteFeatureSet [0 -> 4]}</td>
* </tr>
* <tr>
* <td>2.20.1</td>
* <td>{@code IgniteFeatureSet [0 -> 4, 6]}</td>
* </tr>
* <tr>
* <td>2.21.0</td>
* <td>{@code IgniteFeatureSet [3 -> 6]}</td>
* </tr>
* <tr>
* <td>2.21.1</td>
* <td>{@code IgniteFeatureSet [3 -> 7]}</td>
* </tr>
* </table>
* 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
* </pre>
*/
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";
Expand Down Expand Up @@ -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()))
Expand All @@ -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()));
Expand Down Expand Up @@ -269,6 +248,18 @@ public static Collection<IgniteFeature> 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<IgniteFeature> readDeclaredPluginFeatures(String ver) throws Exception {
Class<?> cls = Class.forName(
Expand Down Expand Up @@ -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);
Expand All @@ -565,7 +556,7 @@ protected void forAllNodes(ConsumerX<Integer> 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);
Expand All @@ -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);
}

/** */
Expand Down Expand Up @@ -642,7 +633,7 @@ protected static RollingUpgradeProcessor ru(Ignite ignite) {
}

/** */
protected static class TestVersions {
public static class TestVersions {
/** */
private final Map<String, String> cmpVersions = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Loading
Loading