Exemple #1
0
        public void MsiOnlyRollBackTestUserSet()
        {
            MockupCluster cluster = Utility.DoBaselineUpgrade("ClusterConfig.Unsecured.DevCluster.json");

            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineConfigVersion, cluster.Current.CSMConfig.Version.Version);

            Utility.UpdateCluster(cluster, SimpleClusterUpgradeTest.TargetMsiVersion, SimpleClusterUpgradeTest.TargetClusterSettingsVersion, true);

            Assert.IsTrue(cluster.RunStateMachine());

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(MockupSimpleClusterUpgradeState));
            Assert.AreNotEqual(upgradeState.TargetWrpConfig.Version, cluster.Current.WRPConfig.Version);

            Utility.RollBackOneIteration(cluster);

            Assert.IsFalse(cluster.RunStateMachine());

            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineMsiVersion, cluster.Current.WRPConfig.Version.MsiVersion);
            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineClusterSettingsVersion, cluster.Current.WRPConfig.Version.ClusterSettingsVersion);
            Assert.AreEqual(cluster.TargetNodeConfig, null);
            Assert.AreNotEqual(cluster.TargetWrpConfig, null);
            Assert.AreEqual(cluster.TargetCsmConfig, null);
            Assert.AreEqual(cluster.TargetCsmConfigUpgradeFailed, true);
            Assert.AreEqual(cluster.TargetWrpConfigUpgradeFailed, true);
        }
Exemple #2
0
        public void StandAloneSetClusterIdTest()
        {
            string[] jsonFilePaths = new string[]
            {
                "myClusterId.Unsecure.DevCluster.GA.json",
                "myClusterId.Unsecure.DevCluster.Jan2017.json"
            };

            foreach (string jsonFilePath in jsonFilePaths)
            {
                StandAloneCluster cluster = Utility.PopulateStandAloneClusterWithBaselineJson(jsonFilePath);
                Assert.IsTrue(Utility.RunStateMachine(cluster));
                ClusterUpgradeStateBase upgradeState = cluster.Pending;
                Assert.IsInstanceOfType(upgradeState, typeof(StandAloneBaselineUpgradeState));
                Assert.AreEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);
                Utility.RollForwardOneIteration(cluster);
                Assert.IsFalse(Utility.RunStateMachine(cluster));
                Assert.IsNull(cluster.Pending);
                Assert.IsNotNull(cluster.Current);

                string clusterIdInManifest = cluster.Current.ExternalState.ClusterManifest.FabricSettings.First(
                    section => section.Name == StringConstants.SectionName.UpgradeOrchestrationService).Parameter.First(
                    param => param.Name == StringConstants.ParameterName.ClusterId).Value;
                Assert.AreEqual("EAB8C37A-CC8A-4EE8-8250-3B0A6B7D0B59", clusterIdInManifest);
            }
        }
        public void RollForwardTest()
        {
            MockupCluster cluster = Utility.DoBaselineUpgrade("ClusterConfig.Unsecured.DevCluster.json");

            //Start a simple cluster upgrade to update the MSI version to the ExpectedMsiVersion.
            Utility.UpdateCluster(cluster, GatekeepingClusterUpgradeTest.ExpectedMsiVersion, GatekeepingClusterUpgradeTest.ExpectedClusterSettingsVersion);

            Assert.IsTrue(cluster.RunStateMachine());

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Utility.RollForwardOneIteration(cluster);

            Assert.IsFalse(cluster.RunStateMachine());

            //Set the MSI version in current to the wrong MSI verion.
            cluster.Current.WRPConfig.Version.MsiVersion = GatekeepingClusterUpgradeTest.WrongMsiVersion;

            Assert.AreNotEqual(cluster.Current.WRPConfig.Version.MsiVersion, cluster.Current.ExternalState.MsiVersion);

            //Sice the MSI version number is not expected. Trigger a GatekeepingClusterUpgrade to rollback the version number to the ExpectedMsiVersion.
            MockupUpgradeStateActivator mockupUpgradeStateActivator = new MockupUpgradeStateActivator();

            cluster.Pending = mockupUpgradeStateActivator.CreateGatekeepingClusterUpgradeState(cluster.Current.CSMConfig, cluster.Current.WRPConfig, cluster.Current.NodeConfig, cluster, new MockupTraceLogger());

            bool processingSuccess = cluster.Pending.StartProcessing();

            Utility.RollForwardOneIteration(cluster);

            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
            Assert.AreEqual(GatekeepingClusterUpgradeTest.ExpectedMsiVersion, cluster.Current.ExternalState.MsiVersion);
        }
        public void StandAloneRollForwardTestWithCustomDeserealization()
        {
            StandAloneCluster cluster = Utility.DoBaselineUpgrade("myClusterConfig.UnSecure.DevCluster.json");

            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineConfigVersion, cluster.Current.CSMConfig.Version.Version);

            Utility.UpdateStandAloneCluster("myClusterConfig.UnSecure.DevClusterV2.json", cluster);

            Assert.IsTrue(Utility.RunStateMachine(cluster));

            string defaultSerializedCluster = Utility.SerealizeUsingDefaults(cluster);

            cluster = Utility.DeserealizeUsingCustomDeserealizer(defaultSerializedCluster);

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(StandAloneSimpleClusterUpgradeState));
            Assert.AreNotEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);
            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);
            Assert.AreNotEqual(SimpleClusterUpgradeTest.TargetDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);

            Utility.RollForwardOneIteration(cluster);

            defaultSerializedCluster = Utility.SerealizeUsingDefaults(cluster);
            cluster = Utility.DeserealizeUsingCustomDeserealizer(defaultSerializedCluster);

            Assert.IsFalse(Utility.RunStateMachine(cluster));
            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
            Assert.AreEqual(SimpleClusterUpgradeTest.TargetDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);

            Assert.AreEqual(SimpleClusterUpgradeTest.TargetConfigVersion, cluster.Current.CSMConfig.Version.Version);
        }
