コード例 #1
0
            protected override async Task ExecuteActionAsync(FabricTestContext testContext, ValidateApplicationServicesAction action, CancellationToken cancellationToken)
            {
                ThrowIf.Null(action.ApplicationName, "ApplicationName");
                TimeoutHelper helper = new TimeoutHelper(action.MaximumStabilizationTimeout);

                // TODO: make these actions which store state locally as well.
                var serviceListResult = await FabricClientRetryHelper.ExecuteFabricActionWithRetryAsync(
                    () => testContext.FabricClient.QueryManager.GetServiceListAsync(
                        action.ApplicationName,
                        null,
                        action.RequestTimeout,
                        cancellationToken),
                    helper.GetRemainingTime(),
                    cancellationToken).ConfigureAwait(false);

                List <Task> serviceValidationTasks = new List <Task>();

                foreach (Service serviceResult in serviceListResult)
                {
                    var validateService = new ValidateServiceAction(serviceResult.ServiceName, helper.GetRemainingTime())
                    {
                        ActionTimeout  = action.ActionTimeout,
                        RequestTimeout = action.RequestTimeout,
                        CheckFlag      = action.CheckFlag
                    };

                    serviceValidationTasks.Add(testContext.ActionExecutor.RunAsync(validateService, cancellationToken));
                }

                await Task.WhenAll(serviceValidationTasks.ToArray()).ConfigureAwait(false);

                ResultTraceString = StringHelper.Format("ValidateApplicationServicesAction succeeded for {0}", action.ApplicationName);
            }
コード例 #2
0
            // Throws exception if validation was unsuccessful.
            protected override async Task ExecuteActionAsync(FabricTestContext testContext, ValidateSystemServicesAction action, CancellationToken token)
            {
                this.timer = new TimeoutHelper(action.MaximumStabilizationTimeout);

                // Get all system services
                var svcListResult = await FabricClientRetryHelper.ExecuteFabricActionWithRetryAsync(
                    () => testContext.FabricClient.QueryManager.GetServiceListAsync(
                        SystemApplicationName,
                        null,
                        action.RequestTimeout,
                        token),
                    this.timer.GetRemainingTime(),
                    token).ConfigureAwait(false);

                List <Task> tasks = new List <Task>();

                foreach (Service svcResult in svcListResult)
                {
                    var validateService = new ValidateServiceAction(svcResult.ServiceName, this.timer.GetRemainingTime())
                    {
                        ActionTimeout  = action.ActionTimeout,
                        RequestTimeout = action.RequestTimeout,
                        CheckFlag      = action.CheckFlag
                    };

                    var task = testContext.ActionExecutor.RunAsync(validateService, token);
                    tasks.Add(task);
                    Trace.WriteNoise("ValidateSystemServicesActionHandler: Validation task added for service: {0}", svcResult.ServiceName.OriginalString);
                }

                await Task.WhenAll(tasks).ConfigureAwait(false);

                ResultTraceString = "ValidateSystemServicesActionHandler completed successfully";
            }