Search in sources :

Example 16 with AgentException

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;
}
Also used : DbAccessFactory(com.axway.ats.log.autodb.DbAccessFactory) AgentException(com.axway.ats.agent.core.exceptions.AgentException) DatabaseAccessException(com.axway.ats.log.autodb.exceptions.DatabaseAccessException)

Example 17 with AgentException

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);
                }
            }
        }
    }
}
Also used : RemoteLoggingConfigurator(com.axway.ats.agent.core.configuration.RemoteLoggingConfigurator) 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) RemoteConfigurationManager(com.axway.ats.agent.webapp.client.configuration.RemoteConfigurationManager)

Example 18 with AgentException

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;
    }
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) InternalComponentException(com.axway.ats.agent.core.exceptions.InternalComponentException) AgentException(com.axway.ats.agent.core.exceptions.AgentException) NoSuchActionException(com.axway.ats.agent.core.exceptions.NoSuchActionException) NoCompatibleMethodFoundException(com.axway.ats.agent.core.exceptions.NoCompatibleMethodFoundException) NoSuchComponentException(com.axway.ats.agent.core.exceptions.NoSuchComponentException) IOException(java.io.IOException) ActionExecutionException(com.axway.ats.agent.core.exceptions.ActionExecutionException) WebMethod(javax.jws.WebMethod)

Example 19 with AgentException

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);
    }
}
Also used : InternalProcessOperations(com.axway.ats.agent.components.system.operations.clients.InternalProcessOperations) AgentException(com.axway.ats.agent.core.exceptions.AgentException) ProcessExecutorException(com.axway.ats.common.process.ProcessExecutorException) Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 20 with AgentException

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;
}
Also used : AgentException(com.axway.ats.agent.core.exceptions.AgentException) SystemOperationException(com.axway.ats.common.system.SystemOperationException) RemoteFileSystemOperations(com.axway.ats.action.filesystem.RemoteFileSystemOperations)

Aggregations

AgentException (com.axway.ats.agent.core.exceptions.AgentException)42 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)11 AgentException_Exception (com.axway.ats.agent.webapp.client.AgentException_Exception)9 AgentService (com.axway.ats.agent.webapp.client.AgentService)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 ObjectOutputStream (java.io.ObjectOutputStream)7 NoSuchComponentException (com.axway.ats.agent.core.exceptions.NoSuchComponentException)6 InternalComponentException (com.axway.ats.agent.webapp.client.InternalComponentException)6 InternalComponentException_Exception (com.axway.ats.agent.webapp.client.InternalComponentException_Exception)6 ActionExecutionException (com.axway.ats.agent.core.exceptions.ActionExecutionException)5 InternalComponentException (com.axway.ats.agent.core.exceptions.InternalComponentException)5 NoCompatibleMethodFoundException (com.axway.ats.agent.core.exceptions.NoCompatibleMethodFoundException)5 NoSuchActionException (com.axway.ats.agent.core.exceptions.NoSuchActionException)5 MonitoringException (com.axway.ats.monitoring.model.exceptions.MonitoringException)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 ObjectInputStream (java.io.ObjectInputStream)5 WebMethod (javax.jws.WebMethod)5 DatabaseEnvironmentUnit (com.axway.ats.environment.database.DatabaseEnvironmentUnit)4 File (java.io.File)4