Exemple #5
0
        public void InterruptWithCertificateClusterUpgrade()
        {
            MockupCluster cluster = Utility.DoBaselineUpgrade("ClusterConfig.Unsecured.DevCluster.json");

            Assert.AreEqual(AutoScaleClusterUpgradeTest.BaselineVMInstanceCount, cluster.Current.CSMConfig.NodeTypes[0].VMInstanceCount);

            Utility.UpdateCluster("ClusterConfig.Unsecured.DevCluster.AutoScale.V2.json", cluster);

            Assert.IsTrue(cluster.RunStateMachine());

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(MockupAutoScaleClusterUpgradeState));
            Assert.AreNotEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);

            //Need to set targetReplicaSetSize to an empty dictionary, in order to get the system think the replica set size is updated.
            //Otherwise VerifyTargetSystemServicesReplicaSetSize() will fail.

            var targetReplicaSetSize = new Dictionary <string, ReplicaSetSize>()
            {
                { "", new ReplicaSetSize() }
            };

            MockupAutoScaleClusterUpgradeState scaleUpUpgradeState = (MockupAutoScaleClusterUpgradeState)upgradeState;

            scaleUpUpgradeState.TargetSystemServicesSize = new Dictionary <string, ReplicaSetSize>();

            scaleUpUpgradeState.GetSystemServiceReplicaSetSize(targetReplicaSetSize);

            //Interrupt with a certificate cluster upgrade
            Utility.UpdateCluster("ClusterConfig.X509.DevCluster.AddPrimary.V1.json", cluster);

            //AutoScaleClusterUpgrade can't be interrupted.
            Assert.IsFalse(cluster.RunStateMachine());
        }
        public void StandAloneRollBackWRPTest()
        {
            StandAloneCluster cluster = Utility.DoBaselineUpgrade("myClusterConfig.UnSecure.DevCluster.json");

            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineConfigVersion, cluster.Current.CSMConfig.Version.Version);

            Utility.UpdateStandAloneClusterWRPSettings("myClusterSettings.1.0.json", "1.0", cluster);

            Assert.IsTrue(Utility.RunStateMachine(cluster));

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(StandAloneSimpleClusterUpgradeState));
            Assert.AreNotEqual(upgradeState.TargetWrpConfig, cluster.Current.WRPConfig);
            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineAdminConfigClusterSettingsVersion, cluster.Current.WRPConfig.Version.ClusterSettingsVersion);

            Utility.RollBackOneIteration(cluster);

            Assert.IsFalse(Utility.RunStateMachine(cluster));

            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineAdminConfigClusterSettingsVersion, cluster.Current.WRPConfig.Version.ClusterSettingsVersion);
            Assert.AreEqual(cluster.TargetNodeConfig, null);
            Assert.AreNotEqual(cluster.TargetWrpConfig, null);
            Assert.AreEqual(cluster.TargetCsmConfig, null);
            Assert.AreEqual(cluster.TargetCsmConfigUpgradeFailed, false);
            Assert.AreEqual(cluster.TargetWrpConfigUpgradeFailed, true);
        }
        public void StandAloneRollForwardTestEnsureNoSeedNodeShift()
        {
            StandAloneCluster cluster = Utility.DoBaselineUpgrade("ClusterConfig.Unsecure.MultiMachine.SeedCheckV1.json");

            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineConfigVersion, cluster.Current.CSMConfig.Version.Version);
            var seedNodes = ((ClusterManifestTypeInfrastructureWindowsServer)cluster.Current.ExternalState.ClusterManifest.Infrastructure.Item).NodeList.ToList().Where(node => node.IsSeedNode).Select(node => node.NodeName).ToList();

            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineSeedNodeCount, seedNodes.Count());

            Utility.UpdateStandAloneCluster("ClusterConfig.Unsecure.MultiMachine.SeedCheckV2.json", cluster);

            Assert.IsTrue(Utility.RunStateMachine(cluster));

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(StandAloneSimpleClusterUpgradeState));
            Assert.AreNotEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);

            var targetSeedNodes = ((ClusterManifestTypeInfrastructureWindowsServer)cluster.Pending.ExternalState.ClusterManifest.Infrastructure.Item).NodeList.ToList().Where(node => node.IsSeedNode).Select(node => node.NodeName).ToList();

            Assert.AreEqual(SimpleClusterUpgradeTest.TargetSeedNodeCount, targetSeedNodes.Count());

            var firstNotSecond = targetSeedNodes.Except(seedNodes).ToList();
            var secondNotFirst = seedNodes.Except(targetSeedNodes).ToList();

            Assert.IsTrue(!firstNotSecond.Any() && !secondNotFirst.Any());

            Utility.RollForwardOneIteration(cluster);

            Assert.IsFalse(Utility.RunStateMachine(cluster));

            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
            Assert.AreEqual(SimpleClusterUpgradeTest.TargetConfigVersion, cluster.Current.CSMConfig.Version.Version);
        }
