Skip to content

Commit 8d572fc

Browse files
vyppkarwasz
andauthored
Enable docker profile in CI for log4j-layout-template-json-test (#2952)
Co-authored-by: Piotr P. Karwasz <piotr.github@karwasz.org>
1 parent 3ac49d5 commit 8d572fc

File tree

7 files changed

+296
-458
lines changed

7 files changed

+296
-458
lines changed

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

Lines changed: 96 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,30 @@
2727
</parent>
2828

2929
<artifactId>log4j-layout-template-json-test</artifactId>
30-
<name>Tests for the JSON Template Layout of Apache Log4j</name>
30+
31+
<name>Apache Log4j JSON Template Layout tests</name>
3132

3233
<properties>
34+
3335
<log4j.docgen.skip>true</log4j.docgen.skip>
34-
<log4jParentDir>${basedir}/..</log4jParentDir>
36+
<bnd.baseline.skip>true</bnd.baseline.skip>
37+
<maven.deploy.skip>true</maven.deploy.skip>
38+
<sign.skip>true</sign.skip>
3539

3640
<!--
3741
~ OSGi and JPMS options
3842
-->
3943
<bnd-module-name>org.apache.logging.log4j.layout.template.json.test</bnd-module-name>
4044
<Fragment-Host>org.apache.logging.log4j.core</Fragment-Host>
45+
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+
4154
</properties>
4255

4356
<dependencies>
@@ -78,8 +91,9 @@
7891
</dependency>
7992

8093
<dependency>
81-
<groupId>org.elasticsearch.client</groupId>
82-
<artifactId>elasticsearch-rest-high-level-client</artifactId>
94+
<groupId>co.elastic.clients</groupId>
95+
<artifactId>elasticsearch-java</artifactId>
96+
<version>${elastic.version}</version>
8397
<scope>test</scope>
8498
</dependency>
8599

@@ -107,34 +121,11 @@
107121
<scope>test</scope>
108122
</dependency>
109123

110-
<dependency>
111-
<groupId>co.elastic.logging</groupId>
112-
<artifactId>log4j2-ecs-layout</artifactId>
113-
<scope>test</scope>
114-
</dependency>
115-
116124
</dependencies>
117125

118126
<build>
119127
<plugins>
120128

121-
<!-- Disable ITs, which are Docker-dependent, by default. -->
122-
<plugin>
123-
<groupId>org.apache.maven.plugins</groupId>
124-
<artifactId>maven-failsafe-plugin</artifactId>
125-
<configuration>
126-
<skip>true</skip>
127-
</configuration>
128-
<executions>
129-
<execution>
130-
<goals>
131-
<goal>integration-test</goal>
132-
<goal>verify</goal>
133-
</goals>
134-
</execution>
135-
</executions>
136-
</plugin>
137-
138129
<plugin>
139130
<groupId>org.apache.maven.plugins</groupId>
140131
<artifactId>maven-surefire-plugin</artifactId>
@@ -159,15 +150,29 @@
159150

160151
<id>docker</id>
161152

153+
<!--
154+
~ Only the `ubuntu` CI runners have access to Docker
155+
-->
162156
<activation>
163-
<activeByDefault>false</activeByDefault>
157+
<os>
158+
<family>linux</family>
159+
</os>
160+
<property>
161+
<name>env.CI</name>
162+
<value>true</value>
163+
</property>
164164
</activation>
165165

166166
<properties>
167-
<elastic.version>8.10.2</elastic.version>
167+
168+
<!-- Suppress `docker-maven-plugin` output -->
169+
<docker.showLogs>false</docker.showLogs>
170+
<docker.verbose>false</docker.verbose>
171+
168172
<!-- `docker run elasticsearch:<TAG>` exists with code 137 due to insufficient memory.
169173
We limit the used JVM memory to avoid this OOM failure. -->
170-
<elastic.java-opts>-Xms750m -Xmx750m</elastic.java-opts>
174+
<elastic.javaOpts>-Xms750m -Xmx750m</elastic.javaOpts>
175+
171176
</properties>
172177

173178
<build>
@@ -177,7 +182,6 @@
177182
<groupId>io.fabric8</groupId>
178183
<artifactId>docker-maven-plugin</artifactId>
179184
<configuration>
180-
<verbose>all</verbose>
181185
<startParallel>true</startParallel>
182186
<autoCreateCustomNetworks>true</autoCreateCustomNetworks>
183187
<images>
@@ -188,10 +192,11 @@
188192
<env>
189193
<discovery.type>single-node</discovery.type>
190194
<xpack.security.enabled>false</xpack.security.enabled>
191-
<ES_JAVA_OPTS>${elastic.java-opts}</ES_JAVA_OPTS>
195+
<ES_JAVA_OPTS>${elastic.javaOpts}</ES_JAVA_OPTS>
192196
</env>
193197
<ports>
194-
<port>9200:9200</port>
198+
<!-- Binds an ephemeral port to the `elasticsearch.port` Maven property. -->
199+
<port>localhost:elasticsearch.port:9200</port>
195200
</ports>
196201
<network>
197202
<mode>custom</mode>
@@ -203,7 +208,11 @@
203208
<color>cyan</color>
204209
</log>
205210
<wait>
206-
<log>recovered \[0\] indices into cluster_state</log>
211+
<tcp>
212+
<ports>
213+
<port>9200</port>
214+
</ports>
215+
</tcp>
207216
<time>60000</time>
208217
</wait>
209218
</run>
@@ -221,11 +230,13 @@
221230
<alias>logstash</alias>
222231
</network>
223232
<env>
224-
<LS_JAVA_OPTS>${elastic.java-opts}</LS_JAVA_OPTS>
233+
<LS_JAVA_OPTS>${elastic.javaOpts}</LS_JAVA_OPTS>
225234
</env>
226235
<ports>
227-
<port>12222:12222</port>
228-
<port>12345:12345</port>
236+
<!-- Binds an ephemeral port to the `logstash.gelf.port` Maven property. -->
237+
<port>localhost:logstash.gelf.port:12222</port>
238+
<!-- Binds an ephemeral port to the `logstash.tcp.port` Maven property. -->
239+
<port>localhost:logstash.tcp.port:12345</port>
229240
</ports>
230241
<log>
231242
<prefix>[LS]</prefix>
@@ -237,54 +248,71 @@
237248
<arg>--pipeline.batch.size</arg>
238249
<arg>1</arg>
239250
<arg>-e</arg>
240-
<arg>input {
251+
<arg><![CDATA[
252+
253+
input {
254+
255+
# Documentation: https://www.elastic.co/guide/en/logstash/current/plugins-inputs-gelf.html
241256
gelf {
242-
host =&gt; "logstash"
243-
use_tcp =&gt; true
244-
use_udp =&gt; false
245-
port =&gt; 12222
246-
type =&gt; "gelf"
257+
host => "logstash"
258+
use_tcp => true
259+
use_udp => false
260+
port => 12222
261+
type => "gelf"
247262
}
263+
264+
# Documentation: https://www.elastic.co/guide/en/logstash/current/plugins-inputs-tcp.html
248265
tcp {
249-
port =&gt; 12345
250-
codec =&gt; json
251-
type =&gt; "tcp"
266+
port => 12345
267+
codec => json
268+
type => "tcp"
252269
}
270+
253271
}
254272
255273
filter {
256274
if [type] == "gelf" {
257275
# These are GELF/Syslog logging levels as defined in RFC 3164.
258-
# Map the integer level to its human readable format.
276+
# Map the integer level to its human-readable format.
277+
# Documentation: https://www.elastic.co/guide/en/logstash/current/plugins-filters-translate.html
259278
translate {
260-
field =&gt; "[level]"
261-
destination =&gt; "[levelName]"
262-
dictionary =&gt; {
263-
"0" =&gt; "EMERG"
264-
"1" =&gt; "ALERT"
265-
"2" =&gt; "CRITICAL"
266-
"3" =&gt; "ERROR"
267-
"4" =&gt; "WARN"
268-
"5" =&gt; "NOTICE"
269-
"6" =&gt; "INFO"
270-
"7" =&gt; "DEBUG"
279+
source => "[level]"
280+
target => "[levelName]"
281+
dictionary => {
282+
"0" => "EMERG"
283+
"1" => "ALERT"
284+
"2" => "CRITICAL"
285+
"3" => "ERROR"
286+
"4" => "WARN"
287+
"5" => "NOTICE"
288+
"6" => "INFO"
289+
"7" => "DEBUG"
271290
}
272291
}
273292
}
274293
}
275294
295+
# Documentation: https://www.elastic.co/guide/en/logstash/current/plugins-filters-elasticsearch.html
276296
output {
277297
# (Un)comment for debugging purposes
278-
# stdout { codec =&gt; rubydebug }
298+
# stdout { codec => rubydebug }
279299
elasticsearch {
280-
hosts =&gt; ["http://elasticsearch:9200"]
281-
index =&gt; "log4j"
300+
hosts => ["http://elasticsearch:9200"]
301+
index => "log4j"
282302
}
283-
}</arg>
303+
}
304+
305+
]]></arg>
284306
</exec>
285307
</entrypoint>
286308
<wait>
287-
<log>Successfully started Logstash API endpoint</log>
309+
<tcp>
310+
<host>localhost</host>
311+
<ports>
312+
<port>12222</port>
313+
<port>12345</port>
314+
</ports>
315+
</tcp>
288316
<time>60000</time>
289317
</wait>
290318
</run>
@@ -316,6 +344,11 @@
316344
<includes>
317345
<include>**/*IT.java</include>
318346
</includes>
347+
<systemPropertyVariables>
348+
<log4j.elasticsearch.port>${elasticsearch.port}</log4j.elasticsearch.port>
349+
<log4j.logstash.gelf.port>${logstash.gelf.port}</log4j.logstash.gelf.port>
350+
<log4j.logstash.tcp.port>${logstash.tcp.port}</log4j.logstash.tcp.port>
351+
</systemPropertyVariables>
319352
</configuration>
320353
<executions>
321354
<execution>

log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/EcsLayoutTest.java

Lines changed: 0 additions & 106 deletions
This file was deleted.

0 commit comments

Comments
 (0)