Search in sources :

Example 11 with AgentService

use of com.axway.ats.agent.webapp.client.AgentService in project ats-framework by Axway.

the class DistributedLoadExecutor method runSynchedIterations.

// TODO When running non blocking, this method is started from a dedicated thread,
// so throwing an error does not affect the main test execution thread,
// so the test does not fail.
// We can keep this errors in some structure which can be checked when
// closing the test case, so we can fail it when needed
private void runSynchedIterations() {
    List<String> atsAgentsTmp = new ArrayList<String>(atsAgents);
    // the actions queue is running, control its execution
    try {
        while (true) {
            Iterator<String> agentsIterator = atsAgentsTmp.iterator();
            while (agentsIterator.hasNext()) {
                AgentService agentServicePort = AgentServicePool.getInstance().getClient(agentsIterator.next());
                boolean needToRunAgain = agentServicePort.waitUntilQueueIsPaused(queueName);
                if (!needToRunAgain) {
                    agentsIterator.remove();
                }
            }
            if (atsAgentsTmp.size() == 0) {
                break;
            }
            // resume the actions on all agents
            for (String agent : atsAgentsTmp) {
                AgentService agentServicePort = AgentServicePool.getInstance().getClient(agent);
                agentServicePort.resumeQueue(queueName);
            }
        }
        // the queue finished but there might be some failed actions
        // check if the wanted actions pass rate is met
        LoadQueueResult queueResult = getQueueResult(threadingPattern.getQueuePassRate(), atsAgents);
        TestcaseStateEventsDispacher.getInstance().setQueueFinishedAsFailed(queueResult == LoadQueueResult.FAILED);
        // end the queue in the log
        log.endLoadQueue(queueName, queueResult);
        log.info("Finished executing action queue '" + queueName + "' on " + atsAgents.toString() + " with synchronized iterations");
    } catch (Exception e) {
        String msg = "Error running action queue '" + queueName + "'";
        log.error(msg, e);
        log.endLoadQueue(queueName, LoadQueueResult.FAILED);
        cancelAllActions();
        throw new RuntimeException(msg, e);
    }
}
Also used : AgentService(com.axway.ats.agent.webapp.client.AgentService) ArrayList(java.util.ArrayList) LoadQueueResult(com.axway.ats.log.model.LoadQueueResult) 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)

Example 12 with AgentService

use of com.axway.ats.agent.webapp.client.AgentService in project ats-framework by Axway.

the class DistributedLoadExecutor method cancelAllActions.

/**
     * Cancel all running actions on remote machines
     *
     * @throws AgentException on error
     */
public void cancelAllActions() {
    for (String host : atsAgents) {
        try {
            AgentService agentServicePort = AgentServicePool.getInstance().getClient(host);
            log.info("Cancelling action queue '" + queueName + "' on agent '" + host + "'");
            //cancel any running queues
            agentServicePort.cancelAllQueues();
            log.info("Cancelled action queue '" + queueName + "' on agent '" + host + "'");
        } catch (Exception e) {
            log.error("Error cancelling action queue '" + queueName + "' on agent '" + host + "'", e);
        }
    }
}
Also used : AgentService(com.axway.ats.agent.webapp.client.AgentService) 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)

Example 13 with AgentService

use of com.axway.ats.agent.webapp.client.AgentService in project ats-framework by Axway.

the class RemoteConfigurationManager method pushConfiguration.

/**
     * Push the provided configuration to the remote Agent
     *
     * @param atsAgent host to push the configuration to
     * @param configurator the configurator
     * @throws AgentException
     */
public void pushConfiguration(String atsAgent, Configurator configurator) throws AgentException {
    // get the client instance
    AgentService agentServicePort = AgentServicePool.getInstance().getClient(atsAgent);
    List<Configurator> configurators = new ArrayList<Configurator>();
    configurators.add(configurator);
    String checkServerLogsStr = ". Check server logs for more details.";
    try {
        // serialize the configurators
        ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
        ObjectOutputStream objectOutStream = new ObjectOutputStream(byteOutStream);
        objectOutStream.writeObject(configurators);
        agentServicePort.pushConfiguration(byteOutStream.toByteArray());
        log.info("Successfully set the " + configurator.getDescription() + " on ATS Agent at '" + atsAgent + "'");
    } catch (IOException ioe) {
        // log hint for further serialization issue investigation
        String msg = "Could not serialize configurators" + checkServerLogsStr;
        log.error(msg, ioe);
        throw new AgentException(msg, ioe);
    } catch (AgentException_Exception ae) {
        String msg = ae.getMessage() + checkServerLogsStr;
        log.error(msg, ae);
        throw new AgentException(msg, ae.getCause());
    } catch (Exception e) {
        String msg = e.getMessage() + checkServerLogsStr;
        log.error(msg, e);
        throw new AgentException(msg, e);
    }
}
Also used : AgentService(com.axway.ats.agent.webapp.client.AgentService) Configurator(com.axway.ats.agent.core.configuration.Configurator) AgentException(com.axway.ats.agent.core.exceptions.AgentException) ArrayList(java.util.ArrayList) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream) AgentException(com.axway.ats.agent.core.exceptions.AgentException) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception) IOException(java.io.IOException)

Example 14 with AgentService

use of com.axway.ats.agent.webapp.client.AgentService in project ats-framework by Axway.

the class TestcaseStateListener method onTestEnd.

@Override
public void onTestEnd() {
    if (configuredAgents == null) {
        // maybe onTestEnd is produced by test skipped event before starting a testcase
        return;
    }
    waitImportantThreadsToFinish();
    for (String atsAgent : configuredAgents) {
        try {
            //get the client
            AgentService agentServicePort = AgentServicePool.getInstance().getClient(atsAgent);
            agentServicePort.onTestEnd();
        } catch (Exception e) {
            log.error("Can't send onTestEnd event to ATS agent '" + atsAgent + "'", e);
        }
    }
    configuredAgents = null;
}
Also used : AgentService(com.axway.ats.agent.webapp.client.AgentService) AgentException(com.axway.ats.agent.core.exceptions.AgentException) AgentException_Exception(com.axway.ats.agent.webapp.client.AgentException_Exception)

Aggregations

AgentException (com.axway.ats.agent.core.exceptions.AgentException)14 AgentException_Exception (com.axway.ats.agent.webapp.client.AgentException_Exception)14 AgentService (com.axway.ats.agent.webapp.client.AgentService)14 IOException (java.io.IOException)11 InternalComponentException (com.axway.ats.agent.webapp.client.InternalComponentException)10 InternalComponentException_Exception (com.axway.ats.agent.webapp.client.InternalComponentException_Exception)10 ArrayList (java.util.ArrayList)5 ImportantThread (com.axway.ats.agent.core.threading.ImportantThread)2 LoadQueueResult (com.axway.ats.log.model.LoadQueueResult)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 ActionRequest (com.axway.ats.agent.core.action.ActionRequest)1 Configurator (com.axway.ats.agent.core.configuration.Configurator)1 RemoteLoggingConfigurator (com.axway.ats.agent.core.configuration.RemoteLoggingConfigurator)1 LoaderDataConfig (com.axway.ats.agent.core.threading.data.config.LoaderDataConfig)1 ThreadingPattern (com.axway.ats.agent.core.threading.patterns.ThreadingPattern)1 ActionWrapper (com.axway.ats.agent.webapp.client.ActionWrapper)1 ArgumentWrapper (com.axway.ats.agent.webapp.client.ArgumentWrapper)1