public TestCommandListDescription( TestCommandStateFilter commandStateFilter, TestCommandTypeFilter commandTypeFilter) { this.TestCommandStateFilter = commandStateFilter; this.TestCommandTypeFilter = commandTypeFilter; }
public async Task <IEnumerable <ActionStateBase> > GetSelectedActionsAsync(TestCommandListDescription description) { TestCommandStateFilter stateFilter = description.TestCommandStateFilter; TestCommandTypeFilter typeFilter = description.TestCommandTypeFilter; TestabilityTrace.TraceSource.WriteInfo(TraceType, "GetSelectedActionsAsync() stateFilter={0}, typeFilter={1}", stateFilter.ToString(), typeFilter.ToString()); List <ActionStateBase> selectedActions = new List <ActionStateBase>(); try { await FaultAnalysisServiceUtility.RunAndReportFaultOnRepeatedFailure( Guid.Empty, () => this.GetSelectedActionsInnerAsync(selectedActions, stateFilter, typeFilter), this.partition, "Replace", ActionStore.MaxRetries, this.cancellationToken).ConfigureAwait(false); } catch (Exception e) { TestabilityTrace.TraceSource.WriteError(TraceType, e.ToString()); throw; } return(selectedActions); }
// Used on service side internal static unsafe TestCommandListDescription CreateFromNative(IntPtr nativePtr) { NativeTypes.FABRIC_TEST_COMMAND_LIST_DESCRIPTION nativeDescription = *(NativeTypes.FABRIC_TEST_COMMAND_LIST_DESCRIPTION *)nativePtr; TestCommandStateFilter stateFilter = (TestCommandStateFilter)nativeDescription.TestCommandStateFilter; TestCommandTypeFilter typeFilter = (TestCommandTypeFilter)nativeDescription.TestCommandTypeFilter; return(new TestCommandListDescription(stateFilter, typeFilter)); }
public GetTestCommandStatusListRequest( IFabricClient fabricClient, TestCommandStateFilter stateFilter, TestCommandTypeFilter typeFilter, TimeSpan timeout) : base(fabricClient, timeout) { this.TestCommandStateFilter = stateFilter; this.TestCommandTypeFilter = typeFilter; this.RetryErrorCodes.Add((uint)NativeTypes.FABRIC_ERROR_CODE.FABRIC_E_NOT_READY); this.RetryErrorCodes.Add((uint)NativeTypes.FABRIC_ERROR_CODE.FABRIC_E_RECONFIGURATION_PENDING); }
private async Task AddActionsMatchingFilterAsync(IReliableDictionary <Guid, byte[]> dictionary, List <ActionStateBase> selectedActions, TestCommandStateFilter stateFilter, TestCommandTypeFilter typeFilter) { using (var tx = this.stateManager.CreateTransaction()) { var enumerable = await dictionary.CreateEnumerableAsync(tx).ConfigureAwait(false); var enumerator = enumerable.GetAsyncEnumerator(); while (await enumerator.MoveNextAsync(CancellationToken.None)) { ActionStateBase actionState = this.ReadData(enumerator.Current.Value); StepStateNames stateName = actionState.StateProgress.Peek(); if (MatchesStateFilter(actionState, stateFilter) && MatchesTypeFilter(actionState.ActionType, typeFilter)) { selectedActions.Add(actionState); } else { TestabilityTrace.TraceSource.WriteNoise(TraceType, "{0} - Current action does not match filter, not adding", actionState.OperationId); } } } }
private static bool MatchesStateFilter(ActionStateBase actionState, TestCommandStateFilter filter) { if (filter == TestCommandStateFilter.All) { return(true); } if (filter == TestCommandStateFilter.Default) { // future use return(true); } StepStateNames stateName = actionState.StateProgress.Peek(); RollbackState rollbackState = actionState.RollbackState; if (filter.HasFlag(TestCommandStateFilter.RollingBack)) { if ((rollbackState == RollbackState.RollingBackAndWillFailAction || rollbackState == RollbackState.RollingBackForce || rollbackState == RollbackState.RollingBackDueToUserCancel) && (stateName != StepStateNames.Failed)) { return(true); } } if (filter.HasFlag(TestCommandStateFilter.Cancelled)) { // stateName == CompletedSuccessfully is possible if the command was in its last step, and finished the last step successfully // before cancellation status was read. There is no point in "cancelling" since the point is to stop execution. Since it completed successfully, // that has been achieved. However, the status should be translated here so it is not confusing to user. if ((stateName == StepStateNames.Failed || stateName == StepStateNames.CompletedSuccessfully) && (rollbackState == RollbackState.RollingBackDueToUserCancel)) { return(true); } } if (filter.HasFlag(TestCommandStateFilter.ForceCancelled)) { // See notes above in Cancelled section, which also applies here. if ((stateName == StepStateNames.Failed || stateName == StepStateNames.CompletedSuccessfully) && (rollbackState == RollbackState.RollingBackForce)) { return(true); } } switch (stateName) { case StepStateNames.IntentSaved: return(filter.HasFlag(TestCommandStateFilter.Running)); case StepStateNames.LookingUpState: return(filter.HasFlag(TestCommandStateFilter.Running)); case StepStateNames.PerformingActions: return(filter.HasFlag(TestCommandStateFilter.Running)); case StepStateNames.CompletedSuccessfully: return(filter.HasFlag(TestCommandStateFilter.CompletedSuccessfully)); case StepStateNames.Failed: return(filter.HasFlag(TestCommandStateFilter.Failed)); default: return(false); } }
public async Task GetSelectedActionsInnerAsync(List <ActionStateBase> selectedActions, TestCommandStateFilter stateFilter, TestCommandTypeFilter typeFilter) { selectedActions.Clear(); // non-terminal state if (stateFilter.HasFlag(TestCommandStateFilter.Running) || stateFilter.HasFlag(TestCommandStateFilter.RollingBack)) { await this.AddActionsMatchingFilterAsync(this.actionTable, selectedActions, stateFilter, typeFilter).ConfigureAwait(false); } // terminal state if (stateFilter.HasFlag(TestCommandStateFilter.CompletedSuccessfully) || stateFilter.HasFlag(TestCommandStateFilter.Failed) || stateFilter.HasFlag(TestCommandStateFilter.Cancelled) || stateFilter.HasFlag(TestCommandStateFilter.ForceCancelled)) { await this.AddActionsMatchingFilterAsync(this.historyTable, selectedActions, stateFilter, typeFilter).ConfigureAwait(false); } }