Exemplo n.º 1
0
        public static StepBase GetStep(
            StepStateNames stateName,
            FabricClient fabricClient,
            ActionStateBase actionState,
            RestartPartitionAction action,
            TimeSpan requestTimeout,
            TimeSpan operationTimeout,
            CancellationToken cancellationToken)
        {
            StepBase step = null;
            RestartPartitionState restartPartitionState = Convert(actionState);

            if (stateName == StepStateNames.LookingUpState)
            {
                step = new LookingUpStep(fabricClient, restartPartitionState, requestTimeout, operationTimeout, action.PartitionSelector, action.RestartPartitionMode);
            }
            else if (stateName == StepStateNames.PerformingActions)
            {
                step = new RestartingSelectedReplicas(fabricClient, restartPartitionState, requestTimeout, operationTimeout, action.RestartPartitionMode);
            }
            else if (stateName == StepStateNames.CompletedSuccessfully)
            {
                // done - but then this method should not have been called
                ReleaseAssert.Failfast("GetStep() should not have been called when the state nme is CompletedSuccessfully");
            }
            else
            {
                ReleaseAssert.Failfast(string.Format(CultureInfo.InvariantCulture, "Unexpected state name={0}", stateName));
            }

            return(step);
        }
Exemplo n.º 2
0
        public static StepBase GetStep(
            StepStateNames stateName,
            FabricClient fabricClient,
            ActionStateBase actionState,
            InvokeQuorumLossAction action,
            TimeSpan requestTimeout,
            TimeSpan operationTimeout,
            CancellationToken cancellationToken)
        {
            StepBase step = null;
            InvokeQuorumLossState state = Convert(actionState);

            if (stateName == StepStateNames.LookingUpState)
            {
                step = new QuorumLossStepsFactory.LookingUpState(fabricClient, state, requestTimeout, operationTimeout, action.PartitionSelector, action.QuorumLossMode);
            }
            else if (stateName == StepStateNames.PerformingActions)
            {
                step = new QuorumLossStepsFactory.PerformingActions(fabricClient, state, requestTimeout, operationTimeout, action.PartitionSelector);
            }
            else if (stateName == StepStateNames.CompletedSuccessfully)
            {
                // done - but then this method should not have been called
                TestabilityTrace.TraceSource.WriteError(StepBase.TraceType, "{0} - GetStep() should not have been called when the state nme is CompletedSuccessfully", actionState.OperationId);
                ReleaseAssert.Failfast("GetStep() should not have been called when the state nme is CompletedSuccessfully");
            }
            else
            {
                string error = string.Format(CultureInfo.InvariantCulture, "{0} - Unexpected state name={1}", actionState.OperationId, stateName);
                TestabilityTrace.TraceSource.WriteError(StepBase.TraceType, "{0}", error);
                ReleaseAssert.Failfast(error);
            }

            return(step);
        }
Exemplo n.º 3
0
 public override bool MustHappenBefore(StepBase other)
 {
     // We want to resolve any outstanding reordering operations early, because they can leave tables existing that shouldn't, tables not existing
     // that should, before statements associated with the wrong table, dogs and cats sleeping together, mass hysteria. So we fix this outstanding issue
     // before anything except pre-upgrade-hooks.
     return(!(other is PreUpgradeHooksStep));
 }
