Make docker integration tests work from CL with 'mvn verify'.

This commit is contained in:
Deklan Dieterly 2014-07-14 13:51:31 -06:00
parent e0d9a73b5b
commit 028d010d84
2 changed files with 36 additions and 12 deletions

21
pom.xml
View File

@ -19,7 +19,7 @@
<mon.common.version>1.0.0-SNAPSHOT</mon.common.version>
<dropwizard.version>0.7.0</dropwizard.version>
<skipITs>true</skipITs>
<skipITs>false</skipITs>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
@ -209,6 +209,11 @@
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
</dependency>
</dependencies>
<build>
@ -252,6 +257,14 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>2.17</version>
</dependency>
</dependencies>
<configuration>
<excludedGroups>performance,functional,integration,database,slow
</excludedGroups>
@ -263,16 +276,16 @@
<configuration>
<groups>performance,functional,integration,database,slow</groups>
<skipTests>${skipITs}</skipTests>
<parallel>methods</parallel>
<threadCount>4</threadCount>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<includes>
<include>**/*.class</include>
</includes>
</configuration>
</execution>
</executions>

View File

@ -11,9 +11,7 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.*;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
@ -21,8 +19,8 @@ import java.net.SocketAddress;
import static com.jayway.restassured.RestAssured.given;
import static com.jayway.restassured.path.json.JsonPath.from;
@Test(groups = "integration", enabled = false)
public class InfluxDBTest {
@Test(groups = "integration", enabled = true)
public class ITInfluxDBTest {
private final static String DDIETERLY_INFLUXDB_V1 = "ddieterly/influxdb:v1";
private static final String DDIETERLY_MYSQL_V1 = "ddieterly/mysql:v1";
@ -32,7 +30,7 @@ public class InfluxDBTest {
private static final String DOCKER_IP = "192.168.59.103";
private static final String DOCKER_PORT = "2375";
private static final String DOCKER_URL = "http://" + DOCKER_IP + ":" + DOCKER_PORT;
private static final int MAX_CONNECT_PORT_TRIES = 20000;
private static final int MAX_CONNECT_PORT_TRIES = 10000;
private final static DockerClient dockerClient = new DockerClient(DOCKER_URL);
@ -57,8 +55,16 @@ public class InfluxDBTest {
private void runAPI() throws IOException {
String latestShadedJarFileName = getLatestShadedJarFileName();
apiProcess = Runtime.getRuntime().exec(new String[]{"java", "-cp", latestShadedJarFileName,
"com.hpcloud.mon.MonApiApplication", "server", "src/test/resources/mon-api-config.yml"});
System.out.println("Running " + latestShadedJarFileName);
ProcessBuilder pb = new ProcessBuilder("java", "-cp", "./target/" + latestShadedJarFileName,
"com.hpcloud.mon.MonApiApplication", "server", "src/test/resources/mon-api-config.yml");
File log = new File("mon-api-integration-test.log");
pb.redirectErrorStream(true);
pb.redirectOutput(ProcessBuilder.Redirect.appendTo(log));
apiProcess = pb.start();
System.out.println("Started " + latestShadedJarFileName);
waitForPortReady("localhost", 8080);
}
@ -74,18 +80,23 @@ public class InfluxDBTest {
tearDown();
System.exit(-1);
}
System.out.println("Found " + files.length + " jar files");
File latestFile = files[0];
for (File file : files) {
if (file.lastModified() > latestFile.lastModified()) {
latestFile = file;
}
}
System.out.println(latestFile.getName() + " is the latest jar file");
return latestFile.getName();
}
private void waitForPortReady(String host, int port) {
System.out.println("waiting to connect to host [" + host + "] on port [" + port + "]");
Socket s = null;
boolean isPortReady = false;
int tryCount = 0;