Exemple #8
0
        public void StandAloneRollForwardTestWithCustomdeserealization()
        {
            string            jsonFilePath          = "myClusterConfig.UnSecure.DevCluster.json";
            string            expectedConfigVersion = "1.0.0";
            StandAloneCluster cluster = Utility.PopulateStandAloneClusterWithBaselineJson(jsonFilePath);

            var defaultSerializedCluster = Utility.SerealizeUsingDefaults(cluster);

            cluster = Utility.DeserealizeUsingCustomDeserealizer(defaultSerializedCluster);

            Assert.IsTrue(Utility.RunStateMachine(cluster));

            defaultSerializedCluster = Utility.SerealizeUsingDefaults(cluster);
            cluster = Utility.DeserealizeUsingCustomDeserealizer(defaultSerializedCluster);

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(StandAloneBaselineUpgradeState));
            Assert.AreEqual(upgradeState.TargetCsmConfig.Version, cluster.Current.CSMConfig.Version);

            Utility.RollForwardOneIteration(cluster);

            defaultSerializedCluster = Utility.SerealizeUsingDefaults(cluster);
            cluster = Utility.DeserealizeUsingCustomDeserealizer(defaultSerializedCluster);

            Assert.IsFalse(Utility.RunStateMachine(cluster));

            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);

            Assert.AreEqual(expectedConfigVersion, cluster.Current.CSMConfig.Version.Version);
        }
Exemple #9
0
        public void StandAloneRollForwardTest()
        {
            string            jsonFilePath          = "myClusterConfig.UnSecure.DevCluster.json";
            string            expectedConfigVersion = "1.0.0";
            StandAloneCluster cluster = Utility.PopulateStandAloneClusterWithBaselineJson(jsonFilePath);

            Assert.IsTrue(Utility.RunStateMachine(cluster));

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(StandAloneBaselineUpgradeState));
            Assert.AreEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);
            var clusterManagerSection = cluster.Pending.ExternalState.ClusterManifest.FabricSettings.Single(section => section.Name.Equals(StringConstants.SectionName.ClusterManager));

            Assert.IsTrue(clusterManagerSection.Parameter.Any(param => param.Name == StringConstants.ParameterName.EnableAutomaticBaseline && param.Value == "True"));

            Utility.RollForwardOneIteration(cluster);

            Assert.IsFalse(Utility.RunStateMachine(cluster));

            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);

            Assert.AreEqual(expectedConfigVersion, cluster.Current.CSMConfig.Version.Version);
        }
        public void StandAloneCodeUpgradeOnlyRollBackTestUserSet()
        {
            StandAloneCluster cluster = Utility.DoBaselineUpgrade("ClusterConfig.Windows.MultiMachine.June2018.V1.json");

            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineConfigVersion, cluster.Current.CSMConfig.Version.Version);

            Utility.UpdateStandAloneCluster("ClusterConfig.Windows.MultiMachine.June2018.V2.json", cluster, true);

            Assert.IsTrue(Utility.RunStateMachine(cluster));

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(StandAloneSimpleClusterUpgradeState));
            Assert.AreNotEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);
            Assert.AreNotEqual(upgradeState.TargetWrpConfig.Version, cluster.Current.WRPConfig.Version);

            Utility.RollBackOneIteration(cluster);

            Assert.IsFalse(Utility.RunStateMachine(cluster));

            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
            Assert.AreNotEqual(SimpleClusterUpgradeTest.TargetMsiVersion, cluster.Current.WRPConfig.Version.MsiVersion);
            Assert.AreEqual(cluster.TargetNodeConfig, null);
            Assert.AreNotEqual(cluster.TargetWrpConfig, null);
            Assert.AreNotEqual(cluster.TargetCsmConfig, null);
            Assert.AreEqual(cluster.TargetCsmConfigUpgradeFailed, true);
            Assert.AreEqual(cluster.TargetWrpConfigUpgradeFailed, true);
        }
        public void StandAloneConfigOnlyRollBackTest()
        {
            StandAloneCluster cluster = Utility.DoBaselineUpgrade("myClusterConfig.UnSecure.DevCluster.json");

            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineConfigVersion, cluster.Current.CSMConfig.Version.Version);

            Utility.UpdateStandAloneCluster("myClusterConfig.UnSecure.DevClusterV2.json", cluster);

            Assert.IsTrue(Utility.RunStateMachine(cluster));

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(StandAloneSimpleClusterUpgradeState));
            Assert.AreNotEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);
            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);
            Assert.AreNotEqual(SimpleClusterUpgradeTest.TargetDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);

            Utility.RollBackOneIteration(cluster);

            Assert.IsFalse(Utility.RunStateMachine(cluster));

            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
            Assert.AreNotEqual(SimpleClusterUpgradeTest.TargetDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);

            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineConfigVersion, cluster.Current.CSMConfig.Version.Version);
        }
