Search in sources :

Example 1 with FixedDurationAllAtOncePattern

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

the class Test_LoadQueueFactory method createQueueFixedDurationAllAtOncePatternPositive.

@Test
public void createQueueFixedDurationAllAtOncePatternPositive() throws Exception {
    FixedDurationAllAtOncePattern pattern = new FixedDurationAllAtOncePattern(100, false, 30);
    QueueLoader loader = LoadQueueFactory.createLoadQueue("test", new ArrayList<ActionRequest>(), pattern, new ArrayList<ParameterDataProvider>(), null);
    assertEquals(RampUpQueueLoader.class, loader.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)

Example 2 with FixedDurationAllAtOncePattern

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

the class LoadQueueFactory method createLoadQueue.

/**
     * Create an action task load queue based on the threading pattern selected
     * 
     * @param queueName name of the queue
     * @param actionRequests the action requests to execute with this queue
     * @param threadingPattern the threading pattern
     * @return
     * @throws NoSuchComponentException there is no registered component for one of the requested actions
     * @throws NoSuchActionException one of the actions requested does not exist
     * @throws NoCompatibleMethodFoundException if no action method is found, which corresponds to this request
     * @throws ThreadingPatternNotSupportedException if the supplied threading pattern is not supported
     */
public static final QueueLoader createLoadQueue(String queueName, List<ActionRequest> actionRequests, ThreadingPattern threadingPattern, List<ParameterDataProvider> parameterDataProviders, List<QueueLoaderListener> listeners) throws NoSuchComponentException, NoSuchActionException, NoCompatibleMethodFoundException, ThreadingPatternNotSupportedException {
    if (listeners == null) {
        listeners = new ArrayList<QueueLoaderListener>();
    }
    if (threadingPattern.getClass() == AllAtOncePattern.class) {
        //convert the "all at once" to "ramp up pattern"
        AllAtOncePattern allAtOncePattern = (AllAtOncePattern) threadingPattern;
        RampUpPattern rampUpPattern = new RampUpPattern(allAtOncePattern.getThreadCount(), allAtOncePattern.isBlockUntilCompletion(), allAtOncePattern.getIterationCount(), allAtOncePattern.getIntervalBetweenIterations());
        rampUpPattern.setMinIntervalBetweenIterations(allAtOncePattern.getMinIntervalBetweenIterations());
        rampUpPattern.setMaxIntervalBetweenIterations(allAtOncePattern.getMaxIntervalBetweenIterations());
        rampUpPattern.setIterationTimeout(allAtOncePattern.getIterationTimeout());
        return new RampUpQueueLoader(queueName, actionRequests, rampUpPattern, allAtOncePattern, parameterDataProviders, listeners);
    } else if (threadingPattern.getClass() == FixedDurationAllAtOncePattern.class) {
        //convert the "fixed duration all at once" to "fixed duration ramp up pattern"
        FixedDurationAllAtOncePattern allAtOncePattern = (FixedDurationAllAtOncePattern) threadingPattern;
        FixedDurationRampUpPattern rampUpPattern = new FixedDurationRampUpPattern(allAtOncePattern.getThreadCount(), allAtOncePattern.isBlockUntilCompletion(), allAtOncePattern.getDuration(), allAtOncePattern.getIntervalBetweenIterations());
        rampUpPattern.setMinIntervalBetweenIterations(allAtOncePattern.getMinIntervalBetweenIterations());
        rampUpPattern.setMaxIntervalBetweenIterations(allAtOncePattern.getMaxIntervalBetweenIterations());
        rampUpPattern.setIterationTimeout(threadingPattern.getIterationTimeout());
        return new RampUpQueueLoader(queueName, actionRequests, rampUpPattern, allAtOncePattern, parameterDataProviders, listeners);
    } else if (threadingPattern.getClass() == RampUpPattern.class || threadingPattern.getClass() == FixedDurationRampUpPattern.class) {
        //this is a real ramp-up pattern
        return new RampUpQueueLoader(queueName, actionRequests, (RampUpStartPattern) threadingPattern, (ExecutionPattern) threadingPattern, parameterDataProviders, listeners);
    } else {
        throw new ThreadingPatternNotSupportedException(threadingPattern.getClass().getSimpleName());
    }
}
Also used : ThreadingPatternNotSupportedException(com.axway.ats.agent.core.threading.exceptions.ThreadingPatternNotSupportedException) QueueLoaderListener(com.axway.ats.agent.core.threading.listeners.QueueLoaderListener) AllAtOncePattern(com.axway.ats.agent.core.threading.patterns.AllAtOncePattern) FixedDurationAllAtOncePattern(com.axway.ats.agent.core.threading.patterns.FixedDurationAllAtOncePattern) FixedDurationRampUpPattern(com.axway.ats.agent.core.threading.patterns.FixedDurationRampUpPattern) RampUpPattern(com.axway.ats.agent.core.threading.patterns.RampUpPattern) FixedDurationRampUpPattern(com.axway.ats.agent.core.threading.patterns.FixedDurationRampUpPattern) FixedDurationAllAtOncePattern(com.axway.ats.agent.core.threading.patterns.FixedDurationAllAtOncePattern)

Example 3 with FixedDurationAllAtOncePattern

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

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

the class DisabledTest_RampUpQueueLoaderFixedDuration method allAtOncePatternBlockingPositive.

@Test
public void allAtOncePatternBlockingPositive() throws Exception {
    FixedDurationAllAtOncePattern pattern = new FixedDurationAllAtOncePattern(2, true, 2, 900);
    loader = LoadQueueFactory.createLoadQueue(QUEUE_1, actionRequests, 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();
    assertEquals(6, LoadTestActionClass.numExecutions);
}
Also used : ArrayList(java.util.ArrayList) FixedDurationAllAtOncePattern(com.axway.ats.agent.core.threading.patterns.FixedDurationAllAtOncePattern) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 5 with FixedDurationAllAtOncePattern

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

FixedDurationAllAtOncePattern (com.axway.ats.agent.core.threading.patterns.FixedDurationAllAtOncePattern)6 Test (org.junit.Test)5 BaseTest (com.axway.ats.agent.core.BaseTest)4 ActionRequest (com.axway.ats.agent.core.action.ActionRequest)3 ArrayList (java.util.ArrayList)3 ParameterDataProvider (com.axway.ats.agent.core.threading.data.ParameterDataProvider)2 ThreadingPatternNotSupportedException (com.axway.ats.agent.core.threading.exceptions.ThreadingPatternNotSupportedException)1 QueueLoaderListener (com.axway.ats.agent.core.threading.listeners.QueueLoaderListener)1 AllAtOncePattern (com.axway.ats.agent.core.threading.patterns.AllAtOncePattern)1 FixedDurationRampUpPattern (com.axway.ats.agent.core.threading.patterns.FixedDurationRampUpPattern)1 RampUpPattern (com.axway.ats.agent.core.threading.patterns.RampUpPattern)1