示例#1
0
        private void StartLoadTestAsync(LoadTestScenario scenario, FactoryContext context)
        {
            IRequestFactory factory = null;
            try
            {
                RequestCommand command = PrepareCommand(scenario, context);
                Synchronize(scenario, context); // await for a configurable period of time.

                if (context.Aborted)
                {
                    return; // sanity.
                }
                context.Status = ExecutionStatus.Executing;
                factory = new ProfiledVirtualUserNetwork(command);
                context.RequestFactory = factory;
                factory.Execute();

                if (!context.Aborted) //
                {
                    context.Status = ExecutionStatus.Completed;
                }
            }
            catch (Exception fault)
            {
                if (factory != null)
                {
                    factory.Abort(); // kill pending requests.
                }
                log.Error(Fault.DroneService_Faulted.FormatWith(fault.Message), fault);
                context.Status = ExecutionStatus.Faulted;
            }
            finally
            {
                context.RequestFactory = null;
            }
        }
示例#2
0
        private void Synchronize(LoadTestScenario scenario, FactoryContext context)
        {
            if (!scenario.StartDate.HasValue)
            {
                log.Debug(Debugging.DroneService_NoSleep);
                return;
            }
            DateTime now = DateTime.UtcNow;

            var remaining = scenario.StartDate.Value - now;
            if (remaining > TimeSpan.Zero)
            {
                log.Debug(Debugging.DroneService_Idle.FormatWith(remaining.TotalSeconds));
                context.Status = ExecutionStatus.Synchronizing;
                Thread.Sleep(remaining);
                log.Debug(Debugging.DroneService_Resumed);
            }
        }
示例#3
0
        private RequestCommand PrepareCommand(LoadTestScenario scenario, FactoryContext context)
        {
            context.Status = ExecutionStatus.Preparing; // acknowledge.

            var command = new RequestCommand
            {
                ExecutionId = scenario.ExecutionId,
                Client = requestService.GetClient(scenario),
                Requests = requestService.ParseRequests(scenario),
                Users = scenario.Users,
                Reporting = GetReportObject(scenario)
            };
            return command;
        }