Skip to content

Commit 53e80aa

Browse files
mdedetrichkiview
andauthored
Fix incorrect path for RABBITMQ_CONFIG_FILE (#5184)
Co-authored-by: Kevin Wittek <[email protected]>
1 parent 734678f commit 53e80aa

File tree

5 files changed

+34
-29
lines changed

5 files changed

+34
-29
lines changed

modules/rabbitmq/src/main/java/org/testcontainers/containers/RabbitMQContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ public RabbitMQContainer withRabbitMQConfig(MountableFile rabbitMQConf) {
396396
* @return This container.
397397
*/
398398
public RabbitMQContainer withRabbitMQConfigSysctl(MountableFile rabbitMQConf) {
399-
withEnv("RABBITMQ_CONFIG_FILE", "/etc/rabbitmq/rabbitmq-custom");
399+
withEnv("RABBITMQ_CONFIG_FILE", "/etc/rabbitmq/rabbitmq-custom.conf");
400400
return withCopyFileToContainer(rabbitMQConf, "/etc/rabbitmq/rabbitmq-custom.conf");
401401
}
402402

modules/rabbitmq/src/test/java/org/testcontainers/containers/RabbitMQContainerTest.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414
import java.io.File;
1515
import java.io.FileInputStream;
1616
import java.io.IOException;
17+
import java.io.InputStream;
1718
import java.security.KeyManagementException;
1819
import java.security.KeyStore;
1920
import java.security.KeyStoreException;
2021
import java.security.NoSuchAlgorithmException;
2122
import java.security.UnrecoverableKeyException;
2223
import java.security.cert.CertificateException;
2324
import java.util.Collections;
25+
import java.util.Objects;
26+
import java.util.Scanner;
2427

2528
import static org.assertj.core.api.Assertions.assertThat;
2629
import static org.assertj.core.api.Assertions.assertThatCode;
@@ -115,43 +118,34 @@ public void shouldCreateRabbitMQContainerWithQueues() throws IOException, Interr
115118
}
116119

117120
@Test
118-
public void shouldMountConfigurationFile()
119-
{
121+
public void shouldMountConfigurationFile() {
120122
try (RabbitMQContainer container = new RabbitMQContainer(RabbitMQTestImages.RABBITMQ_IMAGE)) {
121-
122123
container.withRabbitMQConfig(MountableFile.forClasspathResource("/rabbitmq-custom.conf"));
123124
container.start();
124125

125-
assertThat(container.getLogs()).contains("config file(s) : /etc/rabbitmq/rabbitmq-custom.conf");
126-
assertThat(container.getLogs()).doesNotContain(" (not found)");
126+
assertThat(container.getLogs()).contains("debug"); // config file changes log level to `debug`
127127
}
128128
}
129129

130130

131131
@Test
132-
public void shouldMountConfigurationFileErlang()
133-
{
132+
public void shouldMountConfigurationFileErlang() {
134133
try (RabbitMQContainer container = new RabbitMQContainer(RabbitMQTestImages.RABBITMQ_IMAGE)) {
135-
136134
container.withRabbitMQConfigErlang(MountableFile.forClasspathResource("/rabbitmq-custom.config"));
137135
container.start();
138136

139-
assertThat(container.getLogs()).contains("config file(s) : /etc/rabbitmq/rabbitmq-custom.config");
140-
assertThat(container.getLogs()).doesNotContain(" (not found)");
137+
assertThat(container.getLogs()).contains("debug"); // config file changes log level to `debug`
141138
}
142139
}
143140

144141

145142
@Test
146-
public void shouldMountConfigurationFileSysctl()
147-
{
143+
public void shouldMountConfigurationFileSysctl() {
148144
try (RabbitMQContainer container = new RabbitMQContainer(RabbitMQTestImages.RABBITMQ_IMAGE)) {
149-
150145
container.withRabbitMQConfigSysctl(MountableFile.forClasspathResource("/rabbitmq-custom.conf"));
151146
container.start();
152147

153-
assertThat(container.getLogs()).contains("config file(s) : /etc/rabbitmq/rabbitmq-custom.conf");
154-
assertThat(container.getLogs()).doesNotContain(" (not found)");
148+
assertThat(container.getLogs()).contains("debug"); // config file changes log level to `debug`
155149
}
156150
}
157151

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<configuration>
2+
3+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4+
<!-- encoders are assigned the type
5+
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
6+
<encoder>
7+
<pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern>
8+
</encoder>
9+
</appender>
10+
11+
<root level="INFO">
12+
<appender-ref ref="STDOUT"/>
13+
</root>
14+
15+
<logger name="org.testcontainers" level="DEBUG"/>
16+
</configuration>
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
loopback_users.guest = false
2-
listeners.tcp.default = 5555
1+
log.console.level = debug
Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
[
2-
{ rabbit, [
3-
{ loopback_users, [ ] },
4-
{ tcp_listeners, [ 5555 ] },
5-
{ ssl_listeners, [ ] },
6-
{ default_vhost, <<"vhost">> },
7-
{ hipe_compile, false }
8-
] },
9-
{ rabbitmq_management, [ { listener, [
10-
{ port, 15672 },
11-
{ ssl, false }
12-
] } ] }
2+
{rabbit,
3+
[
4+
{log,
5+
[{console, [{level, debug}]}]
6+
}
7+
]
8+
}
139
].

0 commit comments

Comments
 (0)