public TestCommandListDescription(
     TestCommandStateFilter commandStateFilter,
     TestCommandTypeFilter commandTypeFilter)
 {
     this.TestCommandStateFilter = commandStateFilter;
     this.TestCommandTypeFilter  = commandTypeFilter;
 }
Example #2
0
        private static bool MatchesTypeFilter(ActionType actionType, TestCommandTypeFilter filter)
        {
            if (filter == TestCommandTypeFilter.All)
            {
                return(true);
            }

            if (filter == TestCommandTypeFilter.Default)
            {
                // future use
                return(true);
            }

            switch (actionType)
            {
            case ActionType.InvokeDataLoss:
                return(filter.HasFlag(TestCommandTypeFilter.PartitionDataLoss));

            case ActionType.InvokeQuorumLoss:
                return(filter.HasFlag(TestCommandTypeFilter.PartitionQuorumLoss));

            case ActionType.RestartPartition:
                return(filter.HasFlag(TestCommandTypeFilter.PartitionRestart));

            case ActionType.StartNode:
            case ActionType.StopNode:
                return(filter.HasFlag(TestCommandTypeFilter.NodeTransition));

            default:
                return(false);
            }
        }
Example #3
0
        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);
        }
Example #6
0
        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);
                    }
                }
            }
        }
Example #7
0
        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);
            }
        }