add option to run without integration tests

This commit is contained in:
Christian Posta 2016-02-11 15:57:05 -07:00
parent a4bbcecd7e
commit c730685a01
4 changed files with 179 additions and 153 deletions

View File

@ -74,19 +74,34 @@ Using Docker has several advantages:
1. All builds are consistent. When multiple developers each build the same codebase, they should see exactly the same results -- as long as they're using the same or equivalent JDK, Maven, and Docker versions. That's because the containers will be running the same versions of the services on the same operating systems. Plus, all of the tests are designed to connect to the systems running in the containers, so nobody has to fiddle with connection properties or custom configurations specific to their local environments. 1. All builds are consistent. When multiple developers each build the same codebase, they should see exactly the same results -- as long as they're using the same or equivalent JDK, Maven, and Docker versions. That's because the containers will be running the same versions of the services on the same operating systems. Plus, all of the tests are designed to connect to the systems running in the containers, so nobody has to fiddle with connection properties or custom configurations specific to their local environments.
1. No need to clean up the services, even if those services modify and store data locally. Docker *images* are cached, so building them reusing them to start containers is fast and consistent. However, Docker *containers* are never reused: they always start in their pristine initial state, and are discarded when they are shutdown. Integration tests rely upon containers, and so cleanup is handled automatically. 1. No need to clean up the services, even if those services modify and store data locally. Docker *images* are cached, so building them reusing them to start containers is fast and consistent. However, Docker *containers* are never reused: they always start in their pristine initial state, and are discarded when they are shutdown. Integration tests rely upon containers, and so cleanup is handled automatically.
### Configure your docker environment
The Docker Maven Plugin will resolve the docker host by checking the following environment variables:
export DOCKER_HOST=tcp://10.1.2.2:2376
export DOCKER_CERT_PATH=/path/to/cdk/.vagrant/machines/default/virtualbox/.docker
export DOCKER_TLS_VERIFY=1
These can be set automatically if using Docker Machine or something similar.
### Building the code ### Building the code
First obtain the code by cloning the Git repository: First obtain the code by cloning the Git repository:
$ git clone https://github.com/debezium/debezium.git $ git clone https://github.com/debezium/debezium.git
$ cd keycloak $ cd debezium
Then build the code using Maven: Then build the code using Maven:
$ mvn clean install $ mvn clean install
The build starts and uses several Docker containers for different DBMSes. Note that if Docker is not running, you'll likely get an arcane error -- if this is the case, always verify that Docker is running, perhaps by using `docker ps` to list the running containers. The build starts and uses several Docker containers for different DBMSes. Note that if Docker is not running or configured, you'll likely get an arcane error -- if this is the case, always verify that Docker is running, perhaps by using `docker ps` to list the running containers.
### Don't have docker running locally for builds?
You can skip the integration tests and docker-builds with the following command:
$ mvn clean install -DskipITs
## Contributing ## Contributing

View File