Exemple #12
0
        public void ConfigOnlyRollBackTest()
        {
            MockupCluster cluster = Utility.DoBaselineUpgrade("ClusterConfig.Unsecured.DevCluster.json");

            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineConfigVersion, cluster.Current.CSMConfig.Version.Version);

            Utility.UpdateCluster("ClusterConfig.Unsecured.DevClusterV2.json", cluster);

            Assert.IsTrue(cluster.RunStateMachine());

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(MockupSimpleClusterUpgradeState));
            Assert.AreNotEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);
            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);
            Assert.AreNotEqual(SimpleClusterUpgradeTest.TargetDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);

            Utility.RollBackOneIteration(cluster);

            Assert.IsFalse(cluster.RunStateMachine());

            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
            Assert.AreNotEqual(SimpleClusterUpgradeTest.TargetDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);
            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineConfigVersion, cluster.Current.CSMConfig.Version.Version);
            Assert.AreEqual(cluster.TargetNodeConfig, null);
            Assert.AreEqual(cluster.TargetWrpConfig, null);
            Assert.AreNotEqual(cluster.TargetCsmConfig, null);
            Assert.AreEqual(cluster.TargetCsmConfigUpgradeFailed, true);
            Assert.AreEqual(cluster.TargetWrpConfigUpgradeFailed, false);
        }
Exemple #13
0
        public void InterruptWithSimpleClusterUpgradeTest()
        {
            MockupCluster cluster = Utility.DoBaselineUpgrade("ClusterConfig.Unsecured.DevCluster.json");

            Utility.UpdateCluster("ClusterConfig.Unsecured.DevClusterV2.json", cluster);

            Assert.IsTrue(cluster.RunStateMachine());

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            //Interrupt with another simple cluster upgrade
            Utility.UpdateCluster("ClusterConfig.Unsecured.DevClusterV3.json", cluster);

            //Simple cluster upgrade can be interrupted
            Assert.IsTrue(cluster.RunStateMachine());

            Utility.RollForwardOneIteration(cluster);

            Assert.IsFalse(cluster.RunStateMachine());
            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);

            Assert.AreEqual(SimpleClusterUpgradeTest.InterruptedTargetDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);
            Assert.AreEqual(SimpleClusterUpgradeTest.InterruptedTargetConfigVersion, cluster.Current.CSMConfig.Version.Version);
            Assert.AreEqual(cluster.TargetNodeConfig, null);
            Assert.AreEqual(cluster.TargetWrpConfig, null);
            Assert.AreEqual(cluster.TargetCsmConfig, null);
            Assert.AreEqual(cluster.TargetCsmConfigUpgradeFailed, false);
            Assert.AreEqual(cluster.TargetWrpConfigUpgradeFailed, false);
        }
Exemple #14
0
        internal static void SetTargetReplicaSetSize(ClusterUpgradeStateBase upgradeState)
        {
            var targetReplicaSetSize = new Dictionary <string, ReplicaSetSize>()
            {
                { "", new ReplicaSetSize() }
            };
            StandAloneAutoScaleClusterUpgradeState autoScaleUpgradeState = (StandAloneAutoScaleClusterUpgradeState)upgradeState;

            autoScaleUpgradeState.TargetSystemServicesSize = new Dictionary <string, ReplicaSetSize>();
            autoScaleUpgradeState.GetSystemServiceReplicaSetSize(targetReplicaSetSize);
        }
Exemple #15
0
        public static bool ShouldReportUnhealthy(ClusterUpgradeStateBase upgradeState, UpgradeFlow currentUpgradeFlow, FaultInjectionConfig faultInjectionConfig)
        {
            MultiphaseClusterUpgradeState multiPhaseUpgradeState = upgradeState as MultiphaseClusterUpgradeState;
            int currentStep = 0;

            if (multiPhaseUpgradeState != null)
            {
                currentStep = multiPhaseUpgradeState.CurrentListIndex;
            }

            return(faultInjectionConfig.Equals(new FaultInjectionConfig(currentUpgradeFlow, currentStep)));
        }
