-
Notifications
You must be signed in to change notification settings - Fork 0
/
pom.xml
156 lines (147 loc) · 7.18 KB
/
pom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.horiaconstantin</groupId>
<artifactId>integrationtestingdocker</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- Using docker packaging to bind the most important goals to the relevant lifecycle phases -->
<!-- See http://dmp.fabric8.io/#installation -->
<!-- I'm not using it here because I want to also bind the docker:remove goal to the post-integration-test -->
<!--<packaging>docker</packaging>-->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<mysql-jdbc.version>8.0.13</mysql-jdbc.version>
<junit.version>4.12</junit.version>
<docker-maven-plugin.version>0.28.0</docker-maven-plugin.version>
<maven-failsafe-plugin.version>3.0.0-M2</maven-failsafe-plugin.version>
<maven-surefire-plugin.version>3.0.0-M1</maven-surefire-plugin.version>
<!-- Used in Dockerfile -->
<mysql.version>5.7</mysql.version>
<!-- Docker maven plugin global configuration -->
<!-- Show the container logs, see http://dmp.fabric8.io/#start-configuration -->
<docker.showLogs>true</docker.showLogs>
<!-- Show verbose output of the plugin (e.g. build steps) -->
<docker.verbose>true</docker.verbose>
<!-- This property is not mandatory, but if it's missing the IDE will report an invalid pom -->
<docker.host.address>localhost</docker.host.address>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-jdbc.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker-maven-plugin.version}</version>
<!-- Extensions need to be enabled for docker packaging to work -->
<extensions>true</extensions>
<configuration>
<images>
<image>
<name>mysql-test</name>
<alias>mysql-test</alias>
<build>
<!-- I want to have full control over what is going into the docker image -->
<!-- See http://dmp.fabric8.io/#build-assembly -->
<assembly>
<descriptor>${project.basedir}/src/test/resources/docker/mysql-test/assembly.xml
</descriptor>
</assembly>
<dockerFileDir>${project.basedir}/src/test/resources/docker/mysql-test</dockerFileDir>
<dockerFile>Dockerfile</dockerFile>
<!-- The character that is used for variable replacement in the Dockerfile-->
<filter>@</filter>
</build>
</image>
</images>
</configuration>
<!-- I need to manually map the docker goals to the execution phases. -->
<!-- Unfortunately, mvn help:describe -Dcmd=verify will not show these custom execution mappings -->
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<!-- Trying to stop any already running container. -->
<goal>stop</goal>
<goal>build</goal>
<goal>start</goal>
</goals>
<configuration>
<images>
<image>
<external>
<type>compose</type>
<basedir>${project.basedir}/src/test/resources/docker</basedir>
</external>
<run>
<!-- I've tried to make the wait depend on the tcp port, but I didn't succeed -->
<!-- Let's wait for the log of mysql to mention that port 3306 is up and running -->
<wait>
<time>120000</time>
<log>port: 3306</log>
</wait>
</run>
</image>
</images>
</configuration>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
<goal>remove</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<configuration>
<includes>
<include>**IntegrationTest.java</include>
</includes>
<systemPropertyVariables>
<docker.host.address>${docker.host.address}</docker.host.address>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- We don't care about unit tests in this project, so we're skipping them -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</project>