Exemplo n.º 4
0
        public static StepBase GetStep(
            StepStateNames stateName,
            FabricClient fabricClient,
            ActionStateBase actionState,
            InvokeDataLossAction action,
            TimeSpan requestTimeout,
            TimeSpan operationTimeout,
            CancellationToken cancellationToken)
        {
            StepBase            step = null;
            InvokeDataLossState invokeDataLossState = Convert(actionState);

            StepStateNames prevContext = actionState.StateProgress.Peek();

            if (stateName == StepStateNames.LookingUpState)
            {
                step = new DataLossStepsFactory.LookingUpState(fabricClient, invokeDataLossState, requestTimeout, operationTimeout, action.PartitionSelector);
            }
            else if (stateName == StepStateNames.PerformingActions)
            {
                step = new DataLossStepsFactory.PerformingActions(fabricClient, invokeDataLossState, requestTimeout, operationTimeout, action.PartitionSelector, action.DataLossCheckWaitDurationInSeconds, action.DataLossCheckPollIntervalInSeconds, action.ReplicaDropWaitDurationInSeconds);
            }
            else if (stateName == StepStateNames.CompletedSuccessfully)
            {
                // done - but then this method should not have been called
                ReleaseAssert.Failfast(string.Format(CultureInfo.InvariantCulture, "{0} - GetStep() should not have been called when the state name is CompletedSuccessfully"), actionState.OperationId);
            }
            else
            {
                ReleaseAssert.Failfast(string.Format(CultureInfo.InvariantCulture, "{0} - Unexpected state name={1}", actionState.OperationId, stateName));
            }

            return(step);
        }
Exemplo n.º 5
0
        public static StepBase GetStep(
            StepStateNames stateName,
            FabricClient fabricClient,
            ActionStateBase actionState,
            StartNodeFromFASAction action,
            TimeSpan requestTimeout,
            TimeSpan operationTimeout,
            CancellationToken cancellationToken)
        {
            StepBase         step           = null;
            NodeCommandState startNodeState = Convert(actionState);

            StepStateNames prevContext = actionState.StateProgress.Peek();

            if (stateName == StepStateNames.LookingUpState)
            {
                step = new StartNodeStepsFactory.LookingUpState(fabricClient, startNodeState, action, requestTimeout, operationTimeout);
            }
            else if (stateName == StepStateNames.PerformingActions)
            {
                step = new StartNodeStepsFactory.PerformingActions(fabricClient, startNodeState, action, requestTimeout, operationTimeout);
            }
            else if (stateName == StepStateNames.CompletedSuccessfully)
            {
                // done - but then this method should not have been called
                ReleaseAssert.Failfast(string.Format(CultureInfo.InvariantCulture, "{0} - GetStep() should not have been called when the state name is CompletedSuccessfully"), actionState.OperationId);
            }
            else
            {
                ReleaseAssert.Failfast(string.Format(CultureInfo.InvariantCulture, "{0} - Unexpected state name={1}", actionState.OperationId, stateName));
            }

            return(step);
        }
Exemplo n.º 6
0
 protected void OnStepCompleted(StepBase step)
 {
     if (step.check())
     {
         isStart   = true;
         m_Current = step.id + 1;
     }
 }
Exemplo n.º 7
0
 public void BeforeScenario()
 {
     if (!DoneBeforeScenarioAlready)
     {
         StepBase.CreateBrowser(ConfigurationManager.AppSettings["BrowserType"]);
         Console.WriteLine("selenium open Called");
         BeforeScenarioDoneAlready = true;
     }
 }
Exemplo n.º 8
0
 public TestStepBase(StepBase s, string caseLpu)
 {
     if (s != null)
         step = s;
     if (s.Doctor != null)
     {
         doctor = new TestDoctor(s.Doctor, caseLpu);
     }
 }
Exemplo n.º 9
0
    protected T GetInterface <T>(StepBase stepBase)
    {
        T step = stepBase.GetComponent <T>();

        if (step == null)
        {
            return(default(T));
        }
        return(step);
    }
Exemplo n.º 10
0
 public TestStepBase(StepBase s, string caseLpu)
 {
     if (s != null)
     {
         step = s;
     }
     if (s.Doctor != null)
     {
         doctor = new TestDoctor(s.Doctor, caseLpu);
     }
 }
