Ejemplo n.º 1
0
        private async Task ExecuteTestActionAsync(FabricTestAction testAction, CancellationToken token)
        {
            ReleaseAssert.AssertIf(testAction == null, "testAction should not be null");
            string testActionId = testAction.ToString() + testAction.GetHashCode();
            string actionName   = testAction.GetType().Name;

            // wait for random time duration.
            double pauseMilliseconds = this.random.NextDouble() * this.ChaosParameters.WaitTimeBetweenFaults.TotalMilliseconds;

            TestabilityTrace.TraceSource.WriteInfoWithId(TraceType, testActionId, "Pausing for {0} milliseconds before executing next action", pauseMilliseconds);
            await Task.Delay(TimeSpan.FromMilliseconds(pauseMilliseconds), token).ConfigureAwait(false);

            // create an id for action for tracing.
            TestabilityTrace.TraceSource.WriteInfoWithId(TraceType, testActionId, "Executing action: {0}", actionName);

            // Execute this action linked token.
            await this.TestContext.ActionExecutor.RunAsync(testAction, token).ContinueWith(t =>
            {
                this.HandleTaskComplete(t, testActionId, actionName);
            }).ConfigureAwait(false);

            TestabilityTrace.TraceSource.WriteInfoWithId(TraceType, testActionId, "Action {0} completed.", testAction.GetType().Name);
        }
Ejemplo n.º 2
0
        private async Task ExecuteTestActionAsync(FabricTestAction testAction, CancellationToken token)
        {
            ReleaseAssert.AssertIf(testAction == null, "testAction should not be null");
            string testActionId = testActionId = testAction.ToString() + testAction.GetHashCode();
            string actionName   = testAction.GetType().Name;
            // wait for random time duration.
            int pauseMilliseconds = (int)(this.random.NextDouble() * this.chaosScenarioParameters.WaitTimeBetweenFaults.TotalMilliseconds);

            Log.WriteInfoWithId(TraceType, testActionId, "Pausing for {0} milliseconds before executing next action", pauseMilliseconds);
            await Task.Delay((int)pauseMilliseconds);

            // create an id for action for tracing.
            Log.WriteInfoWithId(TraceType, testActionId, "Executing action: {0}", actionName);

            // Execute this action linked token.
            Task testActionTask = this.TestContext.ActionExecutor.RunAsync(testAction, token).ContinueWith(t =>
            {
                this.HandleTaskComplete(t, testActionId, actionName);
            });

            await testActionTask;

            Log.WriteInfoWithId(TraceType, testActionId, "Action {0} completed.", testAction.GetType().Name);
        }