Convert start/stop db into a profile.

Now we're using the docker-maven-plugin for building images and also
for starting/stopping the db, we need to ensure we don't skip it at
the wrong time. It's simpler to avoid using the <skip> element at all,
and instead use a profile based on the skip.integrationtests property
so that we only start the db when running integration tests.
This commit is contained in:
Tom Page
2019-09-24 16:26:34 +01:00
parent 5d2c61ee63
commit ccd0fbf737

132
pom.xml
View File

@@ -278,13 +278,6 @@
<goal>build</goal> <goal>build</goal>
</goals> </goals>
</execution> </execution>
<execution>
<id>build-image-verify</id>
<phase>verify</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
@@ -454,6 +447,74 @@
</pluginManagement> </pluginManagement>
</build> </build>
</profile> </profile>
<profile>
<id>start-db</id>
<activation>
<property>
<name>skip.integrationtests</name>
<value>false</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${fabric8.docker.version}</version>
<configuration>
<images>
<image>
<alias>test-database</alias>
<name>postgres:${postgres.version}</name>
<run>
<ports>
<port>${database.port}:${postgresql.port}</port>
</ports>
<env>
<POSTGRES_PASSWORD>${alfresco.db.password}</POSTGRES_PASSWORD>
<POSTGRES_USER>${alfresco.db.username}</POSTGRES_USER>
<POSTGRES_DB>${alfresco.test.db.name}</POSTGRES_DB>
</env>
<cmd>
<shell>-c max_connections=300</shell>
</cmd>
<wait>
<log>database system is ready to accept connections</log>
<time>20000</time>
</wait>
</run>
</image>
<image>
<name>alfresco/alfresco-activemq:${activemq.version}</name>
<run>
<ports>
<port>${activemq.port1}:${activemq.port1}</port>
<port>${activemq.port2}:${activemq.port2}</port>
</ports>
</run>
</image>
</images>
</configuration>
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<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>
<properties> <properties>
@@ -494,6 +555,7 @@
<jackson.version>2.9.8</jackson.version> <jackson.version>2.9.8</jackson.version>
<fabric8.docker.version>0.25.0</fabric8.docker.version> <fabric8.docker.version>0.25.0</fabric8.docker.version>
<docker.source.dir>.</docker.source.dir>
<mockito.version>1.10.19</mockito.version> <mockito.version>1.10.19</mockito.version>
<postgresql.version>42.2.5</postgresql.version> <postgresql.version>42.2.5</postgresql.version>
<postgresql.port>5432</postgresql.port> <postgresql.port>5432</postgresql.port>
@@ -1118,62 +1180,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${fabric8.docker.version}</version>
<configuration>
<images>
<image>
<alias>test-database</alias>
<name>postgres:${postgres.version}</name>
<run>
<ports>
<port>${database.port}:${postgresql.port}</port>
</ports>
<env>
<POSTGRES_PASSWORD>${alfresco.db.password}</POSTGRES_PASSWORD>
<POSTGRES_USER>${alfresco.db.username}</POSTGRES_USER>
<POSTGRES_DB>${alfresco.test.db.name}</POSTGRES_DB>
</env>
<cmd>
<shell>-c max_connections=300</shell>
</cmd>
<wait>
<log>database system is ready to accept connections</log>
<time>20000</time>
</wait>
</run>
</image>
<image>
<name>alfresco/alfresco-activemq:${activemq.version}</name>
<run>
<ports>
<port>${activemq.port1}:${activemq.port1}</port>
<port>${activemq.port2}:${activemq.port2}</port>
</ports>
</run>
</image>
</images>
<skip>${skip.integrationtests}</skip>
</configuration>
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>
</build> </build>