Search in sources :

Example 36 with ActionRequest

use of com.axway.ats.agent.core.action.ActionRequest 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 37 with ActionRequest

use of com.axway.ats.agent.core.action.ActionRequest in project ats-framework by Axway.

the class Test_ActionTaskFactory method createActionTaskFixedDuration.

@Test
public void createActionTaskFixedDuration() throws ActionExecutionException, NoSuchComponentException, NoSuchActionException, NoCompatibleMethodFoundException, ThreadingPatternNotSupportedException {
    FixedDurationAllAtOncePattern pattern = new FixedDurationAllAtOncePattern(10, true, 20, 1400);
    Runnable actionTask = ActionTaskFactory.createTask("IP", "Action_Queue", pattern, pattern.getExecutionsPerTimeFrame(), new ThreadsManager(), null, new ArrayList<ActionRequest>(), new ArrayList<ParameterDataProvider>(), null, false);
    assertEquals(FixedDurationActionTask.class, actionTask.getClass());
}
Also used : ParameterDataProvider(com.axway.ats.agent.core.threading.data.ParameterDataProvider) ActionRequest(com.axway.ats.agent.core.action.ActionRequest) FixedDurationAllAtOncePattern(com.axway.ats.agent.core.threading.patterns.FixedDurationAllAtOncePattern) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 38 with ActionRequest

use of com.axway.ats.agent.core.action.ActionRequest in project ats-framework by Axway.

the class Test_ActionTaskFactory method createActionTaskMultipleInvocations.

@Test
public void createActionTaskMultipleInvocations() throws ActionExecutionException, NoSuchComponentException, NoSuchActionException, NoCompatibleMethodFoundException, ThreadingPatternNotSupportedException {
    AllAtOncePattern pattern = new AllAtOncePattern(10, true, 20, 1400);
    Runnable actionTask = ActionTaskFactory.createTask("IP", "Action_Queue", pattern, pattern.getExecutionsPerTimeFrame(), new ThreadsManager(), null, new ArrayList<ActionRequest>(), new ArrayList<ParameterDataProvider>(), null, false);
    assertEquals(MultipleInvocationsActionTask.class, actionTask.getClass());
}
Also used : ParameterDataProvider(com.axway.ats.agent.core.threading.data.ParameterDataProvider) AllAtOncePattern(com.axway.ats.agent.core.threading.patterns.AllAtOncePattern) FixedDurationAllAtOncePattern(com.axway.ats.agent.core.threading.patterns.FixedDurationAllAtOncePattern) ActionRequest(com.axway.ats.agent.core.action.ActionRequest) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 39 with ActionRequest

use of com.axway.ats.agent.core.action.ActionRequest in project ats-framework by Axway.

the class DisabledTest_RampUpQueueLoaderFixedDuration method setUpTest_ActionInvoker.

@BeforeClass
public static void setUpTest_ActionInvoker() throws AgentException {
    Component component = new Component(TEST_COMPONENT_NAME);
    ComponentActionMap actionMap = new ComponentActionMap(TEST_COMPONENT_NAME);
    actionMap.registerActionClass(LoadTestActionClass.class);
    component.setActionMap(actionMap);
    ComponentRepository componentRepository = ComponentRepository.getInstance();
    componentRepository.clear();
    componentRepository.putComponent(component);
    ActionRequest actionRequest = new ActionRequest(TEST_COMPONENT_NAME, "action 1", new Object[] { 3 });
    actionRequests = new ArrayList<ActionRequest>();
    actionRequests.add(actionRequest);
}
Also used : ComponentActionMap(com.axway.ats.agent.core.ComponentActionMap) ActionRequest(com.axway.ats.agent.core.action.ActionRequest) ComponentRepository(com.axway.ats.agent.core.ComponentRepository) Component(com.axway.ats.agent.core.Component) BeforeClass(org.junit.BeforeClass)

Example 40 with ActionRequest

use of com.axway.ats.agent.core.action.ActionRequest in project ats-framework by Axway.

the class DisabledTest_RampUpQueueLoaderFixedDuration method allAtOnceExceptionThrownInAction.

@Test
public void allAtOnceExceptionThrownInAction() throws Exception {
    FixedDurationAllAtOncePattern pattern = new FixedDurationAllAtOncePattern(50, true, 5);
    ActionRequest actionRequest = new ActionRequest(TEST_COMPONENT_NAME, "exception action", new Object[] {});
    ArrayList<ActionRequest> newActionRequests = new ArrayList<ActionRequest>();
    newActionRequests.add(actionRequest);
    loader = LoadQueueFactory.createLoadQueue(QUEUE_1, newActionRequests, pattern, new ArrayList<ParameterDataProvider>(), null);
    //first schedule the threads
    loader.scheduleThreads("IP", false);
    Thread.sleep(1);
    //then start the loader
    long startTime = Calendar.getInstance().getTimeInMillis();
    QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_1);
    loader.start();
    long endTime = Calendar.getInstance().getTimeInMillis();
    //verify that execution will not stop
    assertTrue(endTime - startTime > 5);
}
Also used : ActionRequest(com.axway.ats.agent.core.action.ActionRequest) ArrayList(java.util.ArrayList) FixedDurationAllAtOncePattern(com.axway.ats.agent.core.threading.patterns.FixedDurationAllAtOncePattern) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Aggregations

ActionRequest (com.axway.ats.agent.core.action.ActionRequest)44 Test (org.junit.Test)36 LoaderDataConfig (com.axway.ats.agent.core.threading.data.config.LoaderDataConfig)26 AllAtOncePattern (com.axway.ats.agent.core.threading.patterns.AllAtOncePattern)24 ArrayList (java.util.ArrayList)20 BaseTest (com.axway.ats.agent.core.BaseTest)6 ParameterDataProvider (com.axway.ats.agent.core.threading.data.ParameterDataProvider)6 FixedDurationAllAtOncePattern (com.axway.ats.agent.core.threading.patterns.FixedDurationAllAtOncePattern)5 RampUpPattern (com.axway.ats.agent.core.threading.patterns.RampUpPattern)5 ListDataConfig (com.axway.ats.agent.core.threading.data.config.ListDataConfig)4 FixedDurationRampUpPattern (com.axway.ats.agent.core.threading.patterns.FixedDurationRampUpPattern)3 LocalExecutor (com.axway.ats.agent.webapp.client.executors.LocalExecutor)3 BeforeClass (org.junit.BeforeClass)3 AgentException (com.axway.ats.agent.core.exceptions.AgentException)2 ThreadingPattern (com.axway.ats.agent.core.threading.patterns.ThreadingPattern)2 RemoteExecutor (com.axway.ats.agent.webapp.client.executors.RemoteExecutor)2 IOException (java.io.IOException)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Component (com.axway.ats.agent.core.Component)1 ComponentActionMap (com.axway.ats.agent.core.ComponentActionMap)1