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);
        }
Esempio n. 2
0
        public async Task <StandAloneCluster> GetClusterResourceAsync(string key, CancellationToken cancellationToken)
        {
            StandAloneCluster cluster = null;
            var clusterStateTable     = await this.stateManager.GetOrAddAsync <IReliableDictionary <string, string> >(Constants.ClusterReliableDictionaryName);

            try
            {
                using (var tx = this.stateManager.CreateTransaction())
                {
                    UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Start transaction inside GetClusterResourceAsync.");

                    var data = await clusterStateTable.TryGetValueAsync(tx, key, Constants.DefaultDictionaryTimeout, cancellationToken).ConfigureAwait(false);

                    if (data.HasValue)
                    {
                        UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Found persisted cluster resource. Deserializing it.");
                        cluster = DeserializeClusterResource(data.Value);
                    }
                }

                UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Exit transaction inside GetClusterResourceAsync.");
            }
            catch (Exception e)
            {
                UpgradeOrchestrationTrace.TraceSource.WriteWarning(TraceType, "GetClusterResourceAsync: {0}", e.ToString());
                throw;
            }

            return(cluster);
        }
        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);
        }
        public async Task <string> ProcessSetUpgradeOrchestrationServiceStateAsync(string inputBlob, TimeSpan timeout, CancellationToken cancellationToken)
        {
            UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Entering ProcessSetUpgradeOrchestrationServiceStateAsync.");
            try
            {
                // data validation
                StandAloneCluster cluster = null;
                if (!string.IsNullOrWhiteSpace(inputBlob))
                {
                    JsonSerializerSettings settings = StandaloneUtility.GetStandAloneClusterDeserializerSettings();

                    cluster = JsonConvert.DeserializeObject <StandAloneCluster>(
                        inputBlob,
                        settings);
                }

                await this.storeManager.SetStorageObjectAsync(Constants.ClusterReliableDictionaryKey, inputBlob, this.cancellationToken).ConfigureAwait(false);

                FabricUpgradeOrchestrationServiceState result = UpgradeOrchestrationMessageProcessor.ConstructServiceStateFromCluster(cluster);

                return(JsonConvert.SerializeObject(
                           result,
                           new JsonSerializerSettings
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
                    NullValueHandling = NullValueHandling.Ignore,
                }));
            }
            catch (Exception e)
            {
                UpgradeOrchestrationTrace.TraceSource.WriteWarning(TraceType, "ProcessSetUpgradeOrchestrationServiceStateAsync exception: {0}", e);
                throw UpgradeOrchestrationMessageProcessor.ConvertToComException(e);
            }
        }
Esempio n. 6
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 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);
        }
        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);
        }
Esempio n. 9
0
        private StandAloneCluster InitializeBaselineUpgrade(string jsonFilePath)
        {
            StandAloneCluster result = Utility.PopulateStandAloneClusterWithBaselineJson(jsonFilePath);

            Assert.IsTrue(result.RunStateMachine());
            return(result);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        internal static void UpdateStandAloneClusterAutoWrpUpgrade(StandAloneCluster existingCluster, string msiCodeVersion)
        {
            var adminConfigVersion = new StandaloneAdminConfig(null, false);

            adminConfigVersion.Version.MsiVersion = msiCodeVersion;
            existingCluster.TargetWrpConfig       = adminConfigVersion;
        }
Esempio n. 12
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));
        }
