Exemple #1
0
        public static MockJobStepInfo CreateNewJobStepInfo(uint ud, List <string> roleInstances)
        {
            var impactedRoleInstances = new List <IRoleInstanceImpactedByJob>();

            foreach (var ri in roleInstances)
            {
                var riwo = new MockRoleInstanceImpactedByJob {
                    RoleInstanceName = ri, UpdateDomain = ud
                };
                impactedRoleInstances.Add(riwo);
            }

            var jsi = new MockJobStepInfo
            {
                ImpactStep                     = ImpactStepEnum.ImpactStart,
                AcknowledgementStatus          = AcknowledgementStatusEnum.WaitingForAcknowledgement,
                ActionStatus                   = ImpactActionStatus.NotExecuted,
                CurrentlyImpactedRoleInstances = impactedRoleInstances,
            };

            return(jsi);
        }
        public void BasicTest()
        {
            var job = new MockTenantJob();

            job.JobStatus = (JobStatusEnum)999;
            Assert.AreEqual(JobPhase.Unknown, jobClassifier.GetJobPhase(job));

            job.JobStatus = JobStatusEnum.Pending;
            Assert.AreEqual(JobPhase.Unknown, jobClassifier.GetJobPhase(job));

            configStore.UpdateKey(
                configSection.Name,
                "Azure.JobClassifier.JobStatusCategory.Pending",
                "Inactive");
            Assert.AreEqual(JobPhase.Inactive, jobClassifier.GetJobPhase(job));

            job.JobStatus = JobStatusEnum.Alerted;
            Assert.AreEqual(JobPhase.Inactive, jobClassifier.GetJobPhase(job));

            job.JobStatus = JobStatusEnum.Cancelled;
            Assert.AreEqual(JobPhase.Inactive, jobClassifier.GetJobPhase(job));

            job.JobStatus = JobStatusEnum.Completed;
            Assert.AreEqual(JobPhase.Inactive, jobClassifier.GetJobPhase(job));

            job.JobStatus = JobStatusEnum.Failed;
            Assert.AreEqual(JobPhase.Inactive, jobClassifier.GetJobPhase(job));

            job.JobStatus = JobStatusEnum.Suspended;
            Assert.AreEqual(JobPhase.Inactive, jobClassifier.GetJobPhase(job));

            job.JobStatus = JobStatusEnum.Executing;
            // Unknown because JobStep is null
            Assert.AreEqual(JobPhase.Unknown, jobClassifier.GetJobPhase(job));

            var jobStep = new MockJobStepInfo();

            job.JobStep = jobStep;

            jobStep.ImpactStep = ImpactStepEnum.Default;
            // Unknown because of impact step
            Assert.AreEqual(JobPhase.Unknown, jobClassifier.GetJobPhase(job));

            jobStep.ImpactStep = (ImpactStepEnum)999;
            // Unknown because of impact step
            Assert.AreEqual(JobPhase.Unknown, jobClassifier.GetJobPhase(job));

            jobStep.ImpactStep = ImpactStepEnum.ImpactStart;

            jobStep.AcknowledgementStatus = AcknowledgementStatusEnum.WaitingForAcknowledgement;
            Assert.AreEqual(JobPhase.ImpactStartWaitingForAck, jobClassifier.GetJobPhase(job));
            jobStep.AcknowledgementStatus = AcknowledgementStatusEnum.Acknowledged;
            Assert.AreEqual(JobPhase.ImpactStartAcked, jobClassifier.GetJobPhase(job));
            jobStep.AcknowledgementStatus = AcknowledgementStatusEnum.Timedout;
            Assert.AreEqual(JobPhase.ImpactStartAcked, jobClassifier.GetJobPhase(job));

            jobStep.AcknowledgementStatus = AcknowledgementStatusEnum.Alerted;
            Assert.AreEqual(JobPhase.Unknown, jobClassifier.GetJobPhase(job));

            configStore.UpdateKey(
                configSection.Name,
                "Azure.JobClassifier.ImpactStartAcknowledgementStatusAlerted",
                "Inactive");
            Assert.AreEqual(JobPhase.Inactive, jobClassifier.GetJobPhase(job));

            jobStep.AcknowledgementStatus = (AcknowledgementStatusEnum)999;
            Assert.AreEqual(JobPhase.Unknown, jobClassifier.GetJobPhase(job));

            jobStep.ImpactStep = ImpactStepEnum.ImpactEnd;

            jobStep.AcknowledgementStatus = AcknowledgementStatusEnum.WaitingForAcknowledgement;
            Assert.AreEqual(JobPhase.ImpactEndWaitingForAck, jobClassifier.GetJobPhase(job));
            jobStep.AcknowledgementStatus = AcknowledgementStatusEnum.Acknowledged;
            Assert.AreEqual(JobPhase.Inactive, jobClassifier.GetJobPhase(job));
            jobStep.AcknowledgementStatus = AcknowledgementStatusEnum.Timedout;
            Assert.AreEqual(JobPhase.Inactive, jobClassifier.GetJobPhase(job));
            jobStep.AcknowledgementStatus = AcknowledgementStatusEnum.Alerted;
            Assert.AreEqual(JobPhase.Inactive, jobClassifier.GetJobPhase(job));
            jobStep.AcknowledgementStatus = (AcknowledgementStatusEnum)999;
            Assert.AreEqual(JobPhase.Unknown, jobClassifier.GetJobPhase(job));

            // Compare versions

            configStore.ClearKeys();

            job.JobStatus                 = JobStatusEnum.Failed;
            jobStep.ImpactStep            = ImpactStepEnum.ImpactEnd;
            jobStep.AcknowledgementStatus = AcknowledgementStatusEnum.WaitingForAcknowledgement;

            Assert.AreEqual(JobPhase.Inactive, jobClassifier.GetJobPhase(job));

            configStore.UpdateKey(
                configSection.Name,
                "Azure.JobClassifier.Version",
                "1");

            Assert.AreEqual(JobPhase.ImpactEndWaitingForAck, jobClassifier.GetJobPhase(job));
        }