Пример #1
0
        public void ShouldReportUnhealthyTest()
        {
            FaultInjectionConfig config;
            StandAloneCluster    cluster = Utility.PopulateStandAloneClusterWithBaselineJson("myClusterConfig.UnSecure.DevCluster.json");

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

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

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

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

            MockUpMultiphaseClusterUpgradeState upgradeState2 = new MockUpMultiphaseClusterUpgradeState(2, cluster);

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

            config = new FaultInjectionConfig(UpgradeFlow.RollingForward, 1);
            Assert.IsFalse(FaultInjectionHelper.ShouldReportUnhealthy(upgradeState1, UpgradeFlow.RollingForward, config));
            Assert.IsTrue(FaultInjectionHelper.ShouldReportUnhealthy(upgradeState2, UpgradeFlow.RollingForward, config));
        }
Пример #2
0
        public void FaultInjectionConfigTest()
        {
            UpgradeFlow          upgradeFlow = UpgradeFlow.RollingBack;
            int                  step        = 100;
            FaultInjectionConfig config      = new FaultInjectionConfig(upgradeFlow, step);

            Assert.AreEqual(upgradeFlow, config.FaultFlow);
            Assert.AreEqual(step, config.FaultStep);

            Assert.AreEqual(upgradeFlow + ":" + step, config.ToString());

            Assert.IsFalse(config.Equals(null));
            Assert.IsFalse(config.Equals(step));
            Assert.IsTrue(config.Equals(config));

            FaultInjectionConfig config2 = new FaultInjectionConfig(upgradeFlow, step);

            Assert.IsTrue(config.Equals(config2));
            config2.FaultStep++;
            Assert.IsFalse(config.Equals(config2));
            config2.FaultStep--;
            Assert.IsTrue(config.Equals(config2));
            config2.FaultFlow = UpgradeFlow.RollingForward;
            Assert.IsFalse(config.Equals(config2));
        }
Пример #3
0
        public void TryGetFaultInjectionConfigTest()
        {
            Assert.IsNull(this.InternalTryGetFaultInjectionConfigTest(faultStep: null, faultFlow: string.Empty));
            Assert.IsNull(this.InternalTryGetFaultInjectionConfigTest(faultStep: "0", faultFlow: string.Empty));
            Assert.IsNull(this.InternalTryGetFaultInjectionConfigTest(faultStep: null, faultFlow: "RollingBack"));
            Assert.IsNull(this.InternalTryGetFaultInjectionConfigTest(faultStep: "-1", faultFlow: "RollingBack"));
            Assert.IsNull(this.InternalTryGetFaultInjectionConfigTest(faultStep: "0", faultFlow: "hiahia"));

            string faultStep            = "1";
            string faultFlow            = "RollingBack";
            FaultInjectionConfig config = this.InternalTryGetFaultInjectionConfigTest(faultStep, faultFlow);

            Assert.IsTrue(config.Equals(new FaultInjectionConfig((UpgradeFlow)Enum.Parse(typeof(UpgradeFlow), faultFlow), int.Parse(faultStep))));
        }
Пример #4
0
        public override bool Equals(object obj)
        {
            if (obj == null || obj.GetType() != typeof(FaultInjectionConfig))
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            FaultInjectionConfig other = obj as FaultInjectionConfig;

            return(other.FaultFlow == this.FaultFlow &&
                   other.FaultStep == this.FaultStep);
        }