Skip to content

Commit 428d112

Browse files
vyppkarwasz
authored andcommitted
Enable docker profile in CI for log4j-layout-template-json-test (#2953)
1 parent c96ead3 commit 428d112

File tree

3 files changed

+192
-107
lines changed

3 files changed

+192
-107
lines changed

log4j-layout-template-json-test/pom.xml

Lines changed: 87 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@
4343
<bnd-module-name>org.apache.logging.log4j.layout.template.json.test</bnd-module-name>
4444
<Fragment-Host>org.apache.logging.log4j.core</Fragment-Host>
4545

46+
<!-- `elastic.version` is used for two purposes:
47+
48+
1. `co.elastic.clients:elasticsearch-java` version
49+
2. The Docker image version of the ELK-stack
50+
51+
As of 2024-09-16, these all (Maven artifacts and Elastic products) get released with the same version. -->
52+
<elastic.version>8.15.1</elastic.version>
53+
4654
</properties>
4755

4856
<dependencies>
@@ -85,6 +93,7 @@
8593
<dependency>
8694
<groupId>co.elastic.clients</groupId>
8795
<artifactId>elasticsearch-java</artifactId>
96+
<version>${elastic.version}</version>
8897
<scope>test</scope>
8998
</dependency>
9099

@@ -129,23 +138,6 @@
129138
<build>
130139
<plugins>
131140

132-
<!-- Disable ITs, which are Docker-dependent, by default. -->
133-
<plugin>
134-
<groupId>org.apache.maven.plugins</groupId>
135-
<artifactId>maven-failsafe-plugin</artifactId>
136-
<configuration>
137-
<skip>true</skip>
138-
</configuration>
139-
<executions>
140-
<execution>
141-
<goals>
142-
<goal>integration-test</goal>
143-
<goal>verify</goal>
144-
</goals>
145-
</execution>
146-
</executions>
147-
</plugin>
148-
149141
<plugin>
150142
<groupId>org.apache.maven.plugins</groupId>
151143
<artifactId>maven-surefire-plugin</artifactId>
@@ -170,15 +162,29 @@
170162

171163
<id>docker</id>
172164

165+
<!--
166+
~ Only the `ubuntu` CI runners have access to Docker
167+
-->
173168
<activation>
174-
<activeByDefault>false</activeByDefault>
169+
<os>
170+
<family>linux</family>
171+
</os>
172+
<property>
173+
<name>env.CI</name>
174+
<value>true</value>
175+
</property>
175176
</activation>
176177

177178
<properties>
178-
<elastic.version>8.10.2</elastic.version>
179+
180+
<!-- Suppress `docker-maven-plugin` output -->
181+
<docker.showLogs>false</docker.showLogs>
182+
<docker.verbose>false</docker.verbose>
183+
179184
<!-- `docker run elasticsearch:<TAG>` exists with code 137 due to insufficient memory.
180185
We limit the used JVM memory to avoid this OOM failure. -->
181-
<elastic.java-opts>-Xms750m -Xmx750m</elastic.java-opts>
186+
<elastic.javaOpts>-Xms750m -Xmx750m</elastic.javaOpts>
187+
182188
</properties>
183189

184190
<build>
@@ -188,7 +194,6 @@
188194
<groupId>io.fabric8</groupId>
189195
<artifactId>docker-maven-plugin</artifactId>
190196
<configuration>
191-
<verbose>all</verbose>
192197
<startParallel>true</startParallel>
193198
<autoCreateCustomNetworks>true</autoCreateCustomNetworks>
194199
<images>
@@ -199,10 +204,11 @@
199204
<env>
200205
<discovery.type>single-node</discovery.type>
201206
<xpack.security.enabled>false</xpack.security.enabled>
202-
<ES_JAVA_OPTS>${elastic.java-opts}</ES_JAVA_OPTS>
207+
<ES_JAVA_OPTS>${elastic.javaOpts}</ES_JAVA_OPTS>
203208
</env>
204209
<ports>
205-
<port>9200:9200</port>
210+
<!-- Binds an ephemeral port to the `elasticsearch.port` Maven property. -->
211+
<port>localhost:elasticsearch.port:9200</port>
206212
</ports>
207213
<network>
208214
<mode>custom</mode>
@@ -214,7 +220,11 @@
214220
<color>cyan</color>
215221
</log>
216222
<wait>
217-
<log>recovered \[0\] indices into cluster_state</log>
223+
<tcp>
224+
<ports>
225+
<port>9200</port>
226+
</ports>
227+
</tcp>
218228
<time>60000</time>
219229
</wait>
220230
</run>
@@ -232,11 +242,13 @@
232242
<alias>logstash</alias>
233243
</network>
234244
<env>
235-
<LS_JAVA_OPTS>${elastic.java-opts}</LS_JAVA_OPTS>
245+
<LS_JAVA_OPTS>${elastic.javaOpts}</LS_JAVA_OPTS>
236246
</env>
237247
<ports>
238-
<port>12222:12222</port>
239-
<port>12345:12345</port>
248+
<!-- Binds an ephemeral port to the `logstash.gelf.port` Maven property. -->
249+
<port>localhost:logstash.gelf.port:12222</port>
250+
<!-- Binds an ephemeral port to the `logstash.tcp.port` Maven property. -->
251+
<port>localhost:logstash.tcp.port:12345</port>
240252
</ports>
241253
<log>
242254
<prefix>[LS]</prefix>
@@ -248,54 +260,71 @@
248260
<arg>--pipeline.batch.size</arg>
249261
<arg>1</arg>
250262
<arg>-e</arg>
251-
<arg>input {
263+
<arg><![CDATA[
264+
265+
input {
266+
267+
# Documentation: https://www.elastic.co/guide/en/logstash/current/plugins-inputs-gelf.html
252268
gelf {
253-
host =&gt; "logstash"
254-
use_tcp =&gt; true
255-
use_udp =&gt; false
256-
port =&gt; 12222
257-
type =&gt; "gelf"
269+
host => "logstash"
270+
use_tcp => true
271+
use_udp => false
272+
port => 12222
273+
type => "gelf"
258274
}
275+
276+
# Documentation: https://www.elastic.co/guide/en/logstash/current/plugins-inputs-tcp.html
259277
tcp {
260-
port =&gt; 12345
261-
codec =&gt; json
262-
type =&gt; "tcp"
278+
port => 12345
279+
codec => json
280+
type => "tcp"
263281
}
282+
264283
}
265284
266285
filter {
267286
if [type] == "gelf" {
268287
# These are GELF/Syslog logging levels as defined in RFC 3164.
269-
# Map the integer level to its human readable format.
288+
# Map the integer level to its human-readable format.
289+
# Documentation: https://www.elastic.co/guide/en/logstash/current/plugins-filters-translate.html
270290
translate {
271-
field =&gt; "[level]"
272-
destination =&gt; "[levelName]"
273-
dictionary =&gt; {
274-
"0" =&gt; "EMERG"
275-
"1" =&gt; "ALERT"
276-
"2" =&gt; "CRITICAL"
277-
"3" =&gt; "ERROR"
278-
"4" =&gt; "WARN"
279-
"5" =&gt; "NOTICE"
280-
"6" =&gt; "INFO"
281-
"7" =&gt; "DEBUG"
291+
source => "[level]"
292+
target => "[levelName]"
293+
dictionary => {
294+
"0" => "EMERG"
295+
"1" => "ALERT"
296+
"2" => "CRITICAL"
297+
"3" => "ERROR"
298+
"4" => "WARN"
299+
"5" => "NOTICE"
300+
"6" => "INFO"
301+
"7" => "DEBUG"
282302
}
283303
}
284304
}
285305
}
286306
307+
# Documentation: https://www.elastic.co/guide/en/logstash/current/plugins-filters-elasticsearch.html
287308
output {
288309
# (Un)comment for debugging purposes
289-
# stdout { codec =&gt; rubydebug }
310+
# stdout { codec => rubydebug }
290311
elasticsearch {
291-
hosts =&gt; ["http://elasticsearch:9200"]
292-
index =&gt; "log4j"
312+
hosts => ["http://elasticsearch:9200"]
313+
index => "log4j"
293314
}
294-
}</arg>
315+
}
316+
317+
]]></arg>
295318
</exec>
296319
</entrypoint>
297320
<wait>
298-
<log>Successfully started Logstash API endpoint</log>
321+
<tcp>
322+
<host>localhost</host>
323+
<ports>
324+
<port>12222</port>
325+
<port>12345</port>
326+
</ports>
327+
</tcp>
299328
<time>60000</time>
300329
</wait>
301330
</run>
@@ -327,6 +356,11 @@
327356
<includes>
328357
<include>**/*IT.java</include>
329358
</includes>
359+
<systemPropertyVariables>
360+
<log4j.elasticsearch.port>${elasticsearch.port}</log4j.elasticsearch.port>
361+
<log4j.logstash.gelf.port>${logstash.gelf.port}</log4j.logstash.gelf.port>
362+
<log4j.logstash.tcp.port>${logstash.tcp.port}</log4j.logstash.tcp.port>
363+
</systemPropertyVariables>
330364
</configuration>
331365
<executions>
332366
<execution>

0 commit comments

Comments
 (0)