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);
}
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()));
}
Aggregations