Exemple #16
0
        public static UpgradeFlow GetUpgradeFlow(ClusterUpgradeStateBase upgradeState)
        {
            MultiphaseClusterUpgradeState multiPhaseUpgradeState = upgradeState as MultiphaseClusterUpgradeState;

            if (multiPhaseUpgradeState != null && multiPhaseUpgradeState.UpgradeUnsuccessful)
            {
                return(UpgradeFlow.RollingBack);
            }
            else
            {
                return(UpgradeFlow.RollingForward);
            }
        }
        public void StandAloneRollForwardWRPTest()
        {
            StandAloneCluster cluster = Utility.DoBaselineUpgrade("myClusterConfig.UnSecure.DevCluster.json");

            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineConfigVersion, cluster.Current.CSMConfig.Version.Version);

            Utility.UpdateStandAloneClusterWRPSettings("myClusterSettings.1.0.json", "1.0", cluster);

            Assert.IsTrue(Utility.RunStateMachine(cluster));

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(StandAloneSimpleClusterUpgradeState));
            Assert.AreNotEqual(upgradeState.TargetWrpConfig, cluster.Current.WRPConfig);
            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineAdminConfigClusterSettingsVersion, cluster.Current.WRPConfig.Version.ClusterSettingsVersion);

            Utility.RollForwardOneIteration(cluster);

            Assert.IsFalse(Utility.RunStateMachine(cluster));

            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
            Assert.AreEqual(SimpleClusterUpgradeTest.TargetAdminConfigClusterSettingsVersion, cluster.Current.WRPConfig.Version.ClusterSettingsVersion);
            Assert.AreEqual(cluster.TargetNodeConfig, null);
            Assert.AreEqual(cluster.TargetWrpConfig, null);
            Assert.AreEqual(cluster.TargetCsmConfig, null);
            Assert.AreEqual(cluster.TargetCsmConfigUpgradeFailed, false);
            Assert.AreEqual(cluster.TargetWrpConfigUpgradeFailed, false);

            // Perform simple upgrade after WRP upgrade
            Utility.UpdateStandAloneCluster("myClusterConfig.UnSecure.DevClusterV2.json", cluster);

            Assert.IsTrue(Utility.RunStateMachine(cluster));

            upgradeState = cluster.Pending;
            Assert.IsInstanceOfType(upgradeState, typeof(StandAloneSimpleClusterUpgradeState));
            Assert.AreNotEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);
            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);
            Assert.AreNotEqual(SimpleClusterUpgradeTest.TargetDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);

            Utility.RollForwardOneIteration(cluster);

            Assert.IsFalse(Utility.RunStateMachine(cluster));

            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
            Assert.AreEqual(SimpleClusterUpgradeTest.TargetDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);

            Assert.AreEqual(SimpleClusterUpgradeTest.TargetConfigVersion, cluster.Current.CSMConfig.Version.Version);
        }
        internal async Task <bool> IsInterruptibleAsync(ClusterUpgradeStateBase clusterUpgradeState)
        {
            if (!clusterUpgradeState.CanInterruptUpgrade())
            {
                return(false);
            }

            FabricUpgradeProgress fabricUpgradeProgress = await FabricClientRetryHelper.ExecuteFabricActionWithRetryAsync(
                () =>
                this.fabricClient.ClusterManager.GetFabricUpgradeProgressAsync(Constants.UpgradeServiceMaxOperationTimeout, this.cancellationToken),
                Constants.UpgradeServiceMaxOperationTimeout,
                this.cancellationToken).ConfigureAwait(false);

            return(fabricUpgradeProgress.UpgradeState != FabricUpgradeState.RollingBackInProgress);
        }
        public void StandAloneCodeUpgradeIsNotInterruptiple()
        {
            StandAloneCluster cluster = Utility.DoBaselineUpgrade("ClusterConfig.Windows.MultiMachine.June2018.V1.json");

            Assert.AreEqual(SimpleClusterUpgradeTest.BaselineConfigVersion, cluster.Current.CSMConfig.Version.Version);

            Utility.UpdateStandAloneCluster("ClusterConfig.Windows.MultiMachine.June2018.V2.json", cluster, true);

            Assert.IsTrue(Utility.RunStateMachine(cluster));

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(StandAloneSimpleClusterUpgradeState));
            Assert.IsFalse(upgradeState.CanInterruptUpgrade());
        }
