예제 #1
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);
        }
예제 #2
0
        /** Update the CSM config of a cluster */
        internal static void UpdateCluster(string targetJsonFilePath, MockupCluster existingCluster)
        {
            MockupJsonModel targetJsonConfig = Utility.GetJsonConfigFromFile(Path.Combine(Constant.TestDirectory, targetJsonFilePath));

            existingCluster.TargetCsmConfig = targetJsonConfig.GetUserConfig();
            existingCluster.Topology        = targetJsonConfig.GetClusterTopology();
        }
예제 #3
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);
        }
예제 #4
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);
        }
        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);
        }
예제 #6
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());
        }
예제 #7
0
        internal void InternalUpdateCertificateTest(string v1clusterConfigPath, string v2clusterConfigPath, string[] targetClusterManifests)
        {
            MockupJsonModel jsonConfig = Utility.GetJsonConfigFromFile(Path.Combine(Constant.TestDirectory, v1clusterConfigPath));

            var userConfig      = jsonConfig.GetUserConfig();
            var clusterTopology = jsonConfig.GetClusterTopology();
            var adminConfig     = new MockupAdminConfig();
            var logger          = new MockupTraceLogger();

            List <NodeStatus> nodesStatus = new List <NodeStatus>();

            foreach (NodeDescription node in clusterTopology.Nodes.Values)
            {
                NodeStatus nodeStatus = new NodeStatus()
                {
                    NodeName               = node.NodeName,
                    InstanceId             = 0,
                    NodeDeactivationIntent = WrpNodeDeactivationIntent.Invalid,
                    NodeState              = NodeState.Enabled,
                    NodeType               = node.NodeTypeRef
                };

                nodesStatus.Add(nodeStatus);
            }

            MockupCluster clusterResource = new MockupCluster(adminConfig, userConfig, clusterTopology, logger);
            MockupClusterManifestBuilder v1mockupClusterManifestBuilder = new MockupClusterManifestBuilder(
                clusterTopology,
                clusterResource.SeedNodeSelector,
                userConfig,
                adminConfig,
                new ClusterNodeConfig(nodesStatus, 2),
                new MockupManifestVersionGenerator(),
                clusterResource.FabricSettingsActivator,
                clusterResource.ClusterManifestGeneratorSettings,
                new MockupTraceLogger());

            MockupJsonModel v2JsonConfig = Utility.GetJsonConfigFromFile(Path.Combine(Constant.TestDirectory, v2clusterConfigPath));
            var             v2generatedClusterManifests = v1mockupClusterManifestBuilder.UpdateCertificateInClusterManifest(v1mockupClusterManifestBuilder.GenerateClusterManifest(), v2JsonConfig.Properties.Security, new MockupAdminConfig().GetFabricSettingsMetadata());

            XmlSerializer xmlSerializer = new XmlSerializer(typeof(ClusterManifestType));

            int i = 0;

            foreach (string path in targetClusterManifests)
            {
                StringWriter generatedClusterManifestWriter = new StringWriter();
                xmlSerializer.Serialize(generatedClusterManifestWriter, v2generatedClusterManifests[i++]);
                string generatedClusterManifestString = generatedClusterManifestWriter.ToString();

                var          targetClusterManifest       = System.Fabric.Interop.Utility.ReadXml <ClusterManifestType>(Path.Combine(Constant.TestDirectory, path), SchemaLocation.GetWindowsFabricSchemaLocation());
                StringWriter targetClusterManifestWriter = new StringWriter();
                xmlSerializer.Serialize(targetClusterManifestWriter, targetClusterManifest);
                string targetClusterManifestString = targetClusterManifestWriter.ToString();

                Assert.AreEqual(Utility.RemoveRandomGuid(generatedClusterManifestString), Utility.RemoveRandomGuid(targetClusterManifestString));
            }
        }