Exemplo n.º 11
0
 public static List<TestStepBase> BuildTestStepsFromDataBase(string idCase, string stepLpu)
 {
     List<TestStepBase> steps = new List<TestStepBase>();
     if (idCase != string.Empty)
     {
         using (SqlConnection connection = Global.GetSqlConnection())
         {
             string findSteps = "SELECT * FROM Step WHERE IdCase = '" + idCase + "'";
             SqlCommand stepsCommand = new SqlCommand(findSteps, connection);
             using (SqlDataReader stepsReader = stepsCommand.ExecuteReader())
             {
                 while (stepsReader.Read())
                 {
                     StepBase sb = new StepBase();
                     if (stepsReader["Comment"].ToString() != "")
                         sb.Comment = Convert.ToString(stepsReader["Comment"]);
                     else
                         sb.Comment = null;
                     if (stepsReader["DateEnd"].ToString() != "")
                         sb.DateEnd = Convert.ToDateTime(stepsReader["DateEnd"]);
                     else
                         sb.DateEnd = DateTime.MinValue;
                     if (stepsReader["DateStart"].ToString() != "")
                         sb.DateStart = Convert.ToDateTime(stepsReader["DateStart"]);
                     else
                         sb.DateStart = DateTime.MinValue;
                     if (stepsReader["IdPaymentType"].ToString() != "")
                         sb.IdPaymentType = Convert.ToByte(stepsReader["IdPaymentType"]);
                     else
                         sb.IdPaymentType = 0;
                     if (stepsReader["IdStepMis"].ToString() != "")
                         sb.IdStepMis = Convert.ToString(stepsReader["IdStepMis"]);
                     else
                         sb.IdStepMis = null;
                     TestStepBase step = new TestStepBase(sb, stepLpu);
                     if (stepsReader["IdDoctor"].ToString() != "")
                         step.doctor = TestDoctor.BuildTestDoctorFromDataBase(stepsReader["IdDoctor"].ToString());
                     else
                         step.doctor = null;
                     step.idStep = Convert.ToString(stepsReader["IdStep"]);
                     steps.Add(step);
                 }
             }
         }
     }
     if (steps.Count != 0)
         return steps;
     else
         return null;
 }
 void SetCurrentStep(GlobalVars.SceneList sceneEnum)
 {
     for (int i = 0; i < StepList.Count; i++)
     {
         StepBase curStep = StepList[i];
         if (sceneEnum == curStep.CurScene)
         {
             curStep.Show();
         }
         else
         {
             curStep.Hide();
         }
     }
     GlobalVars.Instance.CurScene = sceneEnum;
     EventManager.Instance.UpdateSceneComplete(sceneEnum);
 }
Exemplo n.º 13
0
 public void AddStepToCase(string guid, string idLpu, string idPatientMis, string idCaseMis, StepBase s)
 {
     try
     {
         StepAmb sa = s as StepAmb;
         if ((object)sa != null)
         {
             client.AddStepToCase(guid, idLpu, idPatientMis, idCaseMis ,s);
             TestAmbStep example = new TestAmbStep(sa, idLpu);
             if (!example.CheckStepInDataBase(guid, idPatientMis, idLpu, idCaseMis))
             {
                 Global.errors1.AddRange(Global.errors2);
             }
         }
         StepStat ss = s as StepStat;
         if ((object)ss != null)
         {
             client.AddStepToCase(guid, idLpu, idPatientMis, idCaseMis, s);
             TestStatStep example = new TestStatStep(ss, idLpu);
             if (!example.CheckStepInDataBase(guid, idPatientMis, idLpu, idCaseMis))
                 Global.errors1.AddRange(Global.errors2);
         }
     }
     catch (System.ServiceModel.FaultException<List<PixServiseTests.EMKServise.RequestFault>> e)
     {
         getErrors(e.Detail);
     }
     catch (System.ServiceModel.FaultException<PixServiseTests.EMKServise.RequestFault[]> e)
     {
         getErrors(e.Detail);
     }
     catch (System.ServiceModel.FaultException<PixServiseTests.EMKServise.RequestFault> e)
     {
         Global.errors1.Add(e.Detail.PropertyName + " - " + e.Detail.Message);
         getErrors(e.Detail.Errors);
     }
 }
Exemplo n.º 14
0
 public override bool MustHappenBefore(StepBase other)
 {
     return(other is DropTablesStep);
 }