Exemple #20
0
        public void StandAloneIsSingletonReplicaMoveAllowedDuringUpgradeTestMultiNode()
        {
            string            jsonFilePath = "ClusterConfig.UnSecure.DevCluster.json";
            StandAloneCluster cluster      = Utility.PopulateStandAloneClusterWithBaselineJson(jsonFilePath);

            Assert.IsTrue(Utility.RunStateMachine(cluster));

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(StandAloneBaselineUpgradeState));
            Assert.AreEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);

            string isSingletonReplicaMoveAllowedDuringUpgradeTest = cluster.Current.ExternalState.ClusterManifest.FabricSettings.First(
                section => section.Name == StringConstants.SectionName.FailoverManager).Parameter.First(
                param => param.Name == StringConstants.ParameterName.IsSingletonReplicaMoveAllowedDuringUpgrade).Value;

            Assert.AreEqual("True", isSingletonReplicaMoveAllowedDuringUpgradeTest);
        }
        public void InterruptWithScaleUpClusterUpgradeTest()
        {
            string        jsonFilePath = "ClusterConfig.Unsecured.DevCluster.json";
            MockupCluster cluster      = Utility.PopulateClusterWithBaselineJson(jsonFilePath);

            Assert.IsTrue(cluster.RunStateMachine());

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(MockupBaselineUpgradeState));
            Assert.AreEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);

            //User starts a scale up cluster upgrade.
            Utility.UpdateCluster("ClusterConfig.Unsecured.DevCluster.ScaleUp.json", cluster);

            //Baseline upgrade can't be interrupted.
            Assert.IsFalse(cluster.RunStateMachine());
        }
Exemple #22
0
        public void StandAloneRollBackTest()
        {
            string            jsonFilePath = "myClusterConfig.UnSecure.DevCluster.json";
            StandAloneCluster cluster      = Utility.PopulateStandAloneClusterWithBaselineJson(jsonFilePath);

            Assert.IsTrue(Utility.RunStateMachine(cluster));

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(StandAloneBaselineUpgradeState));
            Assert.AreEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);

            Utility.RollBackOneIteration(cluster);

            // baseline upgrade failure results in retry
            Assert.IsFalse(Utility.RunStateMachine(cluster));

            Assert.IsNotNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
        }
Exemple #23
0
        public void RollbackTest()
        {
            MockupCluster cluster = Utility.DoBaselineUpgrade("ClusterConfig.Unsecured.DevCluster.json");

            Utility.UpdateCluster("ClusterConfig.Unsecured.DevCluster.AutoScale.V2.json", cluster);

            Assert.IsTrue(cluster.RunStateMachine());

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Utility.RollBackOneIteration(cluster);
            Assert.IsFalse(cluster.RunStateMachine());
            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);

            cluster.TargetCsmConfigUpgradeFailed = false;
            cluster.TargetCsmConfig  = null;
            cluster.TargetNodeConfig = null;
            Utility.UpdateCluster("ClusterConfig.Unsecured.DevCluster.AutoScale.V2.json", cluster);
            Assert.IsTrue(cluster.RunStateMachine());
            upgradeState = cluster.Pending;
            Utility.RollForwardOneIteration(cluster);

            upgradeState = cluster.Pending;
            var targetReplicaSetSize = new Dictionary <string, ReplicaSetSize>()
            {
                { "", new ReplicaSetSize() }
            };
            MockupAutoScaleClusterUpgradeState scaleUpUpgradeState = (MockupAutoScaleClusterUpgradeState)upgradeState;

            scaleUpUpgradeState.TargetSystemServicesSize = new Dictionary <string, ReplicaSetSize>();
            scaleUpUpgradeState.GetSystemServiceReplicaSetSize(targetReplicaSetSize);

            Utility.RollForwardOneIteration(cluster);

            Assert.IsFalse(cluster.RunStateMachine());
            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
            Assert.AreEqual(AutoScaleClusterUpgradeTest.TargetVMInstanceCount, cluster.Current.CSMConfig.NodeTypes[0].VMInstanceCount);
            Assert.AreEqual(AutoScaleClusterUpgradeTest.BaselineConfigVersion, cluster.Current.CSMConfig.Version.Version);
        }
Exemple #24
0
        public void RollForwardTest()
        {
            MockupCluster cluster = Utility.DoBaselineUpgrade("ClusterConfig.Unsecured.DevCluster.json");

            Assert.AreEqual(AutoScaleClusterUpgradeTest.BaselineVMInstanceCount, cluster.Current.CSMConfig.NodeTypes[0].VMInstanceCount);

            Utility.UpdateCluster("ClusterConfig.Unsecured.DevCluster.AutoScale.V2.json", cluster);

            Assert.IsTrue(cluster.RunStateMachine());

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(MockupAutoScaleClusterUpgradeState));
            Assert.AreNotEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);

            //Need to set targetReplicaSetSize to an empty dictionary, in order to get the system think the replica set size is updated.
            //Otherwise VerifyTargetSystemServicesReplicaSetSize() will fail.

            var targetReplicaSetSize = new Dictionary <string, ReplicaSetSize>()
            {
                { "", new ReplicaSetSize() }
            };

            MockupAutoScaleClusterUpgradeState scaleUpUpgradeState = (MockupAutoScaleClusterUpgradeState)upgradeState;

            scaleUpUpgradeState.TargetSystemServicesSize = new Dictionary <string, ReplicaSetSize>();

            scaleUpUpgradeState.GetSystemServiceReplicaSetSize(targetReplicaSetSize);

            Utility.RollForwardOneIteration(cluster);

            upgradeState = (MockupAutoScaleClusterUpgradeState)cluster.Pending;

            Utility.RollForwardOneIteration(cluster);

            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
            Assert.AreEqual(AutoScaleClusterUpgradeTest.TargetVMInstanceCount, cluster.Current.CSMConfig.NodeTypes[0].VMInstanceCount);
            Assert.AreEqual(AutoScaleClusterUpgradeTest.BaselineConfigVersion, cluster.Current.CSMConfig.Version.Version);
        }
        public void RollForwardTest()
        {
            string        jsonFilePath          = "ClusterConfig.Unsecured.DevCluster.json";
            string        expectedConfigVersion = "1.0.0";
            MockupCluster cluster = Utility.PopulateClusterWithBaselineJson(jsonFilePath);

            Assert.IsTrue(cluster.RunStateMachine());

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(MockupBaselineUpgradeState));
            Assert.AreEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);

            Utility.RollForwardOneIteration(cluster);

            Assert.IsFalse(cluster.RunStateMachine());

            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);

            Assert.AreEqual(expectedConfigVersion, cluster.Current.CSMConfig.Version.Version);
        }
