-
Notifications
You must be signed in to change notification settings - Fork 3
/
pom.xml
408 lines (395 loc) · 17 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
<?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.github.eostermueller.snail4j</groupId>
<artifactId>systemUnderTest</artifactId>
<version>0.0.1</version>
<properties>
<maven.failsafe.version>2.22.2</maven.failsafe.version>
<slf4jVersion>1.6.1</slf4jVersion>
<h2.maven.plugin.version>0.1_1.4.191</h2.maven.plugin.version>
<!-- The following allow us to pass in -D parameters to the mvn script -->
<snail4j.wiremock.port>8081</snail4j.wiremock.port>
<snail4j.wiremock.hostname>localhost</snail4j.wiremock.hostname>
<snail4j.sut.arguments></snail4j.sut.arguments>
<snail4j.h2.hostname>localhost</snail4j.h2.hostname>
<snail4j.h2.port>9093</snail4j.h2.port>
<snail4j.sut.port>8080</snail4j.sut.port>
<!-- the following -V is an innocuous mvn parameter, couldn't get "" to work.
The -V will be used when these optional parameters are not passed in -->
<snail4j.maven.offline.passthru>-V</snail4j.maven.offline.passthru>
<snail4j.maven.repo.passthru>-V</snail4j.maven.repo.passthru>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4jVersion}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4jVersion}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>Windows</id>
<activation>
<os>
<family>Windows</family>
</os>
</activation>
<properties>
<!--
The following "benigh filler args" are ugly tech debt.
To fix this, need to yank the maven-process-plugin
-->
<script.extension>.cmd</script.extension>
<sutApp.cmd.01>cmd.exe</sutApp.cmd.01>
<sutApp.cmd.02>/E:ON</sutApp.cmd.02> <!-- benign filler arg -->
<sutApp.cmd.03>/E:ON</sutApp.cmd.03> <!-- benign filler arg -->
<sutApp.cmd.04>/E:ON</sutApp.cmd.04> <!-- benign filler arg -->
<sutApp.cmd.05>/E:ON</sutApp.cmd.05> <!-- benign filler arg -->
<sutApp.cmd.06>/E:ON</sutApp.cmd.06> <!-- benign filler arg -->
<sutApp.cmd.07>/E:ON</sutApp.cmd.07> <!-- benign filler arg -->
<sutApp.cmd.08>/E:ON</sutApp.cmd.08> <!-- benign filler arg -->
<sutApp.cmd.09>/E:ON</sutApp.cmd.09> <!-- benign filler arg -->
<sutApp.cmd.10>/C</sutApp.cmd.10>
<sutApp.cmd.11>..${file.separator}apache-maven-3.6.3${file.separator}bin${file.separator}mvn${script.extension} -e -X ${snail4j.maven.offline.passthru} ${snail4j.maven.repo.passthru} -Dspring-boot.run.fork=true -Dspring-boot.run.jvmArguments="-Dsnail4j.wiremock.hostname=${snail4j.wiremock.hostname} -Dsnail4j.h2.port=${snail4j.h2.port} -Dsnail4j.h2.hostname=${snail4j.h2.hostname} -Dsnail4j.wiremock.port=${snail4j.wiremock.port} -Dglowroot.agent.port=${snail4j.glowroot.port} ${snail4j.sut.jvmArguments}" -Dspring-boot.run.agents=${user.home}/.load-test-in-a-box/glowroot/glowroot/glowroot.jar -Dspring-boot.run.arguments=--server.port=${snail4j.sut.port} spring-boot:run</sutApp.cmd.11>
</properties>
</profile>
<profile>
<id>unix</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<script.extension></script.extension>
<sutApp.cmd.01>..${file.separator}apache-maven-3.6.3${file.separator}bin${file.separator}mvn${script.extension}</sutApp.cmd.01>
<sutApp.cmd.02>-e</sutApp.cmd.02>
<sutApp.cmd.03>-X</sutApp.cmd.03>
<sutApp.cmd.04>-debug</sutApp.cmd.04>
<sutApp.cmd.05>${snail4j.maven.offline.passthru}</sutApp.cmd.05>
<sutApp.cmd.06>${snail4j.maven.repo.passthru}</sutApp.cmd.06>
<sutApp.cmd.07>-Dspring-boot.run.fork=true</sutApp.cmd.07>
<!--
The following says "make sure to wrap multiple values between quotes" but on make, that causes a problem and the
-D system parameters were not recognized...big problem.
https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/html/#goals-run-parameters-details-jvmArguments
Oddly, these didnt' have to be removed for MS-Windows...
I'm thinking this is a problem with the maven-process-plugin, because the following works OK with mac and quotes,
but the maven-process-plugin is not used here:
https://github.com/eostermueller/mac-and-windows-processes
-->
<sutApp.cmd.08>-Dspring-boot.run.jvmArguments=-Dsnail4j.wiremock.hostname=${snail4j.wiremock.hostname} -Dsnail4j.h2.port=${snail4j.h2.port} -Dsnail4j.h2.hostname=${snail4j.h2.hostname} -Dsnail4j.wiremock.port=${snail4j.wiremock.port} -Dglowroot.agent.port=${snail4j.glowroot.port} ${snail4j.sut.jvmArguments}</sutApp.cmd.08>
<sutApp.cmd.09>-Dspring-boot.run.agents=${user.home}/.load-test-in-a-box/glowroot/glowroot/glowroot.jar</sutApp.cmd.09>
<sutApp.cmd.10>-Dspring-boot.run.arguments=--server.port=${snail4j.sut.port}</sutApp.cmd.10>
<sutApp.cmd.11>spring-boot:run</sutApp.cmd.11>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<configuration>
<systemPropertyVariables>
<com.github.eostermueller.snail4j.kill.file>
${user.home}/.load-test-in-a-box/deleteMeToStopSnail4jSut.txt</com.github.eostermueller.snail4j.kill.file>
</systemPropertyVariables>
</configuration>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven.failsafe.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.bazaarvoice.maven.plugins</groupId>
<artifactId>process-exec-maven-plugin</artifactId>
<version>0.9</version>
<!-- <version>0.10-SNAPSHOT</version> -->
<executions>
<!--Start process 1, eg., a dropwizard app dependency-->
<execution>
<id>wiremock</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<name>wiremock</name>
<workingDir>
${user.home}/.load-test-in-a-box/wiremock</workingDir>
<waitForInterrupt>false</waitForInterrupt>
<waitAfterLaunch>4</waitAfterLaunch>
<processLogFile>${user.home}/.load-test-in-a-box/log/wiremock.log</processLogFile>
<!-- <tcpHealthcheckHostname>
localhost</tcpHealthcheckHostname>
<tcpHealthcheckPort>8081</tcpHealthcheckPort>
-->
<arguments>
<argument>..${file.separator}apache-maven-3.6.3${file.separator}bin${file.separator}mvn${script.extension}</argument>
<argument>${snail4j.maven.offline.passthru}</argument>
<argument>${snail4j.maven.repo.passthru}</argument>
<argument>-Dsnail4j.wiremock.port=${snail4j.wiremock.port}</argument>
<argument>clean</argument>
<argument>compile</argument>
<argument>wiremock:run</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>start-h2</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<name>h2</name>
<workingDir>
${user.home}/.load-test-in-a-box/data</workingDir>
<waitForInterrupt>false</waitForInterrupt>
<processLogFile>${user.home}/.load-test-in-a-box/log/h2.log</processLogFile>
<waitAfterLaunch>4</waitAfterLaunch>
<!-- <tcpHealthcheckHostname>
localhost</tcpHealthcheckHostname>
<tcpHealthcheckPort>${snail4j.h2.port}</tcpHealthcheckPort>
-->
<arguments>
<argument>..${file.separator}apache-maven-3.6.3${file.separator}bin${file.separator}mvn${script.extension}</argument>
<argument>-debug</argument>
<argument>-Dh2Version=1.4.191</argument>
<argument>${snail4j.maven.offline.passthru}</argument>
<argument>${snail4j.maven.repo.passthru}</argument>
<argument>-Dh2.port=${snail4j.h2.port}</argument>
<!-- <argument>-Dh2.baseDirectory=${user.home}/.load-test-in-a-box/data</argument> -->
<!-- <argument>-Dh2.baseDirectory=C:/Users/eoste/.load-test-in-a-box/data</argument> -->
<argument>com.github.eostermueller:h2-maven-plugin:${h2.maven.plugin.version}:spawn</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>sutApp</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<name>sutApp</name>
<workingDir>
${user.home}/.load-test-in-a-box/sutApp</workingDir>
<waitForInterrupt>false</waitForInterrupt>
<processLogFile>${user.home}/.load-test-in-a-box/log/sutApp.log</processLogFile>
<waitAfterLaunch>4</waitAfterLaunch>
<!-- <tcpHealthcheckHostname>
localhost</tcpHealthcheckHostname>
<tcpHealthcheckPort>8080</tcpHealthcheckPort>
-->
<arguments>
<argument>${sutApp.cmd.01}</argument>
<argument>${sutApp.cmd.02}</argument>
<argument>${sutApp.cmd.03}</argument>
<argument>${sutApp.cmd.04}</argument>
<argument>${sutApp.cmd.05}</argument>
<argument>${sutApp.cmd.06}</argument>
<argument>${sutApp.cmd.07}</argument>
<argument>${sutApp.cmd.08}</argument>
<argument>${sutApp.cmd.09}</argument>
<argument>${sutApp.cmd.10}</argument>
<argument>${sutApp.cmd.11}</argument>
<!-- @stolenFrom: https://stackoverflow.com/a/46628861/2377579 -->
<!-- @stolenFrom: http://myjavaadventures.com/blog/2018/07/21/spring-boot-pass-arguments/ -->
<!-- <argument>-Dspring-boot.run.jvmArguments="-javaagent:${user.home}/.load-test-in-a-box/glowroot/glowroot/glowroot.jar,-Dglowroot.agent.port=${snail4j.glowroot.port}"</argument> -->
</arguments>
</configuration>
</execution>
<!--Stop all processes in reverse order-->
<execution>
<id>stop-all</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-all</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.eostermueller</groupId>
<artifactId>h2-maven-plugin</artifactId>
<version>${h2.maven.plugin.version}</version>
<configuration>
<port>${snail4j.h2.port}</port>
</configuration>
<executions>
<execution>
<id>Stop a spawned H2 TCP server</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- TODO: workaround to kill windows processes: mvn antrun:run@jcmd-surefire -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<!-- workaround to kill windows processes -->
<execution>
<id>jcmd-surefire</id>
<phase>initialize</phase>
<configuration>
<target>
<property name="runtime_classpath" refid="maven.runtime.classpath" />
<exec executable="${JAVA_HOME}/bin/jcmd">
<redirector outputproperty="process.pid">
<outputfilterchain>
<linecontainsregexp>
<!-- it can be much simpler, but I wanted to confirm if it is a surefire process: -->
<regexp pattern="[\w\\\:]+\\surefire[0-9]+.+(surefire\_?[0-9]+tmp\ ?)+" />
</linecontainsregexp>
<tokenfilter>
<replaceregex pattern=" [\w\\\:]+\\surefire[0-9]+.+(surefire\_?[0-9]+tmp\ ?)+"
replace="" />
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
<exec executable="taskkill" osfamily="winnt">
<arg value="/F" />
<arg value="/PID" />
<arg value="${process.pid}" />
</exec>
<!-- never used:
exec executable="kill" osfamily="unix">
<arg value="-9" />
<arg value="${process.pid}" />
</exec -->
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>jcmd-wiremock</id>
<phase>initialize</phase>
<configuration>
<target>
<property name="runtime_classpath" refid="maven.runtime.classpath" />
<exec executable="${JAVA_HOME}/bin/jcmd">
<arg value="-l" />
<redirector outputproperty="process.pid">
<outputfilterchain>
<linecontainsregexp>
<!-- some greedy regexp to identy windows path, but it looks more clear than a simple .+ -->
<regexp pattern="org\.codehaus\.plexus\.classworlds\.launcher\.Launcher\ .* wiremock\:run" />
</linecontainsregexp>
<tokenfilter>
<replaceregex pattern=" org\.codehaus\.plexus\.classworlds\.launcher\.Launcher\ .* wiremock\:run" replace="" />
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
<exec executable="taskkill" osfamily="winnt">
<arg value="/F" />
<arg value="/PID" />
<arg value="${process.pid}" />
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution >
<execution>
<id>jcmd-workloadcontroller</id>
<phase>initialize</phase>
<configuration>
<target>
<property name="runtime_classpath" refid="maven.runtime.classpath" />
<exec executable="${JAVA_HOME}/bin/jcmd">
<redirector outputproperty="process.pid">
<outputfilterchain>
<linecontainsregexp>
<regexp pattern="com\.github\.eostermueller\.tjp2\.rest\.WorkloadController" />
</linecontainsregexp>
<tokenfilter>
<replaceregex pattern="(\d+)( com\.github\.eostermueller\.tjp2\.rest\.WorkloadController)(.*)"
replace="\1" />
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
<exec executable="taskkill" osfamily="winnt">
<arg value="/F" />
<arg value="/T" />
<arg value="/PID" />
<arg value="${process.pid}" />
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<!-- this is for testing purposes.
adding timestamp to log.txt at processManager directory -->
<execution>
<id>tmp-echo</id>
<phase>initialize</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<tstamp>
<format property="last.updated" pattern="yyyy-MM-dd hh:mm:ss"/>
</tstamp>
<echo>Hello world!</echo>
<echo message="${last.updated}"/>
<concat destfile="log.txt" append="yes" fixlastline="yes">${last.updated}</concat>
<concat destfile="log.txt" append="yes" fixlastline="yes">
<path path="hola.txt"/>
</concat>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>