Ejemplo n.º 1
0
        public VirtualUserNetwork(RequestCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }
            if (command.Requests == null || command.Requests.Count == 0)
            {
                throw new ArgumentOutOfRangeException("command", Arguments.VirtualUserNetwork_EmptyCommandRequests);
            }
            if (command.Users == null)
            {
                throw new ArgumentNullException("command.Users");
            }
            if (command.Users.Amount < 1)
            {
                throw new ArgumentOutOfRangeException("command.Users.Amount", Arguments.VirtualUserNetwork_AmountNotGreaterThanZero);
            }
            ExecutionId = command.ExecutionId;
            Guid = Guid.NewGuid();
            Id = Guid.ToString().Split('-').First().ToUpper();

            userSettings = command.Users;
            taskScheduler = new WorkStealingTaskScheduler(userSettings.Amount);
            tokenSource = new CancellationTokenSource();
            queue = new ConcurrentQueue<IRestRequest>(command.Requests);

            users = new ConcurrentBag<VirtualUser>();

            RestClient = command.Client;
            SleepTime = command.Users.SleepTime;
        }
Ejemplo n.º 2
0
        public ProfiledVirtualUserNetwork(RequestCommand command)
            : base(command)
        {
            if (command.Reporting == null)
                command.Reporting = Report.Null;

            totalRequests = command.Requests.Count;
            report = command.Reporting;
            period = new ConcurrentBag<ProfileItem>();
            periodPending = new ConcurrentDictionary<IRestRequest, RequestItem>();
            signal = new AutoResetEvent(false);
        }
Ejemplo n.º 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;
        }