예제 #8
0
        internal void InternalRemoveCertTest(string baselineJsonFile, string targetJsonFile)
        {
            MockupCluster cluster = Utility.DoBaselineUpgrade(baselineJsonFile);

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

            Utility.UpdateCluster(targetJsonFile, cluster);

            string originalPrimaryThumbprint   = cluster.Current.CSMConfig.Security.CertificateInformation.ClusterCertificate.Thumbprint;
            string originalSecondaryThumbprint = cluster.Current.CSMConfig.Security.CertificateInformation.ClusterCertificate.ThumbprintSecondary;
            string newPrimaryThumbprint        = cluster.TargetCsmConfig.Security.CertificateInformation.ClusterCertificate.Thumbprint;
            bool   removePrimarythumbprint     = originalPrimaryThumbprint != newPrimaryThumbprint;

            // 1st iteration
            Assert.IsTrue(cluster.RunStateMachine());

            MockupCertificateClusterUpgradeState upgradeState = (MockupCertificateClusterUpgradeState)cluster.Pending;

            this.VerifyManifestRemoveCertLists(
                cluster.Pending.ExternalState.ClusterManifest,
                originalPrimaryThumbprint,
                originalSecondaryThumbprint,
                removePrimarythumbprint,
                upgradeState.CurrentListIndex);

            Assert.AreEqual(ClusterCertificateUpgradeTest.BaselineDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);
            Assert.AreNotEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);
            Assert.IsNotNull(cluster.Current);

            Utility.RollForwardOneIteration(cluster);

            // 2nd iteration
            Assert.IsFalse(cluster.RunStateMachine());
            upgradeState = (MockupCertificateClusterUpgradeState)cluster.Pending;
            this.VerifyManifestRemoveCertLists(
                cluster.Pending.ExternalState.ClusterManifest,
                originalPrimaryThumbprint,
                originalSecondaryThumbprint,
                removePrimarythumbprint,
                upgradeState.CurrentListIndex);

            Assert.AreNotEqual(upgradeState.TargetCsmConfig, cluster.Current.CSMConfig);
            Assert.IsNotNull(cluster.Current);

            Utility.RollForwardOneIteration(cluster);

            // final check
            Assert.IsFalse(cluster.RunStateMachine());

            this.VerifyJsonRemoveCertLists(
                cluster.Current.CSMConfig,
                originalPrimaryThumbprint,
                originalSecondaryThumbprint,
                removePrimarythumbprint);

            Assert.AreEqual(ClusterCertificateUpgradeTest.TargetDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);
            Assert.AreEqual(ClusterCertificateUpgradeTest.TargetConfigVersion, cluster.Current.CSMConfig.Version.Version);
        }
예제 #9
0
        public void InterruptWithSimpleClusterUpgradeAtSecondIteration()
        {
            MockupCluster cluster = Utility.DoBaselineUpgrade("ClusterConfig.X509.DevCluster.Replace.V1.json");

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

            Utility.UpdateCluster("ClusterConfig.X509.DevCluster.Replace.V2.json", cluster);

            string originalThumbprint = cluster.Current.CSMConfig.Security.CertificateInformation.ClusterCertificate.Thumbprint;
            string newThumbprint      = cluster.TargetCsmConfig.Security.CertificateInformation.ClusterCertificate.Thumbprint;

            // 1st iteration
            Assert.IsTrue(cluster.RunStateMachine());

            MockupCertificateClusterUpgradeState upgradeState = (MockupCertificateClusterUpgradeState)cluster.Pending;

            this.VerifyManifestReplaceCertLists(
                cluster.Pending.ExternalState.ClusterManifest,
                originalThumbprint,
                newThumbprint,
                upgradeState.CurrentListIndex);

            Utility.RollForwardOneIteration(cluster);

            // 2nd iteration
            Assert.IsFalse(cluster.RunStateMachine());
            upgradeState = (MockupCertificateClusterUpgradeState)cluster.Pending;
            this.VerifyManifestReplaceCertLists(
                cluster.Pending.ExternalState.ClusterManifest,
                originalThumbprint,
                newThumbprint,
                upgradeState.CurrentListIndex);

            Utility.UpdateCluster("ClusterConfig.X509.DevCluster.Replace.V2.Interrupt.json", cluster);
            Assert.IsFalse(cluster.RunStateMachine());

            Utility.RollForwardOneIteration(cluster);

            //3rd iteration
            Assert.IsFalse(cluster.RunStateMachine());
            upgradeState = (MockupCertificateClusterUpgradeState)cluster.Pending;
            this.VerifyManifestReplaceCertLists(
                cluster.Pending.ExternalState.ClusterManifest,
                originalThumbprint,
                newThumbprint,
                upgradeState.CurrentListIndex);

            Utility.RollForwardOneIteration(cluster);

            // final check
            Assert.IsFalse(cluster.RunStateMachine());

            this.VerifyJsonReplaceCertLists(cluster.Current.CSMConfig, originalThumbprint, newThumbprint);

            Assert.AreEqual(ClusterCertificateUpgradeTest.TargetDataDeletionAgeInDays, cluster.Current.CSMConfig.DiagnosticsStoreInformation.DataDeletionAgeInDays);
            Assert.AreEqual(ClusterCertificateUpgradeTest.TargetConfigVersion, cluster.Current.CSMConfig.Version.Version);
        }