Exemple #26
0
        public void SimpleConfigUpgradeInterruptWithSimpleCodeUpgrade()
        {
            MockupCluster cluster = Utility.DoBaselineUpgrade("ClusterConfig.Unsecured.DevCluster.json");

            Utility.UpdateCluster("ClusterConfig.Unsecured.DevClusterV2.json", cluster);

            Assert.IsTrue(cluster.RunStateMachine());

            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(MockupSimpleClusterUpgradeState));

            //Interrupt
            Utility.UpdateCluster(cluster, SimpleClusterUpgradeTest.TargetMsiVersion, SimpleClusterUpgradeTest.TargetClusterSettingsVersion);
            Assert.IsFalse(cluster.RunStateMachine());
            upgradeState = cluster.Pending;
            Assert.IsInstanceOfType(upgradeState, typeof(MockupSimpleClusterUpgradeState));

            Utility.RollForwardOneIteration(cluster);

            Assert.AreEqual(SimpleClusterUpgradeTest.TargetDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);
            Assert.AreEqual(SimpleClusterUpgradeTest.TargetConfigVersion, cluster.Current.CSMConfig.Version.Version);

            Assert.IsFalse(cluster.RunStateMachine());

            Utility.RollForwardOneIteration(cluster);

            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
            Assert.AreEqual(SimpleClusterUpgradeTest.TargetMsiVersion, cluster.Current.WRPConfig.Version.MsiVersion);
            Assert.AreEqual(SimpleClusterUpgradeTest.TargetClusterSettingsVersion, cluster.Current.WRPConfig.Version.ClusterSettingsVersion);
            Assert.AreEqual(cluster.TargetNodeConfig, null);
            Assert.AreEqual(cluster.TargetWrpConfig, null);
            Assert.AreEqual(cluster.TargetCsmConfig, null);
            Assert.AreEqual(cluster.TargetCsmConfigUpgradeFailed, false);
            Assert.AreEqual(cluster.TargetWrpConfigUpgradeFailed, false);
        }
