Search in sources :

Example 31 with ActionRequest

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

the class DisabledTest_MultiThreadedActionHandlerWithParameterizedInputData method paramPresentInDataProvidersButNotInActions.

@Test
public void paramPresentInDataProvidersButNotInActions() throws Exception {
    List<ActionRequest> actions = new ArrayList<ActionRequest>();
    actions.add(actionRequests.get(2));
    LoaderDataConfig loaderDataConfig = new LoaderDataConfig();
    loaderDataConfig.addParameterConfig(parameterDataProviders[0]);
    AllAtOncePattern pattern = new AllAtOncePattern(1, true);
    QueueExecutionStatistics.getInstance().initActionExecutionResults("test 1");
    actionHandler.executeActions("IP", "test 1", -1, actions, pattern, loaderDataConfig);
    assertEquals(0, ParameterizedInputActionClass.getAddedStringsCount());
}
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 ActionRequest

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

the class DisabledTest_MultiThreadedActionHandlerWithParameterizedInputData method paramPresentOnlyOnceInDataProvidersTwoThreads.

@Test
public void paramPresentOnlyOnceInDataProvidersTwoThreads() throws Exception {
    int nThreads = 2;
    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"));
    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 33 with ActionRequest

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

the class DisabledTest_MultiThreadedActionHandlerWithParameterizedInputData method threeThreadsWithThreeInvocations.

@Test
public void threeThreadsWithThreeInvocations() throws Exception {
    int nThreads = 3;
    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"));
    assertEquals(1, (int) ParameterizedInputActionClass.addedStrings.get("X2.txt"));
    assertEquals(1, (int) ParameterizedInputActionClass.addedStrings.get("X3.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 34 with ActionRequest

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

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

the class DistributedLoadExecutor method executeActions.

@Override
public void executeActions(List<ActionRequest> actionRequests) throws AgentException {
    //set the block until completion param to false
    //this way we'll be able to start all the loaders on all boxes at the same time
    //and then wait for all of them to finish
    final boolean blockUntilCompletion = threadingPattern.isBlockUntilCompletion();
    threadingPattern.setBlockUntilCompletion(false);
    int maxHostCount = atsAgents.size();
    // distribute the threading pattern for each agent host
    final List<ThreadingPattern> distributedPatterns = threadingPattern.distribute(maxHostCount);
    if (distributedPatterns.size() < maxHostCount) {
        log.warn("Threading pattern cannot be distributed accross all agents, only the first " + distributedPatterns.size() + " agents will execute");
    }
    // distribute the data configurators for each agent host
    final List<LoaderDataConfig> distributedLoaderDataConfigs = loaderDataConfig.distribute(distributedPatterns.size());
    // start queue in the database and retrieve its ID
    int queueId = retrieveQueueId(queueSequence, getHostsList());
    //call the web service now
    try {
        //first schedule the loaders on all hosts
        for (int i = 0; i < distributedPatterns.size(); i++) {
            //serialize the threading pattern - it's easier to pass it to the web service that way
            byte[] serializedThreadingPattern = serializeObject(distributedPatterns.get(i));
            byte[] serializedLoaderDataConfig = serializeObject(distributedLoaderDataConfigs.get(i));
            //wrap all the action requests
            List<ActionWrapper> actionWrappers = new ArrayList<ActionWrapper>();
            for (ActionRequest actionRequest : actionRequests) {
                actionWrappers.add(wrapActionRequest(actionRequest));
            }
            //schedule the actions, but do not execute
            //get the client
            AgentService agentServicePort = AgentServicePool.getInstance().getClient(atsAgents.get(i));
            agentServicePort.scheduleActionsInMultipleThreads(queueName, queueId, actionWrappers, serializedThreadingPattern, serializedLoaderDataConfig, distributedPatterns.get(0).isUseSynchronizedIterations());
        }
        boolean useSynchronizedIterations = distributedPatterns.get(0).isUseSynchronizedIterations();
        if (useSynchronizedIterations && !blockUntilCompletion) {
            // It is non blocking, but synchronized - we have to wait until the queue finish its execution.
            // We first start the queue. This assures the queue is created before the user have the chance
            // to say "wait for completion"
            startSynchedIterations();
            // and then wait in another thread until the queue finish
            ImportantThread helpThread = new ImportantThread(new Runnable() {

                @Override
                public void run() {
                    runSynchedIterations();
                }
            });
            helpThread.setDescription(queueName);
            helpThread.start();
        } else {
            if (useSynchronizedIterations) {
                // it is blocking - we can wait until the queue finish it execution
                startSynchedIterations();
                runSynchedIterations();
            } else {
                // if blocking - we can wait until the queue finish it execution
                // if non blocking - as it is not synchronized, we will wait only until the queue is started
                runNotSynchedIterations(blockUntilCompletion);
            }
        }
    } catch (AgentException_Exception ae) {
        throw new AgentException(ae.getMessage());
    } catch (InternalComponentException_Exception ice) {
        //we need to get internal component exception info from the soap fault
        InternalComponentException faultInfo = ice.getFaultInfo();
        //then construct and throw a real InternalComponentException (not the JAXB mapping type above)
        throw new com.axway.ats.agent.core.exceptions.InternalComponentException(faultInfo.getComponentName(), faultInfo.getActionName(), faultInfo.getExceptionMessage(), faultInfo.getHostIp());
    } catch (Exception e) {
        throw new AgentException(e.getMessage(), e);
    }
    // restore this flag
    threadingPattern.setBlockUntilCompletion(blockUntilCompletion);
}
Also used : AgentException(com.axway.ats.agent.core.exceptions.AgentException) InternalComponentException_Exception(com.axway.ats.agent.webapp.client.InternalComponentException_Exception) ArrayList(java.util.ArrayList) ActionWrapper(com.axway.ats.agent.webapp.client.ActionWrapper) InternalComponentException(com.axway.ats.agent.webapp.client.InternalComponentException) ImportantThread(com.axway.ats.agent.core.threading.ImportantThread) InternalComponentException_Exception(com.axway.ats.agent.webapp.client.InternalComponentException_Exception) InternalComponentException(com.axway.ats.agent.webapp.client.InternalComponentException) AgentException(com.axway.ats.agent.core.exceptions.AgentException) IOException(java.io.IOException) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception) LoaderDataConfig(com.axway.ats.agent.core.threading.data.config.LoaderDataConfig) ThreadingPattern(com.axway.ats.agent.core.threading.patterns.ThreadingPattern) AgentService(com.axway.ats.agent.webapp.client.AgentService) ActionRequest(com.axway.ats.agent.core.action.ActionRequest) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception)

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