Search in sources :

Example 1 with UserAction

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()));
}
Also used : UserAction(org.activityinfo.test.capacity.action.UserAction) UserRole(org.activityinfo.test.capacity.model.UserRole) ActionExecution(org.activityinfo.test.capacity.action.ActionExecution)

Aggregations

ActionExecution (org.activityinfo.test.capacity.action.ActionExecution)1 UserAction (org.activityinfo.test.capacity.action.UserAction)1 UserRole (org.activityinfo.test.capacity.model.UserRole)1