Search in sources :

Example 1 with BeforeWithParams

use of com.microsoft.applicationinsights.smoketest.fixtures.BeforeWithParams in project ApplicationInsights-Java by microsoft.

the class AiSmokeTest method configureEnvironment.

@BeforeWithParams
public static void configureEnvironment(String appServer, String os, String jreVersion) throws Exception {
    System.out.println("Preparing environment...");
    try {
        ContainerInfo containerInfo = currentContainerInfo.get();
        if (containerInfo != null) {
            // test cleanup didn't take...try to clean up
            if (docker.isContainerRunning(containerInfo.getContainerId())) {
                System.err.println("From last test run, container is still running: " + containerInfo);
                try {
                    docker.stopContainer(containerInfo.getContainerId());
                } catch (Exception e) {
                    System.err.println("Couldn't clean up environment. Must be done manually.");
                    throw e;
                }
            } else {
                // container must have stopped after timeout reached.
                currentContainerInfo.set(null);
            }
        }
        checkParams(appServer, os, jreVersion);
        setupProperties(appServer, os, jreVersion);
        startMockedIngestion();
        createDockerNetwork();
        startAllContainers();
        waitForApplicationToStart();
        System.out.println("Environment preparation complete.");
    } catch (Exception e) {
        String additionalMessage;
        if (e instanceof TimeoutException) {
            additionalMessage = e.getLocalizedMessage();
        } else {
            additionalMessage = ExceptionUtils.getStackTrace(e);
        }
        System.err.printf("Could not configure environment: %s%n", additionalMessage);
        throw e;
    }
}
Also used : ContainerInfo(com.microsoft.applicationinsights.smoketest.docker.ContainerInfo) TimeoutException(com.microsoft.applicationinsights.smoketest.exceptions.TimeoutException) SmokeTestException(com.microsoft.applicationinsights.smoketest.exceptions.SmokeTestException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(com.microsoft.applicationinsights.smoketest.exceptions.TimeoutException) BeforeWithParams(com.microsoft.applicationinsights.smoketest.fixtures.BeforeWithParams)

Aggregations

ContainerInfo (com.microsoft.applicationinsights.smoketest.docker.ContainerInfo)1 SmokeTestException (com.microsoft.applicationinsights.smoketest.exceptions.SmokeTestException)1 TimeoutException (com.microsoft.applicationinsights.smoketest.exceptions.TimeoutException)1 BeforeWithParams (com.microsoft.applicationinsights.smoketest.fixtures.BeforeWithParams)1 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1