Beispiel #1
0
        public void ShouldReportUnhealthyTest()
        {
            FaultInjectionConfig config;
            StandAloneCluster    cluster = Utility.PopulateStandAloneClusterWithBaselineJson("myClusterConfig.UnSecure.DevCluster.json");

            cluster.TargetNodeConfig = new ClusterNodeConfig(null, 0);

            config = new FaultInjectionConfig(UpgradeFlow.RollingForward, 0);

            StandAloneSimpleClusterUpgradeState upgradeState1 = new StandAloneSimpleClusterUpgradeState(cluster.TargetCsmConfig, cluster.TargetWrpConfig, cluster.TargetNodeConfig, cluster, new StandAloneTraceLogger("StandAloneDeploymentManager"));

            Assert.IsTrue(FaultInjectionHelper.ShouldReportUnhealthy(upgradeState1, UpgradeFlow.RollingForward, config));
            Assert.IsFalse(FaultInjectionHelper.ShouldReportUnhealthy(upgradeState1, UpgradeFlow.RollingBack, config));

            MockUpMultiphaseClusterUpgradeState upgradeState2 = new MockUpMultiphaseClusterUpgradeState(2, cluster);

            upgradeState2.CurrentListIndex = 0;
            Assert.IsTrue(FaultInjectionHelper.ShouldReportUnhealthy(upgradeState2, UpgradeFlow.RollingForward, config));
            Assert.IsFalse(FaultInjectionHelper.ShouldReportUnhealthy(upgradeState2, UpgradeFlow.RollingBack, config));
            upgradeState2.CurrentListIndex = 1;
            Assert.IsFalse(FaultInjectionHelper.ShouldReportUnhealthy(upgradeState2, UpgradeFlow.RollingForward, config));

            config = new FaultInjectionConfig(UpgradeFlow.RollingForward, 1);
            Assert.IsFalse(FaultInjectionHelper.ShouldReportUnhealthy(upgradeState1, UpgradeFlow.RollingForward, config));
            Assert.IsTrue(FaultInjectionHelper.ShouldReportUnhealthy(upgradeState2, UpgradeFlow.RollingForward, config));
        }
