use of org.activityinfo.test.capacity.action.UserAction in project activityinfo by bedatadriven.
the class ScenarioRun method run.
private void run(int dayNumber) throws InterruptedException {
List<Runnable> tasks = Lists.newArrayList();
// Enumerate all the tasks that users need to accomplish today
for (UserRole user : scenario.getUsers()) {
Optional<UserAction> task = user.getTask(dayNumber);
if (task.isPresent()) {
tasks.add(new ActionExecution(context, user, task.get()));
}
}
// Randomize queue priority
Collections.shuffle(tasks);
LOGGER.info(String.format("%s: Day %d starting...", scenario.toString(), dayNumber));
// Enqueue and wait for all users to finish
LoadExecutor loadExecutor = new LoadExecutor(executorService);
loadExecutor.setMaxConcurrent(LogisticGrowthFunction.rampUpTo(CapacityTest.MAX_CONCURRENT_USERS).during(Period.seconds(90)));
loadExecutor.execute(tasks);
LOGGER.info(String.format("%s: Run complete.", scenario.toString()));
}
Aggregations