use of com.axway.ats.agent.core.exceptions.AgentException in project ats-framework by Axway.
the class AbstractClientExecutor method retrieveQueueId.
/**
* Start performance queue in the database and retrieve its ID
*
* @return the started queue ID
* @throws AgentException
*/
public int retrieveQueueId(int sequence, String hostsList) throws AgentException {
int queueId;
try {
if (dbAccess == null) {
dbAccess = new DbAccessFactory().getNewDbWriteAccessObject();
}
queueId = dbAccess.startLoadQueue(queueName, sequence, hostsList, threadingPattern.getPatternDescription(), threadingPattern.getThreadCount(), LOCAL_MACHINE, Calendar.getInstance().getTimeInMillis(), ActiveDbAppender.getCurrentInstance().getTestCaseId(), true);
log.rememberLoadQueueState(queueName, queueId, threadingPattern.getPatternDescription(), threadingPattern.getThreadCount());
} catch (DatabaseAccessException e) {
if (ActiveDbAppender.getCurrentInstance() == null) {
// The log4j DB appender is not attached
// We assume the user is running a performance test without DB logging
log.warn("Unable to register a performance queue with name '" + queueName + "' in the loggging database." + " This means the results of running this queue will not be registered in the log DB." + " Check your DB configuration in order to fix this problem.");
// Return this invalid value will not cause an error on the Test Executor side
// We also know there will be no error on agent's side as our DB appender will not be present there
queueId = -1;
} else {
throw new AgentException("Unable to register a performance queue with name '" + queueName + "' in the loggging database. This queue will not run at all.", e);
}
}
return queueId;
}
use of com.axway.ats.agent.core.exceptions.AgentException in project ats-framework by Axway.
the class TestcaseStateListener method onConfigureAtsAgents.
/**
* This event is send right before running a regular action or starting
* an action queue.
*
* It is also expected to be send between onTestStart and onTestEnd events.
*/
@Override
public void onConfigureAtsAgents(List<String> atsAgents) throws Exception {
if (configuredAgents == null) {
// No TestCase is started so we won't configure the remote agents
return;
}
for (String atsAgent : atsAgents) {
// configure only not configured agents
if (!configuredAgents.contains(atsAgent)) {
// We will try to prevent that adding a 'unique' prefix
synchronized (("ATS_STRING_LOCK-" + atsAgent).intern()) {
if (!configuredAgents.contains(atsAgent)) {
// Pass the logging configuration to the remote agent
RemoteLoggingConfigurator remoteLoggingConfigurator = new RemoteLoggingConfigurator(atsAgent);
new RemoteConfigurationManager().pushConfiguration(atsAgent, remoteLoggingConfigurator);
try {
AgentService agentServicePort = AgentServicePool.getInstance().getClient(atsAgent);
agentServicePort.onTestStart(getCurrentTestCaseState());
} catch (AgentException_Exception ae) {
throw new AgentException(ae.getMessage());
}
configuredAgents.add(atsAgent);
}
}
}
}
}
use of com.axway.ats.agent.core.exceptions.AgentException in project ats-framework by Axway.
the class AgentWsImpl method getActionExecutionResults.
/**
* Queue has already finished and the Test Executor is asking for the
* queue execution results.
*
* There is theoretical chance to be called by more than one thread on Test Executor side,
* when more than one queue is started in non-blocking mode. That's why it is synchronized
*
* @param queueName
* @return
* @throws AgentException
*/
@WebMethod
public synchronized byte[] getActionExecutionResults(@WebParam(name = "name") String queueName) throws AgentException {
try {
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutStream = new ObjectOutputStream(byteOutStream);
objectOutStream.writeObject(QueueExecutionStatistics.getInstance().getActionExecutionResults(queueName));
return byteOutStream.toByteArray();
} catch (Exception e) {
handleExceptions(e);
// always throw but the compiler is not aware of this
return null;
}
}
use of com.axway.ats.agent.core.exceptions.AgentException in project ats-framework by Axway.
the class ProcessExecutor method killExternalProcess.
/**
* Killing external process(such not started by us) on a remote host. <br/>
* The process is found by a token which is contained in the start command.
* No regex supported.
*
* @param atsAgent the address of the remote ATS agent which will run the kill command
* @param startCommandSnippet the token to search for in the process start command.
* The minimum allowed length is 2 characters
* @return the number of killed processes
*/
@PublicAtsApi
public static int killExternalProcess(@Validate(name = "atsAgent", type = ValidationType.STRING_SERVER_WITH_PORT) String atsAgent, @Validate(name = "startCommandSnippet", type = ValidationType.STRING_NOT_EMPTY) String startCommandSnippet) {
// validate input parameters
atsAgent = HostUtils.getAtsAgentIpAndPort(atsAgent);
new Validator().validateMethodParameters(new Object[] { atsAgent, startCommandSnippet });
try {
return new InternalProcessOperations(atsAgent).killExternalProcess(startCommandSnippet);
} catch (AgentException e) {
throw new ProcessExecutorException(e);
}
}
use of com.axway.ats.agent.core.exceptions.AgentException in project ats-framework by Axway.
the class RemoteSystemOperations method createScreenshot.
@Override
public String createScreenshot(String filePath) {
try {
String remoteFilePath = null;
int extIndex = filePath.lastIndexOf('.');
if (extIndex > 0) {
remoteFilePath = filePath.substring(extIndex);
}
remoteFilePath = this.remoteSystemOperations.createScreenshot(remoteFilePath);
new RemoteFileSystemOperations(atsAgent).copyFileFrom(remoteFilePath, filePath, true);
} catch (AgentException e) {
throw new SystemOperationException("Could not create screenshot on agent: " + atsAgent, e);
}
return filePath;
}
Aggregations