Beispiel #2
0
        public void GetUpgradeFlowTest()
        {
            StandAloneCluster cluster = Utility.PopulateStandAloneClusterWithBaselineJson("myClusterConfig.UnSecure.DevCluster.json");

            cluster.TargetNodeConfig = new ClusterNodeConfig(null, 0);

            StandAloneSimpleClusterUpgradeState upgradeState1 = new StandAloneSimpleClusterUpgradeState(cluster.TargetCsmConfig, cluster.TargetWrpConfig, cluster.TargetNodeConfig, cluster, new StandAloneTraceLogger("StandAloneDeploymentManager"));

            Assert.AreEqual(UpgradeFlow.RollingForward, FaultInjectionHelper.GetUpgradeFlow(upgradeState1));

            MockUpMultiphaseClusterUpgradeState upgradeState2 = new MockUpMultiphaseClusterUpgradeState(2, cluster);

            upgradeState2.UpgradeUnsuccessful = false;
            Assert.AreEqual(UpgradeFlow.RollingForward, FaultInjectionHelper.GetUpgradeFlow(upgradeState2));

            upgradeState2.UpgradeUnsuccessful = true;
            Assert.AreEqual(UpgradeFlow.RollingBack, FaultInjectionHelper.GetUpgradeFlow(upgradeState2));
        }
        public void RollForwardTest()
        {
            int totalIterations = 5;

            ICluster cluster = this.InitializeCluster();

            MockUpMultiphaseClusterUpgradeState upgradeState = new MockUpMultiphaseClusterUpgradeState(totalIterations, cluster);

            Assert.IsTrue(upgradeState.StartProcessing());
            Assert.IsNotNull(upgradeState.ExternalState);
            Assert.IsNotNull(upgradeState.PreviousExternalState);
            Assert.AreNotEqual(upgradeState.ExternalState, upgradeState.PreviousExternalState);
            Assert.AreEqual(totalIterations, upgradeState.ClusterManifestList.Count());
            Assert.AreEqual(0, upgradeState.CurrentListIndex);
            Assert.IsNull(upgradeState.ClusterUpgradeStarted());

            for (int i = 0; i < totalIterations; i++)
            {
                ClusterExternalState currentState = upgradeState.ExternalState;
                ClusterState         finalState   = upgradeState.RollForwardOneIteration();

                Assert.AreEqual(currentState, upgradeState.PreviousExternalState);
                Assert.AreEqual(i == totalIterations - 1, finalState != null);

                Assert.IsNotNull(upgradeState.ExternalState);
                Assert.IsNotNull(upgradeState.PreviousExternalState);
                Assert.AreNotSame(upgradeState.ExternalState, upgradeState.PreviousExternalState);
                Assert.AreEqual(totalIterations, upgradeState.ClusterManifestList.Count());

                if (i < totalIterations - 1)
                {
                    Assert.AreEqual(i + 1, upgradeState.CurrentListIndex);
                }
                else
                {
                    Assert.AreEqual(i, upgradeState.CurrentListIndex);
                }
            }
        }
        public void InterruptTest()
        {
            int totalIterations = 5;

            ICluster cluster = this.InitializeCluster();
            MockUpMultiphaseClusterUpgradeState upgradeState = new MockUpMultiphaseClusterUpgradeState(totalIterations, cluster);

            Assert.IsTrue(upgradeState.CanInterruptUpgrade());

            upgradeState.StartProcessing();
            Assert.IsTrue(upgradeState.CanInterruptUpgrade());

            upgradeState.ClusterUpgradeStarted();
            Assert.IsTrue(upgradeState.CanInterruptUpgrade());

            for (int i = 0; i < totalIterations; i++)
            {
                upgradeState.RollForwardOneIteration();
                Assert.IsFalse(upgradeState.CanInterruptUpgrade());
            }

            Assert.IsFalse(upgradeState.CanInterruptUpgrade());
        }
        internal void InternalRollBackTest(int totalIterations, int successfulRollForwardIteration, int?unsuccessfulRollBackIteration)
        {
            Assert.IsTrue(totalIterations > successfulRollForwardIteration + 1);

            ICluster cluster = this.InitializeCluster();

            MockUpMultiphaseClusterUpgradeState upgradeState = new MockUpMultiphaseClusterUpgradeState(totalIterations, cluster);

            Assert.IsTrue(upgradeState.StartProcessing());
            Assert.IsNull(upgradeState.ClusterUpgradeStarted());

            // roll forward
            for (int i = 0; i <= successfulRollForwardIteration; i++)
            {
                upgradeState.RollForwardOneIteration();
            }

            // prepare roll back
            ClusterExternalState currentState = upgradeState.ExternalState;
            int          currentIndex         = upgradeState.CurrentListIndex;
            ClusterState targetState          = upgradeState.RollBackOneIteration();

            Assert.AreEqual(successfulRollForwardIteration < 0, targetState != null);
            if (targetState == null)
            {
                Assert.AreEqual(upgradeState.PreviousExternalState, currentState);
                Assert.AreEqual(currentIndex, upgradeState.CurrentListIndex);
            }

            // successful roll back
            int totalSuccessfulRollbackIterations = unsuccessfulRollBackIteration.HasValue ?
                                                    successfulRollForwardIteration - unsuccessfulRollBackIteration.Value + 1: successfulRollForwardIteration + 1;

            for (int i = 0; i < totalSuccessfulRollbackIterations; i++)
            {
                currentState = upgradeState.ExternalState;
                targetState  = upgradeState.RollForwardOneIteration();

                Assert.AreEqual(currentState, upgradeState.PreviousExternalState);
                Assert.AreEqual(i == successfulRollForwardIteration, targetState != null);

                Assert.IsNotNull(upgradeState.ExternalState);
                Assert.IsNotNull(upgradeState.PreviousExternalState);
                Assert.AreNotSame(upgradeState.ExternalState, upgradeState.PreviousExternalState);
                Assert.AreEqual(totalIterations, upgradeState.ClusterManifestList.Count());

                if (i < totalSuccessfulRollbackIterations - 1 || unsuccessfulRollBackIteration.HasValue)
                {
                    Assert.AreEqual(successfulRollForwardIteration - i, upgradeState.CurrentListIndex);
                }
                else
                {
                    Assert.AreEqual(successfulRollForwardIteration - i + 1, upgradeState.CurrentListIndex);
                }
            }

            // unsuccessful rollback
            if (unsuccessfulRollBackIteration.HasValue)
            {
                currentIndex = upgradeState.CurrentListIndex;
                targetState  = upgradeState.RollBackOneIteration();
                Assert.AreEqual(currentIndex, upgradeState.CurrentListIndex);
                Assert.IsNull(targetState);
            }
            else
            {
                Assert.AreEqual(successfulRollForwardIteration > 0 ? 1 : 0, upgradeState.CurrentListIndex);
            }
        }