Exemplo n.º 15
0
 public override bool MustHappenAfter(StepBase other)
 {
     return(other is SetNotNullStep || other is AddFkeysStep || other is AddSequencesStep || other is AddTriggersStep || other is AddStoredProcsStep);
 }
Exemplo n.º 16
0
 public override bool MustHappenBefore(StepBase other)
 {
     return(other is AddFkeysStep);
 }
Exemplo n.º 17
0
 // Must happen last - after everything!
 public override bool MustHappenAfter(StepBase other)
 {
     return(true);
 }
Exemplo n.º 18
0
 public override bool MustHappenAfter(StepBase other)
 {
     return(other is DropIndexesStep || other is SetNotNullStep);
 }
Exemplo n.º 19
0
 public void AddStepToCase(string guid, string idLpu, string idPatientMis, string idCaseMis, StepBase s)
 {
     try
     {
         StepAmb sa = s as StepAmb;
         if ((object)sa != null)
         {
             client.AddStepToCase(guid, idLpu, idPatientMis, idCaseMis, s);
             TestAmbStep example = new TestAmbStep(sa, idLpu);
             if (!example.CheckStepInDataBase(guid, idPatientMis, idLpu, idCaseMis))
             {
                 Global.errors1.AddRange(Global.errors2);
             }
         }
         StepStat ss = s as StepStat;
         if ((object)ss != null)
         {
             client.AddStepToCase(guid, idLpu, idPatientMis, idCaseMis, s);
             TestStatStep example = new TestStatStep(ss, idLpu);
             if (!example.CheckStepInDataBase(guid, idPatientMis, idLpu, idCaseMis))
             {
                 Global.errors1.AddRange(Global.errors2);
             }
         }
     }
     catch (System.ServiceModel.FaultException <List <PixServiseTests.EMKServise.RequestFault> > e)
     {
         getErrors(e.Detail);
     }
     catch (System.ServiceModel.FaultException <PixServiseTests.EMKServise.RequestFault[]> e)
     {
         getErrors(e.Detail);
     }
     catch (System.ServiceModel.FaultException <PixServiseTests.EMKServise.RequestFault> e)
     {
         Global.errors1.Add(e.Detail.PropertyName + " - " + e.Detail.Message);
         getErrors(e.Detail.Errors);
     }
 }
Exemplo n.º 20
0
 public override bool MustHappenAfter(StepBase other)
 {
     return(other is DropSequencesStep || other is AddFkeysStep);
 }
Exemplo n.º 21
0
 public override bool MustHappenBefore(StepBase other)
 {
     return(other is SetNullStep);
 }
Exemplo n.º 22
0
 public override bool MustHappenBefore(StepBase other)
 {
     return(other is AddTablesStep || other is RenameTablesStep || other is AddFieldsStep);
 }
Exemplo n.º 23
0
 public MemoryUsageSnapshotResult(StepBase step, long?memoryUsage) : base(step)
 {
     MemoryUsage = memoryUsage;
 }
