Beispiel #1
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);
        }
Beispiel #2
0
        public Task <IEnumerable <ActionStateBase> > GetRunningActionsAsync()
        {
            TestCommandListDescription description = new TestCommandListDescription(
                TestCommandStateFilter.Running | TestCommandStateFilter.RollingBack,
                TestCommandTypeFilter.All);

            return(this.GetSelectedActionsAsync(description));
        }
Beispiel #3
0
        // This doesn't run in automation, but it is being kept here so it can be run as a small test.
        // See FaultAnalysisServiceTruncate.test for a test on this code path.
        private void TestTruncate()
        {
            this.StartActionIfItHasNotBeenStarted(Command.StuckAction);
            this.StartActionIfItHasNotBeenStarted(Command.FailoverManagerDataLoss);
            this.StartActionIfItHasNotBeenStarted(Command.InvokeDataLossMidActionTestFatal);
            this.StartActionIfItHasNotBeenStarted(Command.InvokeDataLossMidActionTestTransient);

            this.StartActionIfItHasNotBeenStarted(Command.RestartPartitionMidActionTestFatal);
            this.StartActionIfItHasNotBeenStarted(Command.RestartPartitionMidActionTestTransient);

            this.WaitForActionCount(FASConstants.TestMaxStoredActionCountValue);

            // Confirm this action is still stuck - ie that an action not in terminal state is not removed
            this.mockClient.WaitForState(MockClient.MockClientCommandInfo[Command.StuckAction], Actions.Steps.StepStateNames.LookingUpState);
            this.mockClient.WaitForState(MockClient.MockClientCommandInfo[Command.RestartPartitionMidActionTestTransient], Actions.Steps.StepStateNames.CompletedSuccessfully);

            // At this point there should be 1 command in the actionTable, StuckAction, and somewhere between 2 (Constants.TestMaxStoredActionCountValue) and 5 (the total number of possible
            // completed commands) commands in the historyTable.  In steady state, after truncates have run, the historyTable should have 2 (Constants.TestMaxStoredActionCountValue) commands remaining,
            // and they should be the ones that completed last.  Since this test only allows 1 action at a time, this will always be the 2 that were started last -
            // the RestartPartition ones.
            bool conditionSatisfied = false;
            var  timeoutHelper      = new System.Fabric.Common.TimeoutHelper(TimeSpan.FromSeconds(3 * FASConstants.TestStoredActionCleanupIntervalInSeconds));

            do
            {
                TestCommandListDescription queryDescription = new TestCommandListDescription(Query.TestCommandStateFilter.CompletedSuccessfully, Query.TestCommandTypeFilter.PartitionRestart);
                TestCommandQueryResult     queryResult      = this.mockClient.GetTestCommandListAsync(queryDescription).GetAwaiter().GetResult();
                List <TestCommandStatus>   result           = queryResult.Items;

                if (result.Count < FASConstants.TestMaxStoredActionCountValue)
                {
                    string error = string.Format(
                        CultureInfo.InvariantCulture,
                        "Number of commands in the historyTable {0} is below TestMaxStoredActionCountValue (config 'DefaultMaxStoredActionCount')",
                        result.Count);
                    TestabilityTrace.TraceSource.WriteError(TraceType, error);
                    System.Fabric.Common.ReleaseAssert.Failfast(error);
                }

                if (result.Where(c => c.TestCommandType == TestCommandType.PartitionRestart).Count() != FASConstants.TestMaxStoredActionCountValue)
                {
                    TestabilityTrace.TraceSource.WriteInfo(TraceType, "Number of PartitionRestart results is {0}, expecting {1}, retrying", result.Count, FASConstants.TestMaxStoredActionCountValue);
                    continue;
                }

                conditionSatisfied = true;
            }while (!conditionSatisfied && timeoutHelper.GetRemainingTime() > TimeSpan.Zero);

            System.Fabric.Common.ReleaseAssert.Failfast(string.Format(CultureInfo.InvariantCulture, "Did not reach expected target action, see traces above filtered by type~ActionTest'"));

            TestabilityTrace.TraceSource.WriteInfo(TraceType, "Exiting TestTruncate");
        }
        public NativeCommon.IFabricAsyncOperationContext BeginGetTestCommandStatusList(IntPtr description, uint timeoutMilliseconds, NativeCommon.IFabricAsyncOperationCallback callback)
        {
            var      managedDescription = TestCommandListDescription.CreateFromNative(description);
            TimeSpan managedTimeout     = TimeSpan.FromMilliseconds(timeoutMilliseconds);

            return(Utility.WrapNativeAsyncMethodImplementation(
                       (cancellationToken) =>
                       this.GetTestCommandListAsync(
                           managedDescription,
                           managedTimeout,
                           cancellationToken),
                       callback,
                       "FaultAnalysisServiceBroker.BeginGetTestCommandStatusList",
                       ThreadErrorMessageSetter));
        }
        public async Task <TestCommandQueryResult> ProcessGetTestCommandListAsync(TestCommandListDescription description)
        {
            // 5728192
            const int MaxNumberOfItems           = 10000;
            IEnumerable <ActionStateBase> result = await this.actionStore.GetSelectedActionsAsync(description);

            List <TestCommandStatus> list = new List <TestCommandStatus>();

            int end = Math.Min(result.Count(), MaxNumberOfItems);

            for (int i = 0; i < end; i++)
            {
                TestCommandProgressState state = FaultAnalysisServiceUtility.ConvertState(result.ElementAt(i), TraceType);
                TestCommandType          type  = ConvertType(result.ElementAt(i));

                list.Add(new TestCommandStatus(result.ElementAt(i).OperationId, state, type));
            }

            TestCommandQueryResult testCommandQueryResult = new TestCommandQueryResult(list);

            return(testCommandQueryResult);
        }
        public async Task <TestCommandQueryResult> GetTestCommandListAsync(
            TestCommandListDescription description,
            TimeSpan timeout,
            CancellationToken cancellationToken)
        {
            this.ThrowIfNotReady();

            TestCommandQueryResult result = null;

            try
            {
                result = await this.MessageProcessor.ProcessGetTestCommandListAsync(description).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                FaultAnalysisServiceUtility.ThrowTransientExceptionIfRetryable(e);

                throw;
            }

            return(result);
        }
Beispiel #7
0
 public Task <TestCommandQueryResult> GetTestCommandListAsync(TestCommandListDescription description)
 {
     return(this.messageProcessor.ProcessGetTestCommandListAsync(description));
 }
 private Task <TestCommandQueryResult> GetTestCommandListAsync(TestCommandListDescription description, TimeSpan timeout, CancellationToken cancellationToken)
 {
     return(this.service.GetTestCommandListAsync(description, timeout, cancellationToken));
 }