|
27 | 27 | </parent> |
28 | 28 |
|
29 | 29 | <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> |
31 | 32 |
|
32 | 33 | <properties> |
| 34 | + |
33 | 35 | <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> |
35 | 39 |
|
36 | 40 | <!-- |
37 | 41 | ~ OSGi and JPMS options |
38 | 42 | --> |
39 | 43 | <bnd-module-name>org.apache.logging.log4j.layout.template.json.test</bnd-module-name> |
40 | 44 | <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 | + |
41 | 54 | </properties> |
42 | 55 |
|
43 | 56 | <dependencies> |
|
78 | 91 | </dependency> |
79 | 92 |
|
80 | 93 | <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> |
83 | 97 | <scope>test</scope> |
84 | 98 | </dependency> |
85 | 99 |
|
|
107 | 121 | <scope>test</scope> |
108 | 122 | </dependency> |
109 | 123 |
|
110 | | - <dependency> |
111 | | - <groupId>co.elastic.logging</groupId> |
112 | | - <artifactId>log4j2-ecs-layout</artifactId> |
113 | | - <scope>test</scope> |
114 | | - </dependency> |
115 | | - |
116 | 124 | </dependencies> |
117 | 125 |
|
118 | 126 | <build> |
119 | 127 | <plugins> |
120 | 128 |
|
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 | | - |
138 | 129 | <plugin> |
139 | 130 | <groupId>org.apache.maven.plugins</groupId> |
140 | 131 | <artifactId>maven-surefire-plugin</artifactId> |
|
159 | 150 |
|
160 | 151 | <id>docker</id> |
161 | 152 |
|
| 153 | + <!-- |
| 154 | + ~ Only the `ubuntu` CI runners have access to Docker |
| 155 | + --> |
162 | 156 | <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> |
164 | 164 | </activation> |
165 | 165 |
|
166 | 166 | <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 | + |
168 | 172 | <!-- `docker run elasticsearch:<TAG>` exists with code 137 due to insufficient memory. |
169 | 173 | 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 | + |
171 | 176 | </properties> |
172 | 177 |
|
173 | 178 | <build> |
|
177 | 182 | <groupId>io.fabric8</groupId> |
178 | 183 | <artifactId>docker-maven-plugin</artifactId> |
179 | 184 | <configuration> |
180 | | - <verbose>all</verbose> |
181 | 185 | <startParallel>true</startParallel> |
182 | 186 | <autoCreateCustomNetworks>true</autoCreateCustomNetworks> |
183 | 187 | <images> |
|
188 | 192 | <env> |
189 | 193 | <discovery.type>single-node</discovery.type> |
190 | 194 | <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> |
192 | 196 | </env> |
193 | 197 | <ports> |
194 | | - <port>9200:9200</port> |
| 198 | + <!-- Binds an ephemeral port to the `elasticsearch.port` Maven property. --> |
| 199 | + <port>localhost:elasticsearch.port:9200</port> |
195 | 200 | </ports> |
196 | 201 | <network> |
197 | 202 | <mode>custom</mode> |
|
203 | 208 | <color>cyan</color> |
204 | 209 | </log> |
205 | 210 | <wait> |
206 | | - <log>recovered \[0\] indices into cluster_state</log> |
| 211 | + <tcp> |
| 212 | + <ports> |
| 213 | + <port>9200</port> |
| 214 | + </ports> |
| 215 | + </tcp> |
207 | 216 | <time>60000</time> |
208 | 217 | </wait> |
209 | 218 | </run> |
|
221 | 230 | <alias>logstash</alias> |
222 | 231 | </network> |
223 | 232 | <env> |
224 | | - <LS_JAVA_OPTS>${elastic.java-opts}</LS_JAVA_OPTS> |
| 233 | + <LS_JAVA_OPTS>${elastic.javaOpts}</LS_JAVA_OPTS> |
225 | 234 | </env> |
226 | 235 | <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> |
229 | 240 | </ports> |
230 | 241 | <log> |
231 | 242 | <prefix>[LS]</prefix> |
|
237 | 248 | <arg>--pipeline.batch.size</arg> |
238 | 249 | <arg>1</arg> |
239 | 250 | <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 |
241 | 256 | gelf { |
242 | | - host => "logstash" |
243 | | - use_tcp => true |
244 | | - use_udp => false |
245 | | - port => 12222 |
246 | | - type => "gelf" |
| 257 | + host => "logstash" |
| 258 | + use_tcp => true |
| 259 | + use_udp => false |
| 260 | + port => 12222 |
| 261 | + type => "gelf" |
247 | 262 | } |
| 263 | +
|
| 264 | + # Documentation: https://www.elastic.co/guide/en/logstash/current/plugins-inputs-tcp.html |
248 | 265 | tcp { |
249 | | - port => 12345 |
250 | | - codec => json |
251 | | - type => "tcp" |
| 266 | + port => 12345 |
| 267 | + codec => json |
| 268 | + type => "tcp" |
252 | 269 | } |
| 270 | +
|
253 | 271 | } |
254 | 272 |
|
255 | 273 | filter { |
256 | 274 | if [type] == "gelf" { |
257 | 275 | # 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 |
259 | 278 | translate { |
260 | | - field => "[level]" |
261 | | - destination => "[levelName]" |
262 | | - dictionary => { |
263 | | - "0" => "EMERG" |
264 | | - "1" => "ALERT" |
265 | | - "2" => "CRITICAL" |
266 | | - "3" => "ERROR" |
267 | | - "4" => "WARN" |
268 | | - "5" => "NOTICE" |
269 | | - "6" => "INFO" |
270 | | - "7" => "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" |
271 | 290 | } |
272 | 291 | } |
273 | 292 | } |
274 | 293 | } |
275 | 294 |
|
| 295 | + # Documentation: https://www.elastic.co/guide/en/logstash/current/plugins-filters-elasticsearch.html |
276 | 296 | output { |
277 | 297 | # (Un)comment for debugging purposes |
278 | | - # stdout { codec => rubydebug } |
| 298 | + # stdout { codec => rubydebug } |
279 | 299 | elasticsearch { |
280 | | - hosts => ["http://elasticsearch:9200"] |
281 | | - index => "log4j" |
| 300 | + hosts => ["http://elasticsearch:9200"] |
| 301 | + index => "log4j" |
282 | 302 | } |
283 | | - }</arg> |
| 303 | + } |
| 304 | +
|
| 305 | + ]]></arg> |
284 | 306 | </exec> |
285 | 307 | </entrypoint> |
286 | 308 | <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> |
288 | 316 | <time>60000</time> |
289 | 317 | </wait> |
290 | 318 | </run> |
|
316 | 344 | <includes> |
317 | 345 | <include>**/*IT.java</include> |
318 | 346 | </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> |
319 | 352 | </configuration> |
320 | 353 | <executions> |
321 | 354 | <execution> |
|
0 commit comments