Search in sources :

Example 31 with AllAtOncePattern

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

the class DisabledTest_MultiThreadedActionHandlerWithParameterizedInputData method oneThreadWithThreeInvocations.

@Test
public void oneThreadWithThreeInvocations() 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[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"));
    //        assertEquals( 1, ( int ) ParameterizedInputActionClass.addedStrings.get( "Y1.txt" ) );
    assertNull(ParameterizedInputActionClass.addedStrings.get("Y2.txt"));
    //        assertEquals( 1, ( int ) ParameterizedInputActionClass.addedStrings.get( "Z1.txt" ) );
    assertNull(ParameterizedInputActionClass.addedStrings.get("Z2.txt"));
    assertNull(ParameterizedInputActionClass.addedStrings.get("Z3.txt"));
    assertNull(ParameterizedInputActionClass.addedStrings.get("Z4.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 32 with AllAtOncePattern

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

the class DisabledTest_MultiThreadedActionHandlerWithParameterizedInputData method paremterizedStringDataPositive.

@Test
public void paremterizedStringDataPositive() 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));
    AllAtOncePattern pattern = new AllAtOncePattern(5, true);
    QueueExecutionStatistics.getInstance().initActionExecutionResults("test 1");
    actionHandler.executeActions("IP", "test 1", -1, actionRequests, pattern, loaderDataConfig);
    assertEquals(10, ParameterizedInputActionClass.getAddedStringsCount());
    for (int i = 1; i < 6; i++) {
        assertEquals(2, (int) ParameterizedInputActionClass.addedStrings.get("file" + i + ".txt"));
    }
}
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 33 with AllAtOncePattern

use of com.axway.ats.agent.core.threading.patterns.AllAtOncePattern 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 34 with AllAtOncePattern

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

the class DisabledTest_RampUpLoaderMultipleInvocations method allAtOncePatternBlockingVerifyNoDelay.

@Test
public void allAtOncePatternBlockingVerifyNoDelay() throws Exception {
    AllAtOncePattern pattern = new AllAtOncePattern(5, true);
    loader = LoadQueueFactory.createLoadQueue(QUEUE_NAME, actionRequests, 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_NAME);
    loader.start();
    long endTime = Calendar.getInstance().getTimeInMillis();
    assertTrue(endTime - startTime < 2000);
}
Also used : AllAtOncePattern(com.axway.ats.agent.core.threading.patterns.AllAtOncePattern) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 35 with AllAtOncePattern

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

the class Test_QueueCanceling method allAtOnce_BothThreadsRunning.

/**
     * Both threads are canceled while running its 1st iteration
     */
@Test
public void allAtOnce_BothThreadsRunning() throws Exception {
    expectedNumExecutions = 2;
    actionRequests.add(new ActionRequest(TEST_COMPONENT_NAME, ACTION_SLEEP, new Object[] { "1000" }));
    AllAtOncePattern pattern = new AllAtOncePattern(2, false, 2, 0);
    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 : 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)

Aggregations

AllAtOncePattern (com.axway.ats.agent.core.threading.patterns.AllAtOncePattern)37 Test (org.junit.Test)36 LoaderDataConfig (com.axway.ats.agent.core.threading.data.config.LoaderDataConfig)30 ActionRequest (com.axway.ats.agent.core.action.ActionRequest)24 ArrayList (java.util.ArrayList)17 BaseTest (com.axway.ats.agent.core.BaseTest)5 RangeDataConfig (com.axway.ats.agent.core.threading.data.config.RangeDataConfig)5 ListDataConfig (com.axway.ats.agent.core.threading.data.config.ListDataConfig)3 FixedDurationAllAtOncePattern (com.axway.ats.agent.core.threading.patterns.FixedDurationAllAtOncePattern)3 ParameterDataProvider (com.axway.ats.agent.core.threading.data.ParameterDataProvider)2 RampUpPattern (com.axway.ats.agent.core.threading.patterns.RampUpPattern)2 ThreadingPatternNotSupportedException (com.axway.ats.agent.core.threading.exceptions.ThreadingPatternNotSupportedException)1 QueueLoaderListener (com.axway.ats.agent.core.threading.listeners.QueueLoaderListener)1 FixedDurationRampUpPattern (com.axway.ats.agent.core.threading.patterns.FixedDurationRampUpPattern)1