private void SignalReady()
            {
                switch (signalReadyHitCounter)
                {
                case 0:
                    Trace.ConsoleWriteLine(TraceType, "IS: Invoking SignalReady for giving approval to FC's job.");
                    signalReadyHitCounter++;
                    break;

                case 1:
                    Trace.ConsoleWriteLine(TraceType, "IS: Invoking SignalReady after job execution and completion of health check from CM.");
                    Verify.AreEqual(state, State.FromCMAckedCompletedJob,
                                    string.Format(CultureInfo.InvariantCulture, "SignalReady invoked after after health checks from CM to ack completed job: {0}", state));
                    signalReadyHitCounter++;
                    break;

                case 2:
                    Trace.ConsoleWriteLine(TraceType, "IS: Invoking SignalReady 2nd time since MR/FC missed out the previous CompleteJobStep ack.");
                    Verify.AreEqual(state, State.FromISSendSignalReady,
                                    string.Format(CultureInfo.InvariantCulture, "SignalReady invoked 2nd time to re-ack completed job: {0}", state));

                    CompletedEvent.Set();
                    break;
                }
            }
            private void SignalReady()
            {
                switch (signalReadyHitCounter)
                {
                case 0:
                    Trace.ConsoleWriteLine(TraceType, "IS: Invoking SignalReady for MANUAL VendorRepairBegin job.");
                    signalReadyHitCounter++;
                    break;

                case 1:
                    Trace.ConsoleWriteLine(TraceType, "IS: Invoking SignalReady for giving approval to a normal FC's job's StartJobStep.");
                    signalReadyHitCounter++;
                    break;

                case 2:
                    Trace.ConsoleWriteLine(TraceType, "IS: Invoking SignalReady for MANUAL VendorRepairEnd job.");
                    signalReadyHitCounter++;

                    NotificationContext.ImpactedInstances = new List <ImpactedInstance>
                    {
                        new ImpactedInstance("RoleA_IN_1", new List <ImpactReason> {
                            ImpactReason.Reboot
                        })
                    };

                    break;

                case 3:
                    Trace.ConsoleWriteLine(TraceType, "IS: Invoking SignalReady for giving approval to a normal FC's job's CompleteJobStep.");
                    signalReadyHitCounter++;

                    CompletedEvent.Set();
                    break;
                }
            }
            private void SignalError(string errorDescription)
            {
                Trace.ConsoleWriteLine(TraceType,
                                       "IS: Invoking SignalError after job execution and task failure from CM. Error description: {0}", errorDescription);
                Verify.AreEqual(state, State.FromCMHealthCheckFailed,
                                string.Format(CultureInfo.InvariantCulture, "SignalError invoked after health checks from CM failed. Workflow state: {0}", state));

                CompletedEvent.Set();
            }
Exemplo n.º 4
0
        protected override void Run(CancellationToken cancellationToken)
        {
            var tenantJob = TenantJobHelper.CreateNewTenantJob();

            PolicyAgentService.CreateTenantJob(tenantJob);

            RepairManager.CompletedEvent.WaitOne();
            CompletedEvent.Set();
        }
Exemplo n.º 5
0
            protected override void AfterUpdateRepairExecutionState(Guid activityId, MockRepairTask repairTask)
            {
                base.AfterUpdateRepairExecutionState(activityId, repairTask);

                if (repairTask.State == RepairTaskState.Completed)
                {
                    CompletedEvent.Set();
                }
            }
Exemplo n.º 6
0
        protected override void Run(CancellationToken cancellationToken)
        {
            IRepairTask repairTask = CreateRepairTask();

            RepairManager.CreateRepairTaskAsync(Guid.NewGuid(), repairTask).GetAwaiter().GetResult();

            RepairManager.CompletedEvent.WaitOne();
            PolicyAgentService.CompletedEvent.WaitOne();
            CompletedEvent.Set();
        }