예제 #10
0
        internal void InternalReplaceCertRollbackTest(int maxSuccessIteration, bool rollbackSuccess)
        {
            Assert.IsTrue(maxSuccessIteration < 2);

            MockupCluster cluster = Utility.DoBaselineUpgrade("ClusterConfig.X509.DevCluster.Replace.V1.json");

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

            ClusterManifestType baselineClusterManifest = cluster.Current.ExternalState.ClusterManifest;

            Utility.UpdateCluster("ClusterConfig.X509.DevCluster.Replace.V2.json", cluster);
            Assert.IsTrue(cluster.RunStateMachine());

            if (maxSuccessIteration < 0)
            {
                Utility.RollBackOneIteration(cluster);
                Assert.IsFalse(cluster.RunStateMachine());
                Assert.IsNull(cluster.Pending);
                Assert.AreEqual(baselineClusterManifest, cluster.Current.ExternalState.ClusterManifest);
            }
            else
            {
                for (int i = 0; i <= maxSuccessIteration; i++)
                {
                    Utility.RollForwardOneIteration(cluster);
                    Assert.AreEqual(baselineClusterManifest, cluster.Current.ExternalState.ClusterManifest);
                    Assert.IsFalse(cluster.RunStateMachine());
                }

                Utility.RollBackOneIteration(cluster);
                Assert.IsFalse(cluster.RunStateMachine());
                ClusterManifestType expectedManifest = maxSuccessIteration == 0 ? baselineClusterManifest : ((MultiphaseClusterUpgradeState)cluster.Pending).ClusterManifestList[maxSuccessIteration - 1];
                Assert.AreEqual(expectedManifest, cluster.Pending.ExternalState.ClusterManifest);

                if (rollbackSuccess)
                {
                    for (int i = 0; i <= maxSuccessIteration; i++)
                    {
                        Utility.RollForwardOneIteration(cluster);
                        Assert.IsFalse(cluster.RunStateMachine());
                    }

                    Assert.IsNull(cluster.Pending);
                }
                else
                {
                    Utility.RollBackOneIteration(cluster);
                    Assert.IsFalse(cluster.RunStateMachine());
                    Assert.IsNotNull(cluster.Pending);
                }

                Assert.AreEqual(baselineClusterManifest, cluster.Current.ExternalState.ClusterManifest);
            }
        }
예제 #11
0
        internal static MockupCluster DoBaselineUpgrade(string jsonFilePath)
        {
            MockupCluster result = Utility.PopulateClusterWithBaselineJson(jsonFilePath);

            Assert.IsTrue(result.RunStateMachine());
            Utility.RollForwardOneIteration(result);
            Assert.IsFalse(result.RunStateMachine());
            Assert.IsNull(result.Pending);
            Assert.IsNotNull(result.Current);

            return(result);
        }
예제 #12
0
        internal void InternalTwoPhaseRollbackTest(
            string baselineJsonFile,
            string targetJsonFile,
            bool firstIterationSuccess,
            bool rollbackSuccess)
        {
            MockupCluster cluster = Utility.DoBaselineUpgrade(baselineJsonFile);

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

            ClusterManifestType baselineClusterManifest = cluster.Current.ExternalState.ClusterManifest;

            Utility.UpdateCluster(targetJsonFile, cluster);
            Assert.IsTrue(cluster.RunStateMachine());

            if (!firstIterationSuccess)
            {
                Utility.RollBackOneIteration(cluster);
                Assert.IsFalse(cluster.RunStateMachine());
                Assert.IsNull(cluster.Pending);
                Assert.AreEqual(baselineClusterManifest, cluster.Current.ExternalState.ClusterManifest);
            }
            else
            {
                Utility.RollForwardOneIteration(cluster);
                Assert.AreEqual(baselineClusterManifest, cluster.Current.ExternalState.ClusterManifest);

                Assert.IsFalse(cluster.RunStateMachine());
                Utility.RollBackOneIteration(cluster);
                Assert.IsFalse(cluster.RunStateMachine());
                Assert.AreEqual(baselineClusterManifest, cluster.Pending.ExternalState.ClusterManifest);

                if (rollbackSuccess)
                {
                    Utility.RollForwardOneIteration(cluster);
                    Assert.IsFalse(cluster.RunStateMachine());
                    Assert.IsNull(cluster.Pending);
                }
                else
                {
                    Utility.RollBackOneIteration(cluster);
                    Assert.IsFalse(cluster.RunStateMachine());
                    Assert.IsNotNull(cluster.Pending);
                }

                Assert.AreEqual(baselineClusterManifest, cluster.Current.ExternalState.ClusterManifest);
            }
        }
        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());
        }
예제 #14
0
        public void InterruptWithSimpleClusterUpgradeAtFirstIteration()
        {
            MockupCluster cluster = Utility.DoBaselineUpgrade("ClusterConfig.X509.DevCluster.Replace.V1.json");

            Utility.UpdateCluster("ClusterConfig.X509.DevCluster.Replace.V2.json", cluster);

            // 1st iteration
            Assert.IsTrue(cluster.RunStateMachine());
            MockupCertificateClusterUpgradeState upgradeState = (MockupCertificateClusterUpgradeState)cluster.Pending;

            //Interrupt with a simple cluster upgrade
            Utility.UpdateCluster("ClusterConfig.X509.DevCluster.Replace.V2.Interrupt.json", cluster);
            Assert.IsTrue(cluster.RunStateMachine());

            Utility.RollForwardOneIteration(cluster);

            Assert.IsFalse(cluster.RunStateMachine());
            Assert.AreEqual(ClusterCertificateUpgradeTest.InterruptedTargetConfigVersion, cluster.Current.CSMConfig.Version.Version);
        }
예제 #15
0
        internal void InternalGenerateClusterManifestTest(string clusterConfigPath, string clusterManifestPath)
        {
            MockupJsonModel jsonConfig = Utility.GetJsonConfigFromFile(Path.Combine(Constant.TestDirectory, clusterConfigPath));

            var userConfig      = jsonConfig.GetUserConfig();
            var clusterTopology = jsonConfig.GetClusterTopology();
            var adminConfig     = new MockupAdminConfig();
            var logger          = new MockupTraceLogger();

            List <NodeStatus> nodesStatus = new List <NodeStatus>();

            foreach (NodeDescription node in clusterTopology.Nodes.Values)
            {
                NodeStatus nodeStatus = new NodeStatus()
                {
                    NodeName               = node.NodeName,
                    InstanceId             = 0,
                    NodeDeactivationIntent = WrpNodeDeactivationIntent.Invalid,
                    NodeState              = NodeState.Enabled,
                    NodeType               = node.NodeTypeRef
                };

                nodesStatus.Add(nodeStatus);
            }

            MockupCluster clusterResource = new MockupCluster(adminConfig, userConfig, clusterTopology, logger);
            MockupClusterManifestBuilder mockupClusterManifestBuilder = new MockupClusterManifestBuilder(
                clusterTopology,
                clusterResource.SeedNodeSelector,
                userConfig,
                adminConfig,
                new ClusterNodeConfig(nodesStatus, 2),
                new MockupManifestVersionGenerator(),
                clusterResource.FabricSettingsActivator,
                clusterResource.ClusterManifestGeneratorSettings,
                new MockupTraceLogger());

            var generatedClusterManifest = mockupClusterManifestBuilder.GenerateClusterManifest();
            var expectedClusterManifest  = System.Fabric.Interop.Utility.ReadXml <ClusterManifestType>(Path.Combine(Constant.TestDirectory, clusterManifestPath), SchemaLocation.GetWindowsFabricSchemaLocation());

            Assert.AreEqual(Utility.RemoveRandomGuid(Utility.GetClusterManifestXMLString(generatedClusterManifest)), Utility.RemoveRandomGuid(Utility.GetClusterManifestXMLString(expectedClusterManifest)));
        }
        public void RollBackTest()
        {
            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);

            Utility.RollBackOneIteration(cluster);

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

            Assert.IsNotNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
        }
예제 #17
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);
        }
예제 #18
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);
        }
예제 #20
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);
        }
예제 #21
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);
        }
예제 #22
0
 internal static void RollForwardOneIteration(MockupCluster cluster)
 {
     cluster.ClusterUpgradeCompleted();
 }
예제 #23
0
 /** Update the WRP config of a cluster */
 internal static void UpdateCluster(MockupCluster existingCluster, string msiVersion, string clusterSettingsVersion, bool isUserSet = false)
 {
     existingCluster.TargetWrpConfig         = new MockupAdminConfig(isUserSet);
     existingCluster.TargetWrpConfig.Version = new AdminConfigVersion(msiVersion, clusterSettingsVersion);
 }