Search in sources :

Example 6 with FixedDurationRampUpPattern

use of com.axway.ats.agent.core.threading.patterns.FixedDurationRampUpPattern in project ats-framework by Axway.

the class DisabledTest_RampUpQueueLoaderFixedDuration method cancelTasksDuringExecutionPositive.

@Test
public void cancelTasksDuringExecutionPositive() throws Exception {
    ActionRequest actionRequest = new ActionRequest(TEST_COMPONENT_NAME, "sleep action", new Object[] { "10000" });
    ArrayList<ActionRequest> newActionRequests = new ArrayList<ActionRequest>();
    newActionRequests.add(actionRequest);
    FixedDurationRampUpPattern pattern = new FixedDurationRampUpPattern(3, false, 10, 0);
    loader = LoadQueueFactory.createLoadQueue(QUEUE_1, newActionRequests, pattern, new ArrayList<ParameterDataProvider>(), null);
    //first schedule the threads
    loader.scheduleThreads("IP", false);
    Thread.sleep(1);
    assertEquals(0, LoadTestActionClass.numExecutions);
    QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_1);
    //then start the loader
    loader.start();
    Thread.sleep(1000);
    loader.cancel();
    //assert that only the first execution took place
    assertEquals(3, LoadTestActionClass.numExecutions);
}
Also used : ActionRequest(com.axway.ats.agent.core.action.ActionRequest) ArrayList(java.util.ArrayList) FixedDurationRampUpPattern(com.axway.ats.agent.core.threading.patterns.FixedDurationRampUpPattern) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 7 with FixedDurationRampUpPattern

use of com.axway.ats.agent.core.threading.patterns.FixedDurationRampUpPattern in project ats-framework by Axway.

the class DisabledTest_RampUpQueueLoaderFixedDuration method cancelTasksBeforeStartPositive.

@Test
public void cancelTasksBeforeStartPositive() throws Exception {
    FixedDurationRampUpPattern pattern = new FixedDurationRampUpPattern(3, true, 10, 3000);
    loader = LoadQueueFactory.createLoadQueue(QUEUE_1, actionRequests, pattern, new ArrayList<ParameterDataProvider>(), null);
    QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_1);
    //first schedule the threads
    loader.scheduleThreads("IP", false);
    Thread.sleep(1);
    assertEquals(0, LoadTestActionClass.numExecutions);
    loader.cancel();
    assertEquals(0, LoadTestActionClass.numExecutions);
}
Also used : ArrayList(java.util.ArrayList) FixedDurationRampUpPattern(com.axway.ats.agent.core.threading.patterns.FixedDurationRampUpPattern) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 8 with FixedDurationRampUpPattern

use of com.axway.ats.agent.core.threading.patterns.FixedDurationRampUpPattern in project ats-framework by Axway.

the class DisabledTest_RampUpQueueLoaderFixedDuration method cancelFinishedTasksPositive.

@Test
public void cancelFinishedTasksPositive() throws Exception {
    FixedDurationRampUpPattern pattern = new FixedDurationRampUpPattern(3, false, 1, 100);
    loader = LoadQueueFactory.createLoadQueue(QUEUE_1, 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_1);
    //then start the loader
    loader.start();
    //sleep until the first and second iterations are executed
    Thread.sleep(1500);
    assertTrue(LoadTestActionClass.numExecutions > 20);
    loader.cancel();
}
Also used : ArrayList(java.util.ArrayList) FixedDurationRampUpPattern(com.axway.ats.agent.core.threading.patterns.FixedDurationRampUpPattern) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Aggregations

FixedDurationRampUpPattern (com.axway.ats.agent.core.threading.patterns.FixedDurationRampUpPattern)8 Test (org.junit.Test)7 BaseTest (com.axway.ats.agent.core.BaseTest)6 ArrayList (java.util.ArrayList)6 ActionRequest (com.axway.ats.agent.core.action.ActionRequest)2 ParameterDataProvider (com.axway.ats.agent.core.threading.data.ParameterDataProvider)1 ThreadingPatternNotSupportedException (com.axway.ats.agent.core.threading.exceptions.ThreadingPatternNotSupportedException)1 QueueLoaderListener (com.axway.ats.agent.core.threading.listeners.QueueLoaderListener)1 AllAtOncePattern (com.axway.ats.agent.core.threading.patterns.AllAtOncePattern)1 FixedDurationAllAtOncePattern (com.axway.ats.agent.core.threading.patterns.FixedDurationAllAtOncePattern)1 RampUpPattern (com.axway.ats.agent.core.threading.patterns.RampUpPattern)1