Search in sources :

Example 1 with LoadQueueResult

use of com.axway.ats.log.model.LoadQueueResult in project ats-framework by Axway.

the class DistributedLoadExecutor method waitUntilQueueFinishOnAllLoaders.

private void waitUntilQueueFinishOnAllLoaders() {
    try {
        log.info("Action queue '" + queueName + "' is running on " + atsAgents.toString());
        for (int i = 0; i < atsAgents.size(); i++) {
            String host = atsAgents.get(i);
            log.info("Waiting until queue '" + queueName + "' finish on '" + host + "'");
            AgentService agentServicePort = AgentServicePool.getInstance().getClient(host);
            agentServicePort.waitUntilQueueFinish(queueName);
            log.info("Finished executing action queue '" + queueName + "' on '" + host + "'");
        }
        // 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 all agents " + atsAgents.toString());
    } catch (Exception e) {
        String msg = "Error waiting for action queue '" + queueName + "' completion";
        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) 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 2 with LoadQueueResult

use of com.axway.ats.log.model.LoadQueueResult 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)

Aggregations

AgentException (com.axway.ats.agent.core.exceptions.AgentException)2 AgentException_Exception (com.axway.ats.agent.webapp.client.AgentException_Exception)2 AgentService (com.axway.ats.agent.webapp.client.AgentService)2 InternalComponentException (com.axway.ats.agent.webapp.client.InternalComponentException)2 InternalComponentException_Exception (com.axway.ats.agent.webapp.client.InternalComponentException_Exception)2 LoadQueueResult (com.axway.ats.log.model.LoadQueueResult)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)1