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); }
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); }
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)); }
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); }
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); }
protected void OnStepCompleted(StepBase step) { if (step.check()) { isStart = true; m_Current = step.id + 1; } }
public void BeforeScenario() { if (!DoneBeforeScenarioAlready) { StepBase.CreateBrowser(ConfigurationManager.AppSettings["BrowserType"]); Console.WriteLine("selenium open Called"); BeforeScenarioDoneAlready = true; } }
public TestStepBase(StepBase s, string caseLpu) { if (s != null) step = s; if (s.Doctor != null) { doctor = new TestDoctor(s.Doctor, caseLpu); } }
protected T GetInterface <T>(StepBase stepBase) { T step = stepBase.GetComponent <T>(); if (step == null) { return(default(T)); } return(step); }
public TestStepBase(StepBase s, string caseLpu) { if (s != null) { step = s; } if (s.Doctor != null) { doctor = new TestDoctor(s.Doctor, caseLpu); } }
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); }
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); } }
public override bool MustHappenBefore(StepBase other) { return(other is DropTablesStep); }
public override bool MustHappenAfter(StepBase other) { return(other is SetNotNullStep || other is AddFkeysStep || other is AddSequencesStep || other is AddTriggersStep || other is AddStoredProcsStep); }
public override bool MustHappenBefore(StepBase other) { return(other is AddFkeysStep); }
// Must happen last - after everything! public override bool MustHappenAfter(StepBase other) { return(true); }
public override bool MustHappenAfter(StepBase other) { return(other is DropIndexesStep || other is SetNotNullStep); }
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); } }
public override bool MustHappenAfter(StepBase other) { return(other is DropSequencesStep || other is AddFkeysStep); }
public override bool MustHappenBefore(StepBase other) { return(other is SetNullStep); }
public override bool MustHappenBefore(StepBase other) { return(other is AddTablesStep || other is RenameTablesStep || other is AddFieldsStep); }
public MemoryUsageSnapshotResult(StepBase step, long?memoryUsage) : base(step) { MemoryUsage = memoryUsage; }
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); } }
public override bool MustHappenAfter(StepBase other) { return(other is AddTablesStep || other is DropFieldsStep); }
public override bool MustHappenAfter(StepBase other) { return(other is DropChangedFieldsStep); }
public override bool MustHappenAfter(StepBase other) { return(other is AddFulltextCatalogsStep || other is DropFulltextIndexesStep || other is AddFieldsStep || other is AddIndexesStep || other is RenameTablesStep); }
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); }
public new static void BeforeFeatureStep(FeatureContext featureContext) { StepBase.BeforeFeatureStep(featureContext); }
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; } }
public override bool MustHappenBefore(StepBase other) { return(other is AddStoredProcsStep); }
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; } }