Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect path for RABBITMQ_CONFIG_FILE #5184

Conversation

mdedetrich
Copy link
Contributor

@mdedetrich mdedetrich commented Mar 27, 2022

Fixes a bug where the RABBITMQ_CONFIG_FILE was pointing to an incorrect path (i.e. "/etc/rabbitmq/rabbitmq-custom" rather than "/etc/rabbitmq/rabbitmq-custom.conf" ) which meant that the withEnv didn't end up doing anything since it was pointing to a path rather than a file. The tests didn't pick up this bug because they were just testing the existence of /etc/rabbitmq/rabbitmq-custom.conf and not the contents. Due to this the test/s were updated to make sure the actual contents of /etc/rabbitmq/rabbitmq-custom.conf is the same as the MountableFile that gets passed in (the other related tests have also been updated to make sure that they work as expected)

@mdedetrich
Copy link
Contributor Author

Doc generation appears to be failing but it appears to be unrelated since its some issue with Python on deploying docs, i.e.

3:07:36 AM: Traceback (most recent call last):
3:07:36 AM:   File "/opt/buildhome/python3.7/bin/mkdocs", line 8, in <module>
3:07:36 AM:     sys.exit(cli())
3:07:36 AM:   File "/opt/buildhome/python3.7/lib/python3.7/site-packages/click/core.py", line 1128, in __call__
3:07:36 AM:     return self.main(*args, **kwargs)
3:07:36 AM:   File "/opt/buildhome/python3.7/lib/python3.7/site-packages/click/core.py", line 1053, in main
3:07:36 AM:     rv = self.invoke(ctx)
3:07:36 AM:   File "/opt/buildhome/python3.7/lib/python3.7/site-packages/click/core.py", line 1659, in invoke
3:07:36 AM:     return _process_result(sub_ctx.command.invoke(sub_ctx))
3:07:36 AM:   File "/opt/buildhome/python3.7/lib/python3.7/site-packages/click/core.py", line 1395, in invoke
3:07:36 AM:     return ctx.invoke(self.callback, **ctx.params)
3:07:36 AM:   File "/opt/buildhome/python3.7/lib/python3.7/site-packages/click/core.py", line 754, in invoke
3:07:36 AM:     return __callback(*args, **kwargs)
3:07:36 AM:   File "/opt/buildhome/python3.7/lib/python3.7/site-packages/mkdocs/__main__.py", line 187, in build_command
3:07:36 AM:     build.build(config.load_config(**kwargs), dirty=not clean)
3:07:36 AM:   File "/opt/buildhome/python3.7/lib/python3.7/site-packages/mkdocs/config/base.py", line 216, in load_config
3:07:36 AM:     from mkdocs.config.defaults import get_schema
3:07:36 AM:   File "/opt/buildhome/python3.7/lib/python3.7/site-packages/mkdocs/config/defaults.py", line 1, in <module>
3:07:36 AM:     from mkdocs.config import config_options
3:07:36 AM:   File "/opt/buildhome/python3.7/lib/python3.7/site-packages/mkdocs/config/config_options.py", line 8, in <module>
3:07:36 AM:     from mkdocs import utils, theme, plugins
3:07:36 AM:   File "/opt/buildhome/python3.7/lib/python3.7/site-packages/mkdocs/theme.py", line 6, in <module>
3:07:36 AM:     from mkdocs.utils import filters
3:07:36 AM:   File "/opt/buildhome/python3.7/lib/python3.7/site-packages/mkdocs/utils/filters.py", line 13, in <module>
3:07:36 AM:     @jinja2.contextfilter
3:07:36 AM: AttributeError: module 'jinja2' has no attribute 'contextfilter'

Copy link
Member

@kiview kiview left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch @mdedetrich and thanks for providing this PR!
The docs error is indeed unrelated to this PR, we will fix this in #5186.

The only thing I would like us to reconsider is if we can somehow test that the configured and copied config file comes into effect, rather than testing for the implementation detail of it being present in a certain location of the container. Do you have an idea for using a specific config somewhere, that would allow for this?

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

assertThat(container.getLogs()).contains("config file(s) : /etc/rabbitmq/rabbitmq-custom.config");
assertThat(container.execInContainer("cat", "/etc/rabbitmq/rabbitmq-custom.config")
.getStdout()
).contains(configContents);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking for the content here does not really align that the file name and the ENV value are consistent.

container.start();

assertThat(container.getLogs()).contains("config file(s) : /etc/rabbitmq/rabbitmq-custom.conf");
assertThat(container.execInContainer("cat", "/etc/rabbitmq/rabbitmq-custom.conf")
.getStdout()
).contains(configContents);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is tricky to check for the content here, because it checks for the side-effect of an implementation detail (if file at RABBITMQ_CONFIG_FILE does not exist, on startup a default rabbitmq-custom.conf is written?).

That's why it will fail without the fix here with:

java.lang.AssertionError: 
Expecting actual:
  "loopback_users.guest = false
listeners.tcp.default = 5672
default_pass = guest
management.tcp.port = 15672
"
to contain:
  "loopback_users.guest = false
listeners.tcp.default = 5555
" 

@kiview
Copy link
Member

kiview commented Apr 7, 2022

I changed the tests to check if the effect of changing the log level is applied through them.

@mdedetrich
Copy link
Contributor Author

mdedetrich commented Apr 7, 2022

Sorry for taking so long, I was a bit busy. @kiview are more things required? tbh I am not that familiar with rabbitmq and this is just something I have noticed.

Copy link
Member

@kiview kiview left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Np, I just adopted the tests accordingly, thanks for your contribution 👍

@kiview kiview merged commit 53e80aa into testcontainers:master Apr 7, 2022
@mdedetrich mdedetrich deleted the fix-incorrect-RABBITMQ_CONFIG_FILE-path branch April 7, 2022 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants