Search in sources :

Example 1 with UserRole

use of org.activityinfo.test.capacity.model.UserRole in project activityinfo by bedatadriven.

the class CapacityTest method addScenario.

private void addScenario(Scenario scenario) {
    ScenarioContext scenarioContext = new ScenarioContext(context);
    DevServerAccounts accounts = scenarioContext.getAccounts();
    accounts.setBatchingEnabled(true);
    for (UserRole user : scenario.getUsers()) {
        UserAccount account = accounts.ensureAccountExists(user.getNickName());
        LOGGER.fine(String.format("Created User: %s: %s", account.getEmail(), user.getNickName()));
    }
    accounts.flush();
    scenarios.add(scenario);
}
Also used : ScenarioContext(org.activityinfo.test.capacity.model.ScenarioContext) UserRole(org.activityinfo.test.capacity.model.UserRole) DevServerAccounts(org.activityinfo.test.sut.DevServerAccounts) UserAccount(org.activityinfo.test.sut.UserAccount)

Example 2 with UserRole

use of org.activityinfo.test.capacity.model.UserRole 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

UserRole (org.activityinfo.test.capacity.model.UserRole)2 ActionExecution (org.activityinfo.test.capacity.action.ActionExecution)1 UserAction (org.activityinfo.test.capacity.action.UserAction)1 ScenarioContext (org.activityinfo.test.capacity.model.ScenarioContext)1 DevServerAccounts (org.activityinfo.test.sut.DevServerAccounts)1 UserAccount (org.activityinfo.test.sut.UserAccount)1