Exemple #27
0
        public void InterruptWithSimpleCodeClusterUpgradeTest()
        {
            MockupCluster cluster = Utility.DoBaselineUpgrade("ClusterConfig.Unsecured.DevCluster.json");

            Utility.UpdateCluster(cluster, SimpleClusterUpgradeTest.TargetMsiVersion, SimpleClusterUpgradeTest.TargetClusterSettingsVersion);
            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Utility.UpdateCluster(cluster, InterruptedTargetMsiVersion, InterruptedTargetClusterSettingsVersion);
            Assert.IsTrue(cluster.RunStateMachine());

            Utility.RollForwardOneIteration(cluster);

            Assert.IsFalse(cluster.RunStateMachine());

            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
            Assert.AreEqual(SimpleClusterUpgradeTest.InterruptedTargetMsiVersion, cluster.Current.WRPConfig.Version.MsiVersion);
            Assert.AreEqual(SimpleClusterUpgradeTest.InterruptedTargetClusterSettingsVersion, cluster.Current.WRPConfig.Version.ClusterSettingsVersion);
            Assert.AreEqual(cluster.TargetNodeConfig, null);
            Assert.AreEqual(cluster.TargetWrpConfig, null);
            Assert.AreEqual(cluster.TargetCsmConfig, null);
            Assert.AreEqual(cluster.TargetCsmConfigUpgradeFailed, false);
            Assert.AreEqual(cluster.TargetWrpConfigUpgradeFailed, false);
        }
        public void ClusterManifestBuilderTest()
        {
            StandAloneCluster   cluster;
            ClusterManifestType manifest;

            string[] noAddonJsonFiles = new string[]
            {
                TestFiles.GAv1,
                TestFiles.Jan2017v1,
                TestFiles.April2017NoAddon,
                TestFiles.May2017NoAddon,
                TestFiles.Aug2017NoAddon,
                TestFiles.Oct2017NoAddon
            };

            foreach (string jsonFile in noAddonJsonFiles)
            {
                cluster  = this.InitializeBaselineUpgrade(jsonFile);
                manifest = cluster.Pending.ExternalState.ClusterManifest;
                Assert.IsFalse(manifest.FabricSettings.Any(
                                   section => section.Name.Equals(StringConstants.SectionName.RepairManager, StringComparison.OrdinalIgnoreCase) ||
                                   section.Name.Equals(StringConstants.SectionName.DnsService, StringComparison.OrdinalIgnoreCase) ||
                                   section.Name.Equals(StringConstants.SectionName.BackupRestoreService, StringComparison.OrdinalIgnoreCase)));
            }

            // verify RM/ DnsSvc
            Dictionary <string, int> addOnJsonFiles = new Dictionary <string, int>()
            {
                { TestFiles.April2017HasAddon, 1 },
                { TestFiles.April2017HasAddonMultipleBox, -1 },
                { TestFiles.May2017HasAddon, 1 },
                { TestFiles.May2017HasAddonMultipleBox, -1 },
            };

            foreach (KeyValuePair <string, int> addOnJsonFile in addOnJsonFiles)
            {
                cluster  = this.InitializeBaselineUpgrade(addOnJsonFile.Key);
                manifest = cluster.Pending.ExternalState.ClusterManifest;
                this.VerifyRepairManagerSection(manifest.FabricSettings.Single(section => section.Name.Equals(StringConstants.SectionName.RepairManager)));
                this.VerifyDnsServiceSection(manifest.FabricSettings.Single(section => section.Name.Equals(StringConstants.SectionName.DnsService)), addOnJsonFile.Value);
            }

            // verify RM/ DnsSvc/ BackupRestoreSvc
            addOnJsonFiles = new Dictionary <string, int>()
            {
                { TestFiles.Aug2017HasAddon, 1 },
                { TestFiles.Aug2017HasAddonMultipleBox, -1 },
                { TestFiles.Oct2017HasAddon, 1 },
                { TestFiles.Oct2017HasAddonMultipleBox, -1 }
            };

            foreach (KeyValuePair <string, int> addOnJsonFile in addOnJsonFiles)
            {
                cluster  = this.InitializeBaselineUpgrade(addOnJsonFile.Key);
                manifest = cluster.Pending.ExternalState.ClusterManifest;
                this.VerifyRepairManagerSection(manifest.FabricSettings.Single(section => section.Name.Equals(StringConstants.SectionName.RepairManager)));
                this.VerifyBackupRestoreServiceSection(manifest.FabricSettings.Single(section => section.Name.Equals(StringConstants.SectionName.BackupRestoreService)));
                this.VerifyDnsServiceSection(manifest.FabricSettings.Single(section => section.Name.Equals(StringConstants.SectionName.DnsService)), addOnJsonFile.Value);
            }

            // verify upgrade
            cluster = Utility.DoBaselineUpgrade(TestFiles.April2017NoAddon);
            Utility.UpdateStandAloneCluster(TestFiles.April2017NoAddonV2, cluster);
            Assert.IsTrue(Utility.RunStateMachine(cluster));
            ClusterUpgradeStateBase upgradeState = cluster.Pending;

            Assert.IsInstanceOfType(upgradeState, typeof(StandAloneSimpleClusterUpgradeState));
            Assert.AreNotEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);
            Utility.RollForwardOneIteration(cluster);
            Assert.IsFalse(Utility.RunStateMachine(cluster));
            Assert.IsNull(cluster.Pending);
            manifest = cluster.Current.ExternalState.ClusterManifest;
            this.VerifyRepairManagerSection(manifest.FabricSettings.Single(section => section.Name.Equals(StringConstants.SectionName.RepairManager)));

            // simulate the scenario that customer 'partially' enabled RM due to the regression introduced in 6.0
            var rmSection = manifest.FabricSettings.Single(section => section.Name.Equals(StringConstants.SectionName.RepairManager));

            rmSection.Parameter    = new SettingsOverridesTypeSectionParameter[1];
            rmSection.Parameter[0] = new SettingsOverridesTypeSectionParameter()
            {
                Name  = StringConstants.ParameterName.EnableHealthChecks,
                Value = "True"
            };

            Utility.UpdateStandAloneCluster(TestFiles.April2017NoAddonV3, cluster);
            Assert.IsTrue(Utility.RunStateMachine(cluster));
            upgradeState = cluster.Pending;
            Assert.IsInstanceOfType(upgradeState, typeof(StandAloneSimpleClusterUpgradeState));
            Assert.AreNotEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);
            Utility.RollForwardOneIteration(cluster);
            Assert.IsFalse(Utility.RunStateMachine(cluster));
            Assert.IsNull(cluster.Pending);
            manifest = cluster.Current.ExternalState.ClusterManifest;
            this.VerifyRepairManagerSection(manifest.FabricSettings.Single(section => section.Name.Equals(StringConstants.SectionName.RepairManager)));
        }