Skip to content

Commit

Permalink
Fix incorrect path for RABBITMQ_CONFIG_FILE (#5184)
Browse files Browse the repository at this point in the history
Co-authored-by: Kevin Wittek <kevin@wittek.dev>
  • Loading branch information
mdedetrich and kiview committed Apr 7, 2022
1 parent 734678f commit 53e80aa
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 29 deletions.
Expand Up @@ -396,7 +396,7 @@ public RabbitMQContainer withRabbitMQConfig(MountableFile rabbitMQConf) {
* @return This container.
*/
public RabbitMQContainer withRabbitMQConfigSysctl(MountableFile rabbitMQConf) {
withEnv("RABBITMQ_CONFIG_FILE", "/etc/rabbitmq/rabbitmq-custom");
withEnv("RABBITMQ_CONFIG_FILE", "/etc/rabbitmq/rabbitmq-custom.conf");
return withCopyFileToContainer(rabbitMQConf, "/etc/rabbitmq/rabbitmq-custom.conf");
}

Expand Down
Expand Up @@ -14,13 +14,16 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.util.Collections;
import java.util.Objects;
import java.util.Scanner;

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

@Test
public void shouldMountConfigurationFile()
{
public void shouldMountConfigurationFile() {
try (RabbitMQContainer container = new RabbitMQContainer(RabbitMQTestImages.RABBITMQ_IMAGE)) {

container.withRabbitMQConfig(MountableFile.forClasspathResource("/rabbitmq-custom.conf"));
container.start();

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


@Test
public void shouldMountConfigurationFileErlang()
{
public void shouldMountConfigurationFileErlang() {
try (RabbitMQContainer container = new RabbitMQContainer(RabbitMQTestImages.RABBITMQ_IMAGE)) {

container.withRabbitMQConfigErlang(MountableFile.forClasspathResource("/rabbitmq-custom.config"));
container.start();

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


@Test
public void shouldMountConfigurationFileSysctl()
{
public void shouldMountConfigurationFileSysctl() {
try (RabbitMQContainer container = new RabbitMQContainer(RabbitMQTestImages.RABBITMQ_IMAGE)) {

container.withRabbitMQConfigSysctl(MountableFile.forClasspathResource("/rabbitmq-custom.conf"));
container.start();

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

Expand Down
16 changes: 16 additions & 0 deletions modules/rabbitmq/src/test/resources/logback-test.xml
@@ -0,0 +1,16 @@
<configuration>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>

<logger name="org.testcontainers" level="DEBUG"/>
</configuration>
3 changes: 1 addition & 2 deletions modules/rabbitmq/src/test/resources/rabbitmq-custom.conf
@@ -1,2 +1 @@
loopback_users.guest = false
listeners.tcp.default = 5555
log.console.level = debug
18 changes: 7 additions & 11 deletions modules/rabbitmq/src/test/resources/rabbitmq-custom.config
@@ -1,13 +1,9 @@
[
{ rabbit, [
{ loopback_users, [ ] },
{ tcp_listeners, [ 5555 ] },
{ ssl_listeners, [ ] },
{ default_vhost, <<"vhost">> },
{ hipe_compile, false }
] },
{ rabbitmq_management, [ { listener, [
{ port, 15672 },
{ ssl, false }
] } ] }
{rabbit,
[
{log,
[{console, [{level, debug}]}]
}
]
}
].

0 comments on commit 53e80aa

Please sign in to comment.