@ -85,80 +85,7 @@
<build> <build>
<plugins> <plugins>
<!-- Build a Docker image of our MySQL installation, and run it as a container for our integration tests --> <!-- Build a Docker image of our MySQL installation, and run it as a container for our integration tests -->
<plugin>
<groupId>org.jolokia</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<watchInterval>500</watchInterval>
<logDate>default</logDate>
<verbose>true</verbose>
<autoPull>always</autoPull>
<images>
<image>
<name>debezium-mysql57-server</name>
<alias>database</alias>
<build>
<assembly>
<basedir>/docker-entrypoint-initdb.d</basedir>
<dockerFileDir>${project.basedir}/src/test/docker</dockerFileDir>
</assembly>
</build>
<run>
<namingStrategy>alias</namingStrategy>
<!--volumes>
<bind>
<volume>${project.build.directory}/data:/var/lib/postgresql/data</volume>
</bind>
</volumes-->
<env>
<MYSQL_ROOT_PASSWORD>debezium-rocks</MYSQL_ROOT_PASSWORD>
<MYSQL_DATABASE>mysql</MYSQL_DATABASE> <!-- database created upon init -->
<MYSQL_USER>${database.user}</MYSQL_USER>
<MYSQL_PASSWORD>${database.password}</MYSQL_PASSWORD>
</env>
<ports>
<port>${database.port}:3306</port>
</ports>
<log>
<prefix>mysql</prefix>
<enabled>true</enabled>
<color>yellow</color>
</log>
<wait>
<log>MySQL init process done. Ready for start up.</log>
<time>30000</time> <!-- 30 seconds max -->
</wait>
</run>
</image>
</images>
</configuration>
<!--
Connect this plugin to the maven lifecycle around the integration-test phase:
start the container in pre-integration-test and stop it in post-integration-test.
-->
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>build</goal>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<!--
Unlike surefire, the failsafe plugin ensures 'post-integration-test' phase always runs, even
when there are failed integration tests. We rely upon this to always shut down the Docker container
after the integration tests (defined as '*IT.java') are run.
-->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId> <artifactId>maven-failsafe-plugin</artifactId>
@ -177,6 +104,7 @@
</execution> </execution>
</executions> </executions>
<configuration> <configuration>
<skipTests>${skipITs}</skipTests>
<systemPropertyVariables> <systemPropertyVariables>
<!-- Make these available to the tests via system properties --> <!-- Make these available to the tests via system properties -->
<database.hostname>${docker.host.address}</database.hostname> <database.hostname>${docker.host.address}</database.hostname>
@ -211,82 +139,163 @@
</testResources> </testResources>
</build> </build>
<profiles> <profiles>
<profile> <profile>
<id>alt-mysql</id> <id>docker</id>
<activation> <activation>
<activeByDefault>false</activeByDefault> <property>
</activation> <name>!skipITs</name>
<build> </property>
<plugins> </activation>
<!-- Build a Docker image of our MySQL installation, and run it as a container for our integration tests --> <build>
<plugin> <plugins>
<groupId>org.jolokia</groupId> <plugin>
<artifactId>docker-maven-plugin</artifactId> <groupId>org.jolokia</groupId>
<configuration> <artifactId>docker-maven-plugin</artifactId>
<watchInterval>500</watchInterval> <configuration>
<logDate>default</logDate> <watchInterval>500</watchInterval>
<verbose>true</verbose> <logDate>default</logDate>
<autoPull>always</autoPull> <verbose>true</verbose>
<images> <autoPull>always</autoPull>
<image> <images>
<name>mysql:5.7</name> <image>
<alias>database</alias> <name>debezium-mysql57-server</name>
<run> <alias>database</alias>
<namingStrategy>alias</namingStrategy> <build>
<volumes> <assembly>
<bind> <basedir>/docker-entrypoint-initdb.d</basedir>
<volume>${project.basedir}/src/test/docker/alt-server:/etc/mysql/conf.ddata:/var/lib/postgresql/data</volume> <dockerFileDir>${project.basedir}/src/test/docker</dockerFileDir>
</bind> </assembly>
<bind> </build>
<volume>${project.basedir}/src/test/docker/init:/docker-entrypoint-initdb.d</volume> <run>
</bind> <namingStrategy>alias</namingStrategy>
</volumes> <!--volumes>
<env> <bind>
<MYSQL_ROOT_PASSWORD>debezium-rocks</MYSQL_ROOT_PASSWORD> <volume>${project.build.directory}/data:/var/lib/postgresql/data</volume>
<MYSQL_DATABASE>mysql</MYSQL_DATABASE> <!-- database created upon init --> </bind>
<MYSQL_USER>${database.user}</MYSQL_USER> </volumes-->
<MYSQL_PASSWORD>${database.password}</MYSQL_PASSWORD> <env>
</env> <MYSQL_ROOT_PASSWORD>debezium-rocks</MYSQL_ROOT_PASSWORD>
<ports> <MYSQL_DATABASE>mysql</MYSQL_DATABASE> <!-- database created upon init -->
<port>${database.port}:3306</port> <MYSQL_USER>${database.user}</MYSQL_USER>
</ports> <MYSQL_PASSWORD>${database.password}</MYSQL_PASSWORD>
<log> </env>
<prefix>mysql</prefix> <ports>
<enabled>true</enabled> <port>${database.port}:3306</port>
<color>yellow</color> </ports>
</log> <log>
<wait> <prefix>mysql</prefix>
<log>MySQL Community Server (GPL)</log> <enabled>true</enabled>
<time>30000</time> <!-- 30 seconds max --> <color>yellow</color>
</wait> </log>
</run> <wait>
</image> <log>MySQL init process done. Ready for start up.</log>
</images> <time>30000</time> <!-- 30 seconds max -->
</configuration> </wait>
<!-- </run>
Connect this plugin to the maven lifecycle around the integration-test phase: </image>
start the container in pre-integration-test and stop it in post-integration-test. </images>
--> </configuration>
<executions> <!--
<execution> Connect this plugin to the maven lifecycle around the integration-test phase:
<id>start</id> start the container in pre-integration-test and stop it in post-integration-test.
<phase>pre-integration-test</phase> -->
<goals> <executions>
<goal>build</goal> <execution>
<goal>start</goal> <id>start</id>
</goals> <phase>pre-integration-test</phase>
</execution> <goals>
<execution> <goal>build</goal>
<id>stop</id> <goal>start</goal>
<phase>post-integration-test</phase> </goals>
<goals> </execution>
<goal>stop</goal> <execution>
</goals> <id>stop</id>
</execution> <phase>post-integration-test</phase>
</executions> <goals>
</plugin> <goal>stop</goal>
</plugins> </goals>
</build> </execution>
</profile> </executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>alt-mysql</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<!-- Build a Docker image of our MySQL installation, and run it as a container for our integration tests -->
<plugin>
<groupId>org.jolokia</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<watchInterval>500</watchInterval>
<logDate>default</logDate>
<verbose>true</verbose>
<autoPull>always</autoPull>
<images>
<image>
<name>mysql:5.7</name>
<alias>database</alias>
<run>
<namingStrategy>alias</namingStrategy>
<volumes>
<bind>
<volume>${project.basedir}/src/test/docker/alt-server:/etc/mysql/conf.ddata:/var/lib/postgresql/data</volume>
</bind>
<bind>
<volume>${project.basedir}/src/test/docker/init:/docker-entrypoint-initdb.d</volume>
</bind>
</volumes>
<env>
<MYSQL_ROOT_PASSWORD>debezium-rocks</MYSQL_ROOT_PASSWORD>
<MYSQL_DATABASE>mysql</MYSQL_DATABASE> <!-- database created upon init -->
<MYSQL_USER>${database.user}</MYSQL_USER>
<MYSQL_PASSWORD>${database.password}</MYSQL_PASSWORD>
</env>
<ports>
<port>${database.port}:3306</port>
</ports>
<log>
<prefix>mysql</prefix>
<enabled>true</enabled>
<color>yellow</color>
</log>
<wait>
<log>MySQL Community Server (GPL)</log>
<time>30000</time> <!-- 30 seconds max -->
</wait>
</run>
</image>
</images>
</configuration>
<!--
Connect this plugin to the maven lifecycle around the integration-test phase:
start the container in pre-integration-test and stop it in post-integration-test.
-->
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>build</goal>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles> </profiles>
</project> </project>

View File

@ -155,6 +155,7 @@
</execution> </execution>
</executions> </executions>
<configuration> <configuration>
<skipTests>${skipITs</skipTests>
<systemPropertyVariables> <systemPropertyVariables>
<!-- Make these available to the tests via system properties --> <!-- Make these available to the tests via system properties -->
<database.hostname>${docker.host.address}</database.hostname> <database.hostname>${docker.host.address}</database.hostname>

View File

@ -88,6 +88,7 @@
<!--Skip long running tests by default--> <!--Skip long running tests by default-->
<skipLongRunningTests>true</skipLongRunningTests> <skipLongRunningTests>true</skipLongRunningTests>
<skipITs>false</skipITs>
</properties> </properties>
<modules> <modules>
<module>support/checkstyle</module> <module>support/checkstyle</module>