use of com.axway.ats.agent.core.threading.patterns.RampUpPattern in project ats-framework by Axway.
the class DisabledTest_RampUpLoaderMultipleInvocations method rampUpPatternBlockingPositive.
@Test
public void rampUpPatternBlockingPositive() throws Exception {
RampUpPattern pattern = new RampUpPattern(10, true);
loader = LoadQueueFactory.createLoadQueue(QUEUE_NAME, actionRequests, pattern, new ArrayList<ParameterDataProvider>(), null);
//first schedule the threads
loader.scheduleThreads("IP", false);
Thread.sleep(1);
assertEquals(0, LoadTestActionClass.numExecutions);
QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_NAME);
//then start the loader
loader.start();
assertEquals(10, LoadTestActionClass.numExecutions);
}
use of com.axway.ats.agent.core.threading.patterns.RampUpPattern in project ats-framework by Axway.
the class LoadQueueFactory method createLoadQueue.
/**
* Create an action task load queue based on the threading pattern selected
*
* @param queueName name of the queue
* @param actionRequests the action requests to execute with this queue
* @param threadingPattern the threading pattern
* @return
* @throws NoSuchComponentException there is no registered component for one of the requested actions
* @throws NoSuchActionException one of the actions requested does not exist
* @throws NoCompatibleMethodFoundException if no action method is found, which corresponds to this request
* @throws ThreadingPatternNotSupportedException if the supplied threading pattern is not supported
*/
public static final QueueLoader createLoadQueue(String queueName, List<ActionRequest> actionRequests, ThreadingPattern threadingPattern, List<ParameterDataProvider> parameterDataProviders, List<QueueLoaderListener> listeners) throws NoSuchComponentException, NoSuchActionException, NoCompatibleMethodFoundException, ThreadingPatternNotSupportedException {
if (listeners == null) {
listeners = new ArrayList<QueueLoaderListener>();
}
if (threadingPattern.getClass() == AllAtOncePattern.class) {
//convert the "all at once" to "ramp up pattern"
AllAtOncePattern allAtOncePattern = (AllAtOncePattern) threadingPattern;
RampUpPattern rampUpPattern = new RampUpPattern(allAtOncePattern.getThreadCount(), allAtOncePattern.isBlockUntilCompletion(), allAtOncePattern.getIterationCount(), allAtOncePattern.getIntervalBetweenIterations());
rampUpPattern.setMinIntervalBetweenIterations(allAtOncePattern.getMinIntervalBetweenIterations());
rampUpPattern.setMaxIntervalBetweenIterations(allAtOncePattern.getMaxIntervalBetweenIterations());
rampUpPattern.setIterationTimeout(allAtOncePattern.getIterationTimeout());
return new RampUpQueueLoader(queueName, actionRequests, rampUpPattern, allAtOncePattern, parameterDataProviders, listeners);
} else if (threadingPattern.getClass() == FixedDurationAllAtOncePattern.class) {
//convert the "fixed duration all at once" to "fixed duration ramp up pattern"
FixedDurationAllAtOncePattern allAtOncePattern = (FixedDurationAllAtOncePattern) threadingPattern;
FixedDurationRampUpPattern rampUpPattern = new FixedDurationRampUpPattern(allAtOncePattern.getThreadCount(), allAtOncePattern.isBlockUntilCompletion(), allAtOncePattern.getDuration(), allAtOncePattern.getIntervalBetweenIterations());
rampUpPattern.setMinIntervalBetweenIterations(allAtOncePattern.getMinIntervalBetweenIterations());
rampUpPattern.setMaxIntervalBetweenIterations(allAtOncePattern.getMaxIntervalBetweenIterations());
rampUpPattern.setIterationTimeout(threadingPattern.getIterationTimeout());
return new RampUpQueueLoader(queueName, actionRequests, rampUpPattern, allAtOncePattern, parameterDataProviders, listeners);
} else if (threadingPattern.getClass() == RampUpPattern.class || threadingPattern.getClass() == FixedDurationRampUpPattern.class) {
//this is a real ramp-up pattern
return new RampUpQueueLoader(queueName, actionRequests, (RampUpStartPattern) threadingPattern, (ExecutionPattern) threadingPattern, parameterDataProviders, listeners);
} else {
throw new ThreadingPatternNotSupportedException(threadingPattern.getClass().getSimpleName());
}
}
use of com.axway.ats.agent.core.threading.patterns.RampUpPattern in project ats-framework by Axway.
the class DisabledTest_MultiThreadedActionHandler method executeActionsRampUpPatternBlockingWithRampUpPositiveMultipleInvocations.
@Test
public void executeActionsRampUpPatternBlockingWithRampUpPositiveMultipleInvocations() throws Exception {
RampUpPattern pattern = new RampUpPattern(10, true, 2, 1000, 2000, 5);
//then start the queue
long startTime = Calendar.getInstance().getTimeInMillis();
QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_1);
actionHandler.executeActions("IP", QUEUE_1, -1, actionRequests, pattern, new LoaderDataConfig());
long executionTime = Calendar.getInstance().getTimeInMillis() - startTime;
assertTrue(executionTime >= 4000);
assertTrue(executionTime < 6000);
expectedNumExecutions = 20;
}
use of com.axway.ats.agent.core.threading.patterns.RampUpPattern in project ats-framework by Axway.
the class DisabledTest_MultiThreadedActionHandler method startRampUpPatternBlockingWithRampUpPositive.
@Test
public void startRampUpPatternBlockingWithRampUpPositive() throws Exception {
RampUpPattern pattern = new RampUpPattern(10, true, 1, 0, 1000, 2);
actionHandler.scheduleActions("IP", QUEUE_1, -1, actionRequests, pattern, new LoaderDataConfig(), false);
//then start the queue
long startTime = Calendar.getInstance().getTimeInMillis();
actionHandler.startQueue(QUEUE_1);
long executionTime = Calendar.getInstance().getTimeInMillis() - startTime;
assertTrue(executionTime >= 4000);
assertTrue(executionTime < 7000);
expectedNumExecutions = 10;
}
use of com.axway.ats.agent.core.threading.patterns.RampUpPattern in project ats-framework by Axway.
the class DisabledTest_MultiThreadedActionHandler method getRunningQueuesCountPositive.
@Test
public void getRunningQueuesCountPositive() throws Exception {
RampUpPattern pattern = new RampUpPattern(3, false, 3, 1000, 200, 2);
assertEquals(0, actionHandler.getRunningQueuesCount());
QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_1);
//first queue finished
actionHandler.executeActions("IP", QUEUE_1, -1, actionRequests, pattern, new LoaderDataConfig());
assertEquals(1, actionHandler.getRunningQueuesCount());
QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_2);
//second queue running
actionHandler.executeActions("IP", QUEUE_2, -1, actionRequests, pattern, new LoaderDataConfig());
assertEquals(2, actionHandler.getRunningQueuesCount());
//third queue scheduled
actionHandler.scheduleActions("IP", "test 3", -1, actionRequests, pattern, new LoaderDataConfig(), false);
assertEquals(2, actionHandler.getRunningQueuesCount());
//wait until the queue finishes
actionHandler.waitUntilAllQueuesFinish();
assertEquals(0, actionHandler.getRunningQueuesCount());
}
Aggregations