Search in sources :

Example 16 with RampUpPattern

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

the class DisabledTest_RampUpLoaderMultipleInvocations 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);
    RampUpPattern pattern = new RampUpPattern(3, false, 10, 0);
    loader = LoadQueueFactory.createLoadQueue(QUEUE_NAME, 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_NAME);
    //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 : RampUpPattern(com.axway.ats.agent.core.threading.patterns.RampUpPattern) ActionRequest(com.axway.ats.agent.core.action.ActionRequest) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 17 with RampUpPattern

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

the class DisabledTest_RampUpLoaderMultipleInvocations method getStateRunningBlockingPositive.

@Test
public void getStateRunningBlockingPositive() throws Exception {
    RampUpPattern pattern = new RampUpPattern(3, true);
    loader = LoadQueueFactory.createLoadQueue(QUEUE_NAME, actionRequests, pattern, new ArrayList<ParameterDataProvider>(), null);
    //first schedule the threads
    loader.scheduleThreads("IP", false);
    Thread.sleep(1);
    assertEquals(ActionTaskLoaderState.SCHEDULED, loader.getState());
    QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_NAME);
    //then start the loader
    loader.start();
    assertEquals(ActionTaskLoaderState.FINISHED, loader.getState());
}
Also used : RampUpPattern(com.axway.ats.agent.core.threading.patterns.RampUpPattern) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 18 with RampUpPattern

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

the class DisabledTest_RampUpLoaderMultipleInvocations method rampUpPatternBlockingWithRampUpIrregularPatternPositive.

@Test
public void rampUpPatternBlockingWithRampUpIrregularPatternPositive() throws Exception {
    RampUpPattern pattern = new RampUpPattern(10, true, 1, 0, 1000, 3);
    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);
    //then start the loader
    long startTime = Calendar.getInstance().getTimeInMillis();
    QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_NAME);
    loader.start();
    long executionTime = Calendar.getInstance().getTimeInMillis() - startTime;
    assertEquals(10, LoadTestActionClass.numExecutions);
    assertTrue(executionTime > 3000);
    assertTrue(executionTime < 5000);
}
Also used : RampUpPattern(com.axway.ats.agent.core.threading.patterns.RampUpPattern) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 19 with RampUpPattern

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

the class DisabledTest_RampUpLoaderMultipleInvocations method getStateNonBlockingPositive.

@Test
public void getStateNonBlockingPositive() throws Exception {
    RampUpPattern pattern = new RampUpPattern(3, false, 10, 3000);
    loader = LoadQueueFactory.createLoadQueue(QUEUE_NAME, actionRequests, pattern, new ArrayList<ParameterDataProvider>(), null);
    //first schedule the threads
    loader.scheduleThreads("IP", false);
    Thread.sleep(1);
    assertEquals(ActionTaskLoaderState.SCHEDULED, loader.getState());
    QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_NAME);
    //then start the loader
    loader.start();
    assertEquals(ActionTaskLoaderState.RUNNING, loader.getState());
    //cancel
    loader.cancel();
    assertEquals(ActionTaskLoaderState.FINISHED, loader.getState());
}
Also used : RampUpPattern(com.axway.ats.agent.core.threading.patterns.RampUpPattern) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 20 with RampUpPattern

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

the class DisabledTest_RampUpLoaderMultipleInvocations method rampUpPatternBlockingMultipleInvocationsNoDelayPositive.

@Test
public void rampUpPatternBlockingMultipleInvocationsNoDelayPositive() throws Exception {
    RampUpPattern pattern = new RampUpPattern(2, true, 10, 0);
    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);
    //then start the loader
    long startTime = Calendar.getInstance().getTimeInMillis();
    QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_NAME);
    loader.start();
    long endTime = Calendar.getInstance().getTimeInMillis();
    assertEquals(20, LoadTestActionClass.numExecutions);
    assertTrue(endTime - startTime < 2000);
}
Also used : RampUpPattern(com.axway.ats.agent.core.threading.patterns.RampUpPattern) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Aggregations

RampUpPattern (com.axway.ats.agent.core.threading.patterns.RampUpPattern)36 Test (org.junit.Test)35 LoaderDataConfig (com.axway.ats.agent.core.threading.data.config.LoaderDataConfig)18 ArrayList (java.util.ArrayList)17 BaseTest (com.axway.ats.agent.core.BaseTest)16 ActionRequest (com.axway.ats.agent.core.action.ActionRequest)5 AllAtOncePattern (com.axway.ats.agent.core.threading.patterns.AllAtOncePattern)2 FixedDurationRampUpPattern (com.axway.ats.agent.core.threading.patterns.FixedDurationRampUpPattern)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 FixedDurationAllAtOncePattern (com.axway.ats.agent.core.threading.patterns.FixedDurationAllAtOncePattern)1