Search in sources :

Example 6 with LoaderDataConfig

use of com.axway.ats.agent.core.threading.data.config.LoaderDataConfig in project ats-framework by Axway.

the class DisabledTest_MultiThreadedActionHandler method cancelAllQueuesDuringExecutionPositive.

@Test
public void cancelAllQueuesDuringExecutionPositive() 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);
    assertEquals(0, LoadTestActionClass.numExecutions);
    QueueExecutionStatistics.getInstance().initActionExecutionResults(QUEUE_1);
    //then start the queue
    actionHandler.executeActions("IP", QUEUE_1, -1, newActionRequests, pattern, new LoaderDataConfig());
    Thread.sleep(1000);
    actionHandler.cancelAllQueues();
    //assert that only the first execution took place
    expectedNumExecutions = 3;
}
Also used : RampUpPattern(com.axway.ats.agent.core.threading.patterns.RampUpPattern) 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 LoaderDataConfig

use of com.axway.ats.agent.core.threading.data.config.LoaderDataConfig in project ats-framework by Axway.

the class DisabledTest_MultiThreadedActionHandlerWithParameterizedInputData method twoThreadsWithTwoInvocations.

@Test
public void twoThreadsWithTwoInvocations() throws Exception {
    int nThreads = 2;
    int nInvocations = 2;
    List<ActionRequest> actions = new ArrayList<ActionRequest>();
    LoaderDataConfig loaderDataConfig = new LoaderDataConfig();
    for (int i = 0; i < nInvocations; i++) {
        actions.add(fileUploadActionRequest);
        loaderDataConfig.addParameterConfig(parameterDataProviders[i]);
    }
    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"));
    assertEquals(1, (int) 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 8 with LoaderDataConfig

use of com.axway.ats.agent.core.threading.data.config.LoaderDataConfig in project ats-framework by Axway.

the class DisabledTest_MultiThreadedActionHandlerWithParameterizedInputData method oneThreadWithTwoInvocations.

@Test
public void oneThreadWithTwoInvocations() throws Exception {
    int nThreads = 1;
    int nInvocations = 2;
    List<ActionRequest> actions = new ArrayList<ActionRequest>();
    LoaderDataConfig loaderDataConfig = new LoaderDataConfig();
    for (int i = 0; i < nInvocations; i++) {
        actions.add(fileUploadActionRequest);
        loaderDataConfig.addParameterConfig(parameterDataProviders[i]);
    }
    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"));
    assertNull(ParameterizedInputActionClass.addedStrings.get("Y2.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 9 with LoaderDataConfig

use of com.axway.ats.agent.core.threading.data.config.LoaderDataConfig in project ats-framework by Axway.

the class DisabledTest_MultiThreadedActionHandlerWithParameterizedInputData method paremterizedVariousDataPositive.

@Test
public void paremterizedVariousDataPositive() throws Exception {
    LoaderDataConfig loaderDataConfig = new LoaderDataConfig();
    loaderDataConfig.addParameterConfig(new RangeDataConfig("fileName", "file{0}.txt", 1, 300));
    loaderDataConfig.addParameterConfig(new RangeDataConfig("fileName", "file{0}.txt", 1, 300));
    loaderDataConfig.addParameterConfig(new RangeDataConfig("milliseconds", 1, 4));
    AllAtOncePattern pattern = new AllAtOncePattern(5, true);
    QueueExecutionStatistics.getInstance().initActionExecutionResults("test 1");
    actionHandler.executeActions("IP", "test 1", -1, actionRequests, pattern, loaderDataConfig);
    //check the strings
    assertEquals(10, ParameterizedInputActionClass.getAddedStringsCount());
    for (int i = 1; i < 6; i++) {
        assertEquals(2, (int) ParameterizedInputActionClass.addedStrings.get("file" + i + ".txt"));
    }
    //check the integers
    assertEquals(4, ParameterizedInputActionClass.addedLongs.size());
    for (int i = 1; i < 5; i++) {
        assertTrue(ParameterizedInputActionClass.addedLongs.contains(new Long(i)));
    }
}
Also used : RangeDataConfig(com.axway.ats.agent.core.threading.data.config.RangeDataConfig) AllAtOncePattern(com.axway.ats.agent.core.threading.patterns.AllAtOncePattern) LoaderDataConfig(com.axway.ats.agent.core.threading.data.config.LoaderDataConfig) Test(org.junit.Test)

Example 10 with LoaderDataConfig

use of com.axway.ats.agent.core.threading.data.config.LoaderDataConfig 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)

Aggregations

LoaderDataConfig (com.axway.ats.agent.core.threading.data.config.LoaderDataConfig)50 Test (org.junit.Test)47 AllAtOncePattern (com.axway.ats.agent.core.threading.patterns.AllAtOncePattern)30 ActionRequest (com.axway.ats.agent.core.action.ActionRequest)26 RampUpPattern (com.axway.ats.agent.core.threading.patterns.RampUpPattern)18 ArrayList (java.util.ArrayList)16 RangeDataConfig (com.axway.ats.agent.core.threading.data.config.RangeDataConfig)5 AgentException (com.axway.ats.agent.core.exceptions.AgentException)3 ListDataConfig (com.axway.ats.agent.core.threading.data.config.ListDataConfig)3 ThreadingPattern (com.axway.ats.agent.core.threading.patterns.ThreadingPattern)2 IOException (java.io.IOException)2 ActionExecutionException (com.axway.ats.agent.core.exceptions.ActionExecutionException)1 InternalComponentException (com.axway.ats.agent.core.exceptions.InternalComponentException)1 NoCompatibleMethodFoundException (com.axway.ats.agent.core.exceptions.NoCompatibleMethodFoundException)1 NoSuchActionException (com.axway.ats.agent.core.exceptions.NoSuchActionException)1 NoSuchComponentException (com.axway.ats.agent.core.exceptions.NoSuchComponentException)1 ImportantThread (com.axway.ats.agent.core.threading.ImportantThread)1 ActionWrapper (com.axway.ats.agent.webapp.client.ActionWrapper)1 AgentException_Exception (com.axway.ats.agent.webapp.client.AgentException_Exception)1 AgentService (com.axway.ats.agent.webapp.client.AgentService)1