Search in sources :

Example 6 with ActionRequest

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

the class DisabledTest_MultiThreadedActionHandlerWithParameterizedInputData method paramPresentOnlyOnceInDataProviders.

@Test
public void paramPresentOnlyOnceInDataProviders() throws Exception {
    int nThreads = 1;
    int nInvocations = 3;
    List<ActionRequest> actions = new ArrayList<ActionRequest>();
    LoaderDataConfig loaderDataConfig = new LoaderDataConfig();
    for (int i = 0; i < nInvocations; i++) {
        actions.add(fileUploadActionRequest);
    }
    loaderDataConfig.addParameterConfig(parameterDataProviders[0]);
    AllAtOncePattern pattern = new AllAtOncePattern(nThreads, true);
    QueueExecutionStatistics.getInstance().initActionExecutionResults("test 1");
    actionHandler.executeActions("IP", "test 1", -1, actions, pattern, loaderDataConfig);
    assertEquals(nInvocations * nThreads, ParameterizedInputActionClass.getAddedStringsCount());
    assertEquals(1, (int) ParameterizedInputActionClass.addedStrings.get("X1.txt"));
    assertNull(ParameterizedInputActionClass.addedStrings.get("X2.txt"));
    assertNull(ParameterizedInputActionClass.addedStrings.get("X3.txt"));
}
Also used : AllAtOncePattern(com.axway.ats.agent.core.threading.patterns.AllAtOncePattern) ActionRequest(com.axway.ats.agent.core.action.ActionRequest) ArrayList(java.util.ArrayList) LoaderDataConfig(com.axway.ats.agent.core.threading.data.config.LoaderDataConfig) Test(org.junit.Test)

Example 7 with ActionRequest

use of com.axway.ats.agent.core.action.ActionRequest 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);
}
Also used : AllAtOncePattern(com.axway.ats.agent.core.threading.patterns.AllAtOncePattern) ActionRequest(com.axway.ats.agent.core.action.ActionRequest) ListDataConfig(com.axway.ats.agent.core.threading.data.config.ListDataConfig) LoaderDataConfig(com.axway.ats.agent.core.threading.data.config.LoaderDataConfig) Test(org.junit.Test)

Example 8 with ActionRequest

use of com.axway.ats.agent.core.action.ActionRequest 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);
}
Also used : AllAtOncePattern(com.axway.ats.agent.core.threading.patterns.AllAtOncePattern) ActionRequest(com.axway.ats.agent.core.action.ActionRequest) LoaderDataConfig(com.axway.ats.agent.core.threading.data.config.LoaderDataConfig) Test(org.junit.Test)

Example 9 with ActionRequest

use of com.axway.ats.agent.core.action.ActionRequest 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);
}
Also used : AllAtOncePattern(com.axway.ats.agent.core.threading.patterns.AllAtOncePattern) ActionRequest(com.axway.ats.agent.core.action.ActionRequest) LoaderDataConfig(com.axway.ats.agent.core.threading.data.config.LoaderDataConfig) Test(org.junit.Test)

Example 10 with ActionRequest

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

the class Test_QueueCanceling method ramUp_OneThreadRunning_OneThreadNotStartedYet.

/**
     * Cancel a ramp-up pattern while:
     *  - 1th thread is running its first iteration
     *  - 2nd thread is waiting to start its first iteration
     */
@Test
public void ramUp_OneThreadRunning_OneThreadNotStartedYet() throws Exception {
    expectedNumExecutions = 1;
    actionRequests.add(new ActionRequest(TEST_COMPONENT_NAME, ACTION_SLEEP, new Object[] { "1000" }));
    RampUpPattern pattern = new RampUpPattern(2, false, 2, 0, 2000, 1);
    QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_NAME);
    actionHandler.scheduleActions(HOST, QUEUE_NAME, -1, actionRequests, pattern, new LoaderDataConfig(), false);
    actionHandler.startQueue(QUEUE_NAME);
    Thread.sleep(500);
}
Also used : RampUpPattern(com.axway.ats.agent.core.threading.patterns.RampUpPattern) ActionRequest(com.axway.ats.agent.core.action.ActionRequest) LoaderDataConfig(com.axway.ats.agent.core.threading.data.config.LoaderDataConfig) Test(org.junit.Test)

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