Esempio n. 13
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 async Task <string> ProcessGetClusterConfigurationAsync(string apiVersion, TimeSpan timeout, CancellationToken cancellationToken)
        {
            UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Entering ProcessGetClusterConfigurationAsync.");
            try
            {
                UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Retrieve current cluster resource from StoreManager.");
                StandAloneCluster cluster = await this.storeManager.GetClusterResourceAsync(
                    Constants.ClusterReliableDictionaryKey, this.cancellationToken).ConfigureAwait(false);

                if (cluster == null || cluster.Current == null)
                {
                    // read from fabric data root
                    string fabricDataRoot = FabricEnvironment.GetDataRoot();
                    string jsonConfigPath = Path.Combine(fabricDataRoot, System.Fabric.FabricDeployer.Constants.FileNames.BaselineJsonClusterConfig); // TODO: Needs to come from image store
                    return(File.ReadAllText(jsonConfigPath));
                }
                else
                {
                    var      nodesFromFM = new Dictionary <string, NodeDescription>();
                    NodeList nodes       = await StandaloneUtility.GetNodesFromFMAsync(this.fabricClient, this.cancellationToken).ConfigureAwait(false);

                    for (int i = 0; i < nodes.Count; ++i)
                    {
                        if (nodes[i].NodeStatus != System.Fabric.Query.NodeStatus.Invalid && !UpgradeOrchestrationMessageProcessor.IsGhostNode(nodes[i]))
                        {
                            NodeDescription nodeDesc = new NodeDescription()
                            {
                                FaultDomain   = nodes[i].FaultDomain.ToString(),
                                UpgradeDomain = nodes[i].UpgradeDomain,
                                IPAddress     = nodes[i].IpAddressOrFQDN,
                                NodeTypeRef   = nodes[i].NodeType,
                                NodeName      = nodes[i].NodeName
                            };
                            nodesFromFM.Add(nodes[i].NodeName, nodeDesc);
                        }
                    }

                    cluster.Topology.Nodes = nodesFromFM;

                    UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Construct StandAloneJsonModel from current cluster resource.");
                    var jsonModel = StandAloneInstallerJsonModelBase.ConstructByApiVersion(cluster.Current.CSMConfig, cluster.Topology, cluster.Current.CSMConfig.Version.Version, apiVersion);
                    UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Serializing current json model.");
                    var serializerSettings = new JsonSerializerSettings
                    {
                        Formatting                 = Formatting.Indented,
                        NullValueHandling          = NullValueHandling.Ignore,
                        PreserveReferencesHandling = PreserveReferencesHandling.None
                    };
                    serializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
                    return(JsonConvert.SerializeObject(jsonModel, serializerSettings));
                }
            }
            catch (Exception e)
            {
                UpgradeOrchestrationTrace.TraceSource.WriteWarning(TraceType, "ProcessStartUpgradeAsync exception: {0}", e);
                throw UpgradeOrchestrationMessageProcessor.ConvertToComException(e);
            }
        }
Esempio n. 15
0
        private void InternalRestartUpgradePolicyTest(string v1JsonFile, string v2JsonFile, bool expectedForceRestart)
        {
            StandAloneCluster cluster = Utility.PopulateStandAloneClusterWithBaselineJson(v1JsonFile);

            this.ValidateUpgrade(cluster, 1, false);

            Utility.UpdateStandAloneCluster(v2JsonFile, cluster);
            this.ValidateUpgrade(cluster, 3, expectedForceRestart);
        }
        internal ICluster InitializeCluster()
        {
            StandAloneCluster cluster = Utility.DoBaselineUpgrade("myClusterConfig.X509.DevCluster.json");

            Assert.AreEqual(MultiphaseClusterUpgradeStateTest.BaselineConfigVersion, cluster.Current.CSMConfig.Version.Version);
            Utility.UpdateStandAloneCluster("myClusterConfig.X509.DevClusterV2.json", cluster);
            cluster.TargetWrpConfig  = new StandaloneAdminConfig();
            cluster.TargetNodeConfig = new ClusterNodeConfig();
            return(cluster);
        }
Esempio n. 17
0
        internal static StandAloneCluster DoBaselineUpgrade(string jsonFilePath)
        {
            StandAloneCluster result = Utility.PopulateStandAloneClusterWithBaselineJson(jsonFilePath);

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

            return(result);
        }
Esempio n. 18
0
        public void WinCertClusterTest()
        {
            StandAloneCluster cluster = Utility.DoBaselineUpgrade("myClusterConfig.WinCert.DevCluster.json");

            Assert.AreEqual("1.0.0", cluster.Current.CSMConfig.Version.Version);

            var nodeType = cluster.Current.ExternalState.ClusterManifest.NodeTypes.First();

            Assert.IsNotNull(nodeType.Certificates.ClientCertificate);
            Assert.IsNull(nodeType.Certificates.ClusterCertificate);
            Assert.AreEqual(nodeType.Certificates.ServerCertificate, nodeType.Certificates.ClientCertificate);
        }
Esempio n. 19
0
        internal static string SerealizeUsingNewSerializerSettings(StandAloneCluster cluster)
        {
            JsonSerializerSettings settings = new JsonSerializerSettings
            {
                Formatting                 = Newtonsoft.Json.Formatting.Indented,
                ReferenceLoopHandling      = ReferenceLoopHandling.Serialize,
                NullValueHandling          = NullValueHandling.Ignore,
                TypeNameHandling           = TypeNameHandling.Auto,
                PreserveReferencesHandling = PreserveReferencesHandling.None
            };

            return(JsonConvert.SerializeObject(cluster, settings));
        }
Esempio n. 20
0
 internal static string SerealizeUsingDefaults(StandAloneCluster cluster)
 {
     return(JsonConvert.SerializeObject(
                cluster,
                new JsonSerializerSettings
     {
         Formatting = Newtonsoft.Json.Formatting.Indented,
         ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
         NullValueHandling = NullValueHandling.Ignore,
         TypeNameHandling = TypeNameHandling.Objects,
         PreserveReferencesHandling = PreserveReferencesHandling.None,
         TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Full
     }));
 }
        private async Task CompleteAndPersistBaselineStateAsync(StandAloneCluster cluster, CancellationToken cancellationToken)
        {
            /* For standalone scenarios, baseline upgrade is performed automatically by CM when cluster bootstraps.
             * No need to perform an upgrade again. Persist state and return. */
            UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Baseline upgrade detected. Skipping actual upgrade and simply persisting state.");

            cluster.ClusterUpgradeCompleted();
            ReleaseAssert.AssertIfNot(cluster.Pending == null, "cluster.Pending is not null after baseline upgrade completed. Investigate why cluster.Pending is not null.");
            UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "State machine reports no pending upgrade. Status is reset.");
            cluster.Reset();

            await this.storeManager.PersistClusterResourceAsync(Constants.ClusterReliableDictionaryKey, cluster, cancellationToken)
            .ConfigureAwait(false);
        }
        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);
        }
Esempio n. 23
0
        public void ReportUnhealthyIfNecessaryTest()
        {
            StandAloneCluster cluster = Utility.PopulateStandAloneClusterWithBaselineJson("myClusterConfig.UnSecure.DevCluster.json");

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

            FabricUpgradeOrchestrationService service = new FabricUpgradeOrchestrationService(new StatefulServiceContext(), "hiahiaEndpoint", false);
            UpgradeOrchestrator orchestrator          = service.Orchestrator;

            Assert.IsFalse(orchestrator.ReportUnhealthyIfNecessary(cluster));

            cluster.TargetCsmConfig.FabricSettings = new List <SettingsSectionDescription>()
            {
                new SettingsSectionDescription()
                {
                    Name       = StringConstants.SectionName.UpgradeOrchestrationService,
                    Parameters = new List <SettingsParameterDescription>()
                    {
                        new SettingsParameterDescription()
                        {
                            Name  = StringConstants.ParameterName.FaultStep,
                            Value = "1"
                        },
                        new SettingsParameterDescription()
                        {
                            Name  = StringConstants.ParameterName.FaultFlow,
                            Value = "RollingBack"
                        },
                    }
                }
            };

            cluster.Pending = new MockUpMultiphaseClusterUpgradeState(2, cluster)
            {
                CurrentListIndex = 1
            };

            Assert.IsFalse(orchestrator.ReportUnhealthyIfNecessary(cluster));

            cluster.Pending = new MockUpMultiphaseClusterUpgradeState(2, cluster)
            {
                CurrentListIndex    = 1,
                UpgradeUnsuccessful = true,
            };
            bool healthy = true;

            Assert.IsTrue(orchestrator.ReportUnhealthyIfNecessary(cluster, isHealthy => { healthy = isHealthy; }));
            Assert.IsFalse(healthy);
        }
Esempio n. 24
0
        internal static void UpdateStandAloneCluster(string targetJsonFilePath, StandAloneCluster existingCluster, bool isUserSet = false)
        {
            StandAloneInstallerJsonModelBase targetJsonConfig = StandAloneInstallerJsonModelBase.GetJsonConfigFromFile(Path.Combine(Utility.TestDirectory, targetJsonFilePath));
            StandaloneSettingsValidator      validator        = new StandaloneSettingsValidator(targetJsonConfig);

            existingCluster.TargetCsmConfig = validator.ClusterProperties;
            existingCluster.Topology        = validator.Topology;

            if (!string.IsNullOrEmpty(validator.ClusterProperties.CodeVersion))
            {
                var adminConfigVersion = new StandaloneAdminConfig(null, isUserSet);
                adminConfigVersion.Version.MsiVersion = validator.ClusterProperties.CodeVersion;
                existingCluster.TargetWrpConfig       = adminConfigVersion;
            }
        }
        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());
        }
Esempio n. 26
0
        public static void DryRunConfigUpgrade(StandAloneCluster cluster)
        {
            UpgradeOrchestrationTrace.TraceSource.WriteInfo(FabricUpgradeOrchestrationService.TraceType, "In data loss state. Starting dry run config upgrade in order to recover FUOS state");

            // 1-step baseline upgrade with non-baseline config
            if (cluster.RunStateMachine())
            {
                cluster.ClusterUpgradeCompleted();
                cluster.Reset();
                UpgradeOrchestrationTrace.TraceSource.WriteInfo(FabricUpgradeOrchestrationService.TraceType, "Dry run config upgrade completed");
            }
            else
            {
                UpgradeOrchestrationTrace.TraceSource.WriteError(FabricUpgradeOrchestrationService.TraceType, "Unexpected. Dry run config upgrade is skipped");
            }
        }
        internal static StandAloneCluster ConstructClusterFromJson(StandAloneInstallerJsonModelBase jsonModel, FabricNativeConfigStore configStore)
        {
            UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Creating userconfig, cluster topology, adminconfig.");

            var userConfig      = jsonModel.GetUserConfig();
            var clusterTopology = jsonModel.GetClusterTopology();
            var adminConfig     = new StandaloneAdminConfig();
            var logger          = new StandAloneTraceLogger("StandAloneDeploymentManager");

            UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Creating new StandAlone cluster resource.");

            var clusterId       = configStore.ReadUnencryptedString(Constants.SectionName, Constants.ClusterIdParameterName);
            var clusterResource = new StandAloneCluster(adminConfig, userConfig, clusterTopology, clusterId, logger);

            return(clusterResource);
        }
Esempio n. 28
0
        public void RuntimeMajorVersionBumpupTest()
        {
            string[] filePaths = new string[]
            {
                Path.Combine(Utility.TestDirectory, "5.7cu2UosState1.json"),
                Path.Combine(Utility.TestDirectory, "5.7cu2UosState2.json"),
            };

            foreach (string file in filePaths)
            {
                string str = File.ReadAllText(file);

                StandAloneCluster cluster = StoreManager.DeserializeClusterResource(str);
                Assert.IsNotNull(cluster);
            }
        }
Esempio n. 29
0
        private void ValidateUpgrade(StandAloneCluster cluster, int iterations, bool expectedForceRestart)
        {
            for (int i = 0; i < iterations; i++)
            {
                cluster.RunStateMachine();

                bool currentExpectedForceRestart = expectedForceRestart && i == 0;
                Assert.AreEqual(currentExpectedForceRestart, cluster.Pending.GetUpgradePolicy().ForceRestart);

                Utility.RollForwardOneIteration(cluster);
                Assert.AreEqual(cluster.Pending == null, i == iterations - 1);
            }

            Assert.IsFalse(cluster.RunStateMachine());
            Assert.IsNull(cluster.Pending);
            Assert.IsNotNull(cluster.Current);
        }
Esempio n. 30
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));
        }