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);
}
}
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);
}
}
}
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);
}
}
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;
}
Aggregations