sergey-chugunov-1985 commented on code in PR #13195: URL: https://github.com/apache/ignite/pull/13195#discussion_r3436611705
########## modules/core/src/test/java/org/apache/ignite/internal/processors/rollingupgrade/ClusterVersionsRollingUpgradeTest.java: ########## @@ -0,0 +1,853 @@ +/* + * 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; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.atomic.AtomicInteger; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.Ignition; +import org.apache.ignite.configuration.BinaryConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.IgnitionEx; +import org.apache.ignite.internal.processors.rollingupgrade.RollingUpgradeProcessor.RollingUpgradeState; +import org.apache.ignite.internal.processors.rollingupgrade.feature.AbstractRollingUpgradeTest; +import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeature; +import org.apache.ignite.internal.util.distributed.InitMessage; +import org.apache.ignite.internal.util.distributed.SingleNodeMessage; +import org.apache.ignite.internal.util.lang.ConsumerX; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.spi.IgniteSpiException; +import org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage; +import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage; +import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCustomEventMessage; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; + +import static java.util.concurrent.TimeUnit.MILLISECONDS; +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.security.NodeSecurityContextPropagationTest.discoveryRingMessageWorker; +import static org.apache.ignite.internal.processors.security.NodeSecurityContextPropagationTest.discoveryRingMessageWorkerQueue; +import static org.apache.ignite.internal.processors.security.NodeSecurityContextPropagationTest.wrapRingMessageWorkerQueue; + +/** */ +public class ClusterVersionsRollingUpgradeTest extends AbstractRollingUpgradeTest { + /** */ + @Test + public void testVersionUpgradeDisabledSingleServer() throws Exception { + startGrid(0); + + checkVersionUpgradeInactive("2.19.0"); + } + + /** */ + @Test + public void testVersionUpgradeDisabledNodeJoin() throws Exception { + startCluster(); + + checkVersionUpgradeInactive(TEST_DEFAULT_VER); + + String msg = "The joining node version differs from the version of the cluster"; + + checkJoinFailed(3, "2.18.0", msg); + checkJoinFailed(3, "2.19.1", msg); + } + + /** */ + @Test + public void testVersionUpgradeDisabledFinalization() throws Exception { + startCluster(); + + ru(1).finalizeClusterVersion(); + + checkVersionUpgradeInactive(TEST_DEFAULT_VER); + } + + /** */ + @Test + public void testVersionsFinalizationNoVersionUpgrade() throws Exception { + startCluster(); + + ru(1).enableVersionUpgrade(); + + checkVersionUpgradeInProgress(TEST_DEFAULT_VER, null); + + ru(1).finalizeClusterVersion(); + + checkVersionUpgradeInactive(TEST_DEFAULT_VER); + + restartNode(1); + restartNode(2); + } + + /** */ + @Test + public void testVersionUpgradeCommandsIdempotency() throws Exception { + startCluster(); + + ru(0).enableVersionUpgrade(); + ru(1).enableVersionUpgrade(); + + checkVersionUpgradeInProgress(TEST_DEFAULT_VER, null); + + ru(0).finalizeClusterVersion(); + ru(0).finalizeClusterVersion(); + + checkVersionUpgradeInactive(TEST_DEFAULT_VER); + } + + /** */ + @Test + public void testVersionUpgradeEnabledNodeJoin() throws Exception { + startCluster(); + + ru(1).enableVersionUpgrade(); + + checkVersionUpgradeInProgress(TEST_DEFAULT_VER, null); + + restartNode(2); + restartNode(0); + + checkJoinSuccess(3, false); + checkJoinSuccess(4, true); + + checkVersionUpgradeInProgress(TEST_DEFAULT_VER, null); + + checkJoinFailed(5, "2.18.0", + "The joining node is incompatible with the current state of the cluster version rolling upgrade being in progress"); + + upgradeNodeVersion(0, "2.19.1"); + upgradeNodeVersion(2, "2.19.1"); + + checkVersionUpgradeInProgress(TEST_DEFAULT_VER, "2.19.1"); + + checkJoinFailed(5, "2.19.2", + "The joining node is incompatible with the current state of the cluster version rolling upgrade being in progress"); + + restartNode(3); + restartNode(4); + + restartNode(0); + restartNode(2); + + upgradeNodeVersion(1, "2.19.1"); + upgradeNodeVersion(3, "2.19.1"); + upgradeNodeVersion(4, "2.19.1"); + + finalizeClusterVersion(1, "2.19.1"); + } + + /** */ + @Test + public void testClusterVersionUpgrade() throws Exception { + startCluster(); + + ru(1).enableVersionUpgrade(); + + upgradeNodeVersion(1, "2.19.2"); + + checkVersionFinalizationFailed( + 1, + "Cluster version finalization failed. The topology contains nodes running multiple different versions" + ); + + upgradeNodeVersion(0, "2.19.2"); + + checkVersionFinalizationFailed( + 1, + "Cluster version finalization failed. The topology contains nodes running multiple different versions" + ); + + upgradeNodeVersion(2, "2.19.2"); + + finalizeClusterVersion(1, "2.19.2"); + } + + /** */ + @Test + public void testJoinAfterClusterVersionFinalization() throws Exception { + startCluster(); + + ru(1).enableVersionUpgrade(); + + upgradeNodeVersion(0, "2.19.2"); + upgradeNodeVersion(2, "2.19.2"); + stopGrid(1); + + finalizeClusterVersion(0, "2.19.2"); + + checkJoinSuccess(1, "2.19.2", false); + checkJoinSuccess(4, "2.19.2", true); + + checkVersionUpgradeInactive("2.19.2"); + } + + /** */ + @Test + public void testFeatureActivationListener() throws Exception { + startCluster(); + + ru(1).enableVersionUpgrade(); + + CountDownLatch featureActivationLatch = new CountDownLatch(3); + + forAllNodes(nodeIdx -> { + upgradeNodeVersion(nodeIdx, "2.19.2"); + checkFeatureActivationSubscription(nodeIdx, VER_2_19_2_ID_1_FEATURE, featureActivationLatch); + }); + + finalizeClusterVersion(1, "2.19.2"); + + assertTrue(featureActivationLatch.await(getTestTimeout(), MILLISECONDS)); + } + + /** */ + @Test + public void testIterativeClusterVersionUpgrade() throws Exception { + startCluster(); + + ru(1).enableVersionUpgrade(); + + forAllNodes(nodeIdx -> upgradeNodeVersion(nodeIdx, "2.19.2")); + + upgradeNodeVersion(0, TEST_DEFAULT_VER, "2.19.2", "2.19.3"); + + stopGrid(0); + + checkJoinSuccess(3, TEST_DEFAULT_VER, false); + checkJoinSuccess(4, TEST_DEFAULT_VER, true); + + checkUpgradeFailed(2, "2.19.3", + "The joining node is incompatible with the current state of the cluster version rolling upgrade being in progress"); + checkUpgradeFailed(1, "2.19.3", + "The joining node is incompatible with the current state of the cluster version rolling upgrade being in progress"); + + upgradeNodeVersion(3, "2.19.2"); + upgradeNodeVersion(4, "2.19.2"); + checkJoinSuccess(0, "2.19.3", false); + + checkUpgradeFailed(2, TEST_DEFAULT_VER, + "The joining node is incompatible with the current state of the cluster version rolling upgrade being in progress"); + checkUpgradeFailed(1, TEST_DEFAULT_VER, + "The joining node is incompatible with the current state of the cluster version rolling upgrade being in progress"); + + restartNode(1); + restartNode(2); + + upgradeNodeVersion(2, TEST_DEFAULT_VER, "2.19.2", "2.19.3"); + upgradeNodeVersion(1, TEST_DEFAULT_VER, "2.19.2", "2.19.3"); + upgradeNodeVersion(3, TEST_DEFAULT_VER, "2.19.2", "2.19.3"); + // After all cluster nodes have been upgraded, the Rolling Upgrade source version becomes equal to the cluster logical version. + upgradeNodeVersion(4, TEST_DEFAULT_VER, TEST_DEFAULT_VER, "2.19.3"); + + checkJoinSuccess(5, "2.19.2", false); + checkJoinSuccess(6, "2.19.2", false); + + upgradeNodeVersion(5, TEST_DEFAULT_VER, "2.19.2", "2.19.3"); + // After all cluster nodes have been upgraded, the Rolling Upgrade source version becomes equal to the cluster logical version. + upgradeNodeVersion(6, TEST_DEFAULT_VER, TEST_DEFAULT_VER, "2.19.3"); + + finalizeClusterVersion(1, "2.19.3"); + } + + /** */ + @Test + public void testMultipleClusterVersionUpgrades() throws Exception { + startCluster(); + + ru(1).enableVersionUpgrade(); + forAllNodes(nodeIdx -> upgradeNodeVersion(nodeIdx, "2.19.2")); + finalizeClusterVersion(1, "2.19.2"); + + ru(1).enableVersionUpgrade(); + forAllNodes(nodeIdx -> upgradeNodeVersion(nodeIdx, "2.19.2", "2.20.0")); + finalizeClusterVersion(1, "2.20.0"); + + ru(1).enableVersionUpgrade(); + forAllNodes(nodeIdx -> upgradeNodeVersion(nodeIdx, "2.20.0", "2.21.0")); + finalizeClusterVersion(1, "2.21.0"); + } + + /** */ + @Test + public void testProductVersionChangeDuringClusterVersionUpgrade() throws Exception { + startCluster(); + + ru(1).enableVersionUpgrade(); + + upgradeNodeVersion(0, "2.19.2"); + + upgradeNodeVersion(0, "2.19.3"); + + checkUpgradeFailed(1, "2.19.2", + "The joining node is incompatible with the current state of the cluster version rolling upgrade being in progress"); + checkUpgradeFailed(2, "2.19.2", + "The joining node is incompatible with the current state of the cluster version rolling upgrade being in progress"); + + upgradeNodeVersion(1, "2.19.3"); + upgradeNodeVersion(2, "2.19.3"); + + finalizeClusterVersion(1, "2.19.3"); + } + + /** */ + @Test + public void testUpgradeBetweenVersionsWithCherryPicks() throws Exception { + startCluster("2.19.3"); + + ru(1).enableVersionUpgrade(); + + checkJoinFailed(3, "2.20.0", + "Rolling Upgrade is not available between the current cluster logical version and the joining node product version"); + + forAllNodes(nodeIdx -> upgradeNodeVersion(nodeIdx, "2.19.3", "2.20.1")); + + finalizeClusterVersion(1, "2.20.1"); + } + + /** */ + @Test + public void testUpgradeBetweenVersionWithCherryPicksAndContinuousRange() throws Exception { + startCluster("2.20.1"); + + ru(1).enableVersionUpgrade(); + + forAllNodes(nodeIdx -> upgradeNodeVersion(nodeIdx, "2.20.1", "2.21.1")); + + finalizeClusterVersion(1, "2.21.1"); + } + + /** */ + @Test + public void testConcurrentFinalization() throws Exception { + startCluster(); + + ru(1).enableVersionUpgrade(); + + spi(grid(1)).blockMessages((node, msg) -> msg instanceof SingleNodeMessage); + + try { + Review Comment: ```suggestion ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