Exemplo n.º 24
0
        static public List <TestStepBase> BuildTestStepsFromDataBase(string idCase, string stepLpu)
        {
            List <TestStepBase> steps = new List <TestStepBase>();

            if (idCase != string.Empty)
            {
                using (SqlConnection connection = Global.GetSqlConnection())
                {
                    string     findSteps    = "SELECT * FROM Step WHERE IdCase = '" + idCase + "'";
                    SqlCommand stepsCommand = new SqlCommand(findSteps, connection);
                    using (SqlDataReader stepsReader = stepsCommand.ExecuteReader())
                    {
                        while (stepsReader.Read())
                        {
                            StepBase sb = new StepBase();
                            if (stepsReader["Comment"].ToString() != "")
                            {
                                sb.Comment = Convert.ToString(stepsReader["Comment"]);
                            }
                            else
                            {
                                sb.Comment = null;
                            }
                            if (stepsReader["DateEnd"].ToString() != "")
                            {
                                sb.DateEnd = Convert.ToDateTime(stepsReader["DateEnd"]);
                            }
                            else
                            {
                                sb.DateEnd = DateTime.MinValue;
                            }
                            if (stepsReader["DateStart"].ToString() != "")
                            {
                                sb.DateStart = Convert.ToDateTime(stepsReader["DateStart"]);
                            }
                            else
                            {
                                sb.DateStart = DateTime.MinValue;
                            }
                            if (stepsReader["IdPaymentType"].ToString() != "")
                            {
                                sb.IdPaymentType = Convert.ToByte(stepsReader["IdPaymentType"]);
                            }
                            else
                            {
                                sb.IdPaymentType = 0;
                            }
                            if (stepsReader["IdStepMis"].ToString() != "")
                            {
                                sb.IdStepMis = Convert.ToString(stepsReader["IdStepMis"]);
                            }
                            else
                            {
                                sb.IdStepMis = null;
                            }
                            TestStepBase step = new TestStepBase(sb, stepLpu);
                            if (stepsReader["IdDoctor"].ToString() != "")
                            {
                                step.doctor = TestDoctor.BuildTestDoctorFromDataBase(stepsReader["IdDoctor"].ToString());
                            }
                            else
                            {
                                step.doctor = null;
                            }
                            step.idStep = Convert.ToString(stepsReader["IdStep"]);
                            steps.Add(step);
                        }
                    }
                }
            }
            if (steps.Count != 0)
            {
                return(steps);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 25
0
 public override bool MustHappenAfter(StepBase other)
 {
     return(other is AddTablesStep || other is DropFieldsStep);
 }
Exemplo n.º 26
0
 public override bool MustHappenAfter(StepBase other)
 {
     return(other is DropChangedFieldsStep);
 }
Exemplo n.º 27
0
 public override bool MustHappenAfter(StepBase other)
 {
     return(other is AddFulltextCatalogsStep || other is DropFulltextIndexesStep ||
            other is AddFieldsStep || other is AddIndexesStep || other is RenameTablesStep);
 }
Exemplo n.º 28
0
 public override bool MustHappenAfter(StepBase other)
 {
     return(other is AlterFieldsStep);
 }
        private async Task <StepResult> RunStepAsync(StepBase step)
        {
            var stepResult    = new StepResult(step);
            var startDateTime = DateTime.Now;

            stepResult.StepStartTime = startDateTime;

            try
            {
                switch (step)
                {
                case OpenAppStep openAppStep:
                {
                    var appPath = GetDependentValue(openAppStep.AppPath);
                    _Process             = Process.Start(appPath);
                    stepResult.IsSuccess = true;
                    stepResult.InfoItem  = appPath;
                    break;
                }

                case CloseAppStep closeAppStep:
                {
                    var appPath = GetDependentValue(closeAppStep.AppPath);
                    _Process.Kill();
                    _Process.WaitForExit();
                    stepResult.IsSuccess = true;
                    stepResult.InfoItem  = appPath;
                    break;
                }

                case GetAppWindowStep getAppWindowStep:
                    stepResult = await RunElementStepAsync(RootElement, getAppWindowStep);

                    stepResult.StepStartTime = startDateTime;
                    var getAppWindowStepResult = (ElementStepResult)stepResult;
                    _AppElement          = getAppWindowStepResult.AutomationElement;
                    stepResult.IsSuccess = _AppElement != null;
                    stepResult.InfoItem  = getAppWindowStepResult.ElementName;
                    break;

                case ElementStepBase elementStepBase:
                {
                    if (_AppElement == null)
                    {
                        throw new Exception("The app window has not been obtained.");
                    }

                    stepResult = await RunElementStepAsync(_AppElement, elementStepBase);

                    stepResult.StepStartTime = startDateTime;
                    var elementStepResult = (ElementStepResult)stepResult;
                    stepResult.IsSuccess = elementStepResult.AutomationElement != null;
                    stepResult.InfoItem  = $"Element: {elementStepResult.ElementName}";
                    break;
                }

                case IExecutable executable:
                    stepResult = new StepResult(step)
                    {
                        StepStartTime = DateTime.Now
                    };
                    var returnValue = await executable.Execute();

                    stepResult.Value = returnValue.ToString();
                    //Correct?
                    stepResult.InfoItem  = stepResult.Value;
                    stepResult.IsSuccess = true;
                    break;

                case SendKeyStep sendKeyStep:
                    WindowsAPI.SendKeyPress(sendKeyStep.KeyCode);
                    stepResult.IsSuccess = true;
                    break;

                case WaitStep waitStep:
                    await Task.Delay(waitStep.Milliseconds);

                    stepResult.InfoItem  = $"{ waitStep.Milliseconds} milliseconds";
                    stepResult.IsSuccess = true;
                    break;

                case MemoryUsageSnapshotStep memoryUsageSnapshotStep:
                    _Process?.Refresh();
                    var memstepResult = new MemoryUsageSnapshotResult(step, _Process?.WorkingSet64);
                    stepResult.StepStartTime = startDateTime;
                    stepResult           = memstepResult;
                    stepResult.InfoItem  = $"Memory Usage: { _Process?.WorkingSet64} ";
                    stepResult.IsSuccess = _Process != null;
                    break;
                }
            }
            catch (Exception ex)
            {
                stepResult.Exception = ex;
                stepResult.IsSuccess = false;
            }

            stepResult.StepFinishTime = DateTime.Now;

            return(stepResult);
        }
Exemplo n.º 30
0
 public new static void BeforeFeatureStep(FeatureContext featureContext)
 {
     StepBase.BeforeFeatureStep(featureContext);
 }
Exemplo n.º 31
0
        private async Task RunStepAsync(
            FabricClient fabricClient,
            FabricTestAction action,
            ActionStateBase actionState,
            CancellationToken cancellationToken,
            ServiceInternalFaultInfo serviceInternalFaultInfo)
        {
            StepStateNames state = actionState.StateProgress.Peek();

            TestabilityTrace.TraceSource.WriteInfo(TraceType, "Running state={0}, name={1}, key={2}", state, actionState.ActionType, actionState.OperationId);

            StepBase actionUnit = null;

            actionUnit = action.GetStep(fabricClient, actionState, state, cancellationToken);

            TestabilityTrace.TraceSource.WriteInfo(TraceType, "{0} - Running {1}", actionState.OperationId, actionUnit.StepName);
            try
            {
                while (true)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    RollbackState readRollbackState = await this.CheckUserCancellationAndUpdateIfNeededAsync(actionState, cancellationToken, FASConstants.InnerForwardLoop).ConfigureAwait(false);

                    TestabilityTrace.TraceSource.WriteInfo(TraceType, "{0} - readRollbackState={1}", actionState.OperationId, readRollbackState);

                    // If RetryStepWithoutRollingbackOnFailure == true, then don't allow graceful user cancel
                    if (!actionState.RetryStepWithoutRollingBackOnFailure && (readRollbackState == RollbackState.RollingBackDueToUserCancel))
                    {
                        TestabilityTrace.TraceSource.WriteInfo(TraceType, "{0} - read RollingBackDueToUserCancel breaking from Run loop inside RunStepAsync()", actionState.OperationId);
                        break;
                    }

                    // RollingBackForce always stops execution
                    if (readRollbackState == RollbackState.RollingBackForce)
                    {
                        break;
                    }

                    Exception runException = null;
                    try
                    {
                        TestabilityTrace.TraceSource.WriteInfo(TraceType, "{0}, {1} - calling Step.Run()", actionState.OperationId, actionState.ActionType);
                        ActionStateBase newContext = await actionUnit.RunAsync(cancellationToken, serviceInternalFaultInfo).ConfigureAwait(false);

                        TestabilityTrace.TraceSource.WriteInfo(TraceType, "{0}, {1} - calling break after run", actionState.OperationId, actionState.ActionType);
                        break;
                    }
                    catch (Exception runExceptionTemp)
                    {
                        runException = runExceptionTemp;
                        TestabilityTrace.TraceSource.WriteWarning(TraceType, "{0}, {1} - runException {2}", actionState.OperationId, actionState.ActionType, runException);
                        if (actionState.RetryStepWithoutRollingBackOnFailure)
                        {
                            // trace and loop.  Should have /backoff/?
                            TestabilityTrace.TraceSource.WriteWarning(
                                TraceType,
                                "{0}, {1} has RetryStepWithoutRollingbackOnFailure set to true, retrying step name='{2}'.  Caught exception: {3}",
                                actionState.OperationId,
                                actionState.ActionType,
                                actionUnit.StepName,
                                runException);

                            this.ProcessRetryStepExceptions(actionState.OperationId, runException);
                        }
                        else
                        {
                            throw;
                        }
                    }

                    if (runException != null)
                    {
                        await Task.Delay(TimeSpan.FromSeconds(this.commandStepRetryBackoffInSeconds), cancellationToken).ConfigureAwait(false);
                    }
                }
            }
            catch (Exception e)
            {
                TestabilityTrace.TraceSource.WriteWarning(TraceType, "{0} - RunState, error: {1}", actionState.OperationId, e.ToString());
                throw;
            }
        }
Exemplo n.º 32
0
 public override bool MustHappenBefore(StepBase other)
 {
     return(other is AddStoredProcsStep);
 }
Exemplo n.º 33
0
        private async Task CleanupStepAsync(
            FabricClient fabricClient,
            FabricTestAction action,
            ActionStateBase actionState,
            CancellationToken cancellationToken,
            ServiceInternalFaultInfo serviceInternalFaultInfo)
        {
            StepStateNames state = actionState.StateProgress.Peek();

            TestabilityTrace.TraceSource.WriteInfo(TraceType, "Cleaning up state={0}, name={1}, key={2}", state, actionState.ActionType, actionState.OperationId);

            StepBase actionUnit = null;

            actionUnit = action.GetStep(fabricClient, actionState, state, cancellationToken);

            TestabilityTrace.TraceSource.WriteInfo(TraceType, "{0} - Cleaning up {1}", actionState.OperationId, actionUnit.StepName);

            try
            {
                while (true)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    RollbackState readRollbackState = await this.CheckUserCancellationAndUpdateIfNeededAsync(actionState, cancellationToken, FASConstants.InnerCleanupLoop).ConfigureAwait(false);

                    if (readRollbackState == RollbackState.RollingBackDueToUserCancel)
                    {
                        // Do nothing, already rolling back
                        TestabilityTrace.TraceSource.WriteWarning(TraceType, "{0} - Inner cleanup loop read RollingBackDueToUserCancel", actionState.OperationId);
                    }
                    else if (readRollbackState == RollbackState.RollingBackForce)
                    {
                        TestabilityTrace.TraceSource.WriteWarning(TraceType, "{0} - Inner cleanup loop read RollingBackForce", actionState.OperationId);
                        break;
                    }

                    try
                    {
                        await actionUnit.CleanupAsync(cancellationToken).ConfigureAwait(false);

                        actionState.StateProgress.Pop();
                        break;
                    }
                    catch (Exception cleanupException)
                    {
                        TestabilityTrace.TraceSource.WriteWarning(
                            TraceType,
                            "{0} - Cleanup of action type={1}, failed with {2}, retrying",
                            actionState.OperationId,
                            actionState.ActionType,
                            cleanupException);
                    }

                    await Task.Delay(TimeSpan.FromSeconds(this.commandStepRetryBackoffInSeconds), cancellationToken).ConfigureAwait(false);
                }
            }
            catch (Exception e)
            {
                TestabilityTrace.TraceSource.WriteWarning(TraceType, "{0} - CleanupStepAsync, error: {1}", actionState.OperationId, e.ToString());
                throw;
            }
        }