Exemplo n.º 7
0
        protected override void Run(CancellationToken cancellationToken)
        {
            var tenantJob = TenantJobHelper.CreateNewTenantJob(ImpactActionEnum.PlatformUpdate); // Root HE

            // this kicks things off
            PolicyAgentService.CreateTenantJob(tenantJob);

            RepairManager.CompletedEvent.WaitOne();
            CompletedEvent.Set();
        }
        protected override void Run(CancellationToken cancellationToken)
        {
            var tenantJob = TenantJobHelper.CreateNewTenantJob(ImpactActionEnum.PlatformMaintenance);

            // this kicks things off
            PolicyAgentService.CreateTenantJob(tenantJob);

            ProcessCloser.ExitEvent.WaitOne();

            CompletedEvent.Set();
        }
Exemplo n.º 9
0
        public virtual void SetCompleted(bool success, ResultError errorCode)
        {
            Success   = success;
            ErrorCode = errorCode;

#if DEBUG
#elif TRACE
            Traces = Debugging.CollectTraces();
#endif
            CompletedEvent.Set();
        }
        protected override void Run(CancellationToken cancellationToken)
        {
            IRepairTask repairTask = CreateRepairTask();

            RepairManager.CreateRepairTaskAsync(Guid.NewGuid(), repairTask).GetAwaiter().GetResult();

            ((MockRepairTask)repairTask).CreatedTimestamp = DateTime.UtcNow;

            RepairManager.CompletedEvent.WaitOne();
            CompletedEvent.Set();
        }
            protected override void AfterUpdateRepairExecutionState(Guid activityId, MockRepairTask repairTask)
            {
                base.AfterUpdateRepairExecutionState(activityId, repairTask);

                if (repairTask.State == RepairTaskState.Claimed && !repairTask.ClaimedTimestamp.HasValue)
                {
                    repairTask.ClaimedTimestamp = DateTime.UtcNow;
                }

                if (repairTask.State == RepairTaskState.Completed && repairTask.ResultStatus == RepairTaskResult.Cancelled)
                {
                    CompletedEvent.Set();
                }
            }
Exemplo n.º 12
0
        protected override void Run(CancellationToken cancellationToken)
        {
            var tenantJob = TenantJobHelper.CreateNewTenantJob(ImpactActionEnum.PlatformMaintenance);

            // this kicks things off
            PolicyAgentService.CreateTenantJob(tenantJob);

            ProcessCloser.ExitEvent.WaitOne();

            var elapsed = DateTimeOffset.UtcNow - startTime;

            Assert.IsTrue(elapsed >= TimeSpan.FromSeconds(MaxRetryDurationInSeconds), "Verifying if max retry duration is exceeded");
            CompletedEvent.Set();
        }
Exemplo n.º 13
0
            /// <summary>
            /// When IS makes a RepairRequest post to PolicyAgent, then we create a new tenant job in response
            /// </summary>
            public override async Task PostPolicyAgentRequestAsync(
                Guid activityId,
                PolicyAgentRequest request,
                CancellationToken cancellationToken)
            {
                if (request.RepairRequest != null && request.RepairRequest.RoleInstanceId != null)
                {
                    string id = request.RepairRequest.RoleInstanceId + "/" + request.RepairRequest.Action;

                    if (!repairRequests.Contains(id))
                    {
                        var tenantJob = TenantJobHelper.CreateNewTenantJob(
                            ImpactActionEnum.TenantMaintenance,
                            0,
                            new List <string> {
                            "Role_IN_1"
                        },
                            request.RepairRequest.ContextId);
                        CreateTenantJob(tenantJob);

                        repairRequests.Add(id);
                        return;
                    }
                }

                if (policyAgentStage == 0)
                {
                    SendImpactEnd(request);
                }
                else if (policyAgentStage == 1)
                {
                    SendCompletion(request, true);
                    CompletedEvent.Set();
                }

                policyAgentStage++;

                await Task.FromResult(0);
            }
Exemplo n.º 14
0
        protected override void Run(CancellationToken cancellationToken)
        {
            ProcessCloser.ExitEvent.WaitOne();

            CompletedEvent.Set();
        }
Exemplo n.º 15
0
 /// <summary>
 /// Override in derived classes for functionality outside of the coordinator
 /// </summary>
 protected virtual void Run(CancellationToken cancellationToken)
 {
     CompletedEvent.Set();
 }
Exemplo n.º 16
0
 public virtual void SetCompleted(bool success)
 {
     Success = success;
     CompletedEvent.Set();
 }
 public WorkflowRunAsyncTest1()
 {
     CompletedEvent.Set();
 }