use of com.axway.ats.agent.core.threading.patterns.AllAtOncePattern in project ats-framework by Axway.
the class Test_QueueCanceling method allAtOnce_OneThreadReallyRunning_OneThreadPaused.
/**
* All(or most of) the tests in this class let the actions do SLEEP (the internal thread state is TIMED_WAITING) while mean running.
* In this test, the threads are really running(the internal thread state is RUNNABLE).
* When we cancel the queue, one of the is RUNNING its first iteration, the other thread is sleeping between its first and second iterations.
*/
@Test
public void allAtOnce_OneThreadReallyRunning_OneThreadPaused() throws Exception {
expectedNumExecutions = 2;
ListDataConfig parameterData = new ListDataConfig("runTime", Arrays.asList(new String[] { "500", "2000" }), ParameterProviderLevel.PER_THREAD_STATIC);
LoaderDataConfig loaderDataConfig = new LoaderDataConfig();
loaderDataConfig.addParameterConfig(parameterData);
actionRequests.add(new ActionRequest(TEST_COMPONENT_NAME, ACTION_RUNNING, new Object[] { "runTime" }));
AllAtOncePattern pattern = new AllAtOncePattern(2, false, 2, 1000);
QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_NAME);
actionHandler.scheduleActions(HOST, QUEUE_NAME, -1, actionRequests, pattern, loaderDataConfig, false);
actionHandler.startQueue(QUEUE_NAME);
Thread.sleep(1000);
}
use of com.axway.ats.agent.core.threading.patterns.AllAtOncePattern in project ats-framework by Axway.
the class Test_QueueCanceling method allAtOnce_BothThreadsPaused.
/**
* Both threads are canceled while waiting between 1st and 2nd iterations
*/
@Test
public void allAtOnce_BothThreadsPaused() throws Exception {
expectedNumExecutions = 2;
actionRequests.add(new ActionRequest(TEST_COMPONENT_NAME, ACTION_SLEEP, new Object[] { "500" }));
AllAtOncePattern pattern = new AllAtOncePattern(2, false, 2, 1000);
QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_NAME);
actionHandler.scheduleActions(HOST, QUEUE_NAME, -1, actionRequests, pattern, new LoaderDataConfig(), false);
actionHandler.startQueue(QUEUE_NAME);
Thread.sleep(1000);
}
use of com.axway.ats.agent.core.threading.patterns.AllAtOncePattern in project ats-framework by Axway.
the class Test_QueueCanceling method allAtOnce_SetMaxSpeed_OneThreadRunning_OneThreadPaused.
/**
* Both threads will do 1 iteration.
* There won`t be any 3rd iteration, the remaining 3rd iteration cannot be added to no thread, so both threads will wait for 30 seconds.
*
* At this moment we will cancel all threads
*/
@Test
public void allAtOnce_SetMaxSpeed_OneThreadRunning_OneThreadPaused() throws Exception {
expectedNumExecutions = 3;
actionRequests.add(new ActionRequest(TEST_COMPONENT_NAME, ACTION_SLEEP, new Object[] { "500" }));
AllAtOncePattern pattern = new AllAtOncePattern(2, false, 5, 500);
pattern.setExecutionSpeed(30, 3);
QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_NAME);
actionHandler.scheduleActions(HOST, QUEUE_NAME, -1, actionRequests, pattern, new LoaderDataConfig(), false);
actionHandler.startQueue(QUEUE_NAME);
Thread.sleep(1500);
}
use of com.axway.ats.agent.core.threading.patterns.AllAtOncePattern in project ats-framework by Axway.
the class Test_QueueCanceling method allAtOnce_SetMaxSpeed.
@Test
public void allAtOnce_SetMaxSpeed() throws Exception {
expectedNumExecutions = 9;
actionRequests.add(new ActionRequest(TEST_COMPONENT_NAME, ACTION_SLEEP, new Object[] { "500" }));
AllAtOncePattern pattern = new AllAtOncePattern(9, false);
pattern.setExecutionSpeed(30, 15);
QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_NAME);
actionHandler.scheduleActions(HOST, QUEUE_NAME, -1, actionRequests, pattern, new LoaderDataConfig(), false);
actionHandler.startQueue(QUEUE_NAME);
Thread.sleep(1500);
}
use of com.axway.ats.agent.core.threading.patterns.AllAtOncePattern in project ats-framework by Axway.
the class Test_QueueCanceling method allAtOnce_SynchronizedActions.
/**
* 2 threads are run synchronized, 1 thread will do its iteration and will be put in sleep by
* the Thread Manager waiting until the 2 (slower) finish its iteration.
* This is the moment we will cancel the queue.
*/
@Test
public void allAtOnce_SynchronizedActions() throws Exception {
expectedNumExecutions = 2;
final String paramName = "sleepTime";
ListDataConfig parameterData = new ListDataConfig(paramName, Arrays.asList(new String[] { "500", "1500" }), ParameterProviderLevel.PER_THREAD_STATIC);
LoaderDataConfig loaderDataConfig = new LoaderDataConfig();
loaderDataConfig.addParameterConfig(parameterData);
actionRequests.add(new ActionRequest(TEST_COMPONENT_NAME, ACTION_SLEEP, new Object[] { paramName }));
AllAtOncePattern pattern = new AllAtOncePattern(2, false, 2, 0);
pattern.setUseSynchronizedIterations(true);
QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_NAME);
actionHandler.scheduleActions(HOST, QUEUE_NAME, -1, actionRequests, pattern, loaderDataConfig, true);
actionHandler.startQueue(QUEUE_NAME);
Thread.sleep(1000);
}
Aggregations