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

DevServices config not making it to quarkusIntTest config #25730

Closed
GregJohnStewart opened this issue May 23, 2022 · 7 comments · Fixed by #25799
Closed

DevServices config not making it to quarkusIntTest config #25730

GregJohnStewart opened this issue May 23, 2022 · 7 comments · Fixed by #25799
Labels
area/devservices kind/bug Something isn't working triage/wontfix This will not be worked on
Milestone

Comments

@GregJohnStewart
Copy link
Contributor

GregJohnStewart commented May 23, 2022

Describe the bug

In some of my quarkusIntTest tests, I am attempting to connect to the Mongo devServices instance to play with test data and cleanup after each test.

These tests work fine in regular @QuarkusTest mode, however it seems that the quarkus.mongodb.connection-string config value never makes it to the test context.

I am attempting to get the value via ConfigProvider.getConfig().getValue("quarkus.mongodb.connection-string", String.class);.

I have confirmed that the mongo service is running in docker at the time, and quarkus.devservices.enabled=true doesn't change anything

Expected behavior

I shold be able to use ConfigProvider.getConfig().getValue("quarkus.mongodb.connection-string", String.class);, and the connection string from the Mongo dev service is present.

Actual behavior

The config value expected from the mongo dev service isn't present in quarkusIntTest test context.

How to Reproduce?

I have a reproducer here:

https://github.com/Epic-Breakfast-Productions/OpenQuarterMaster/tree/main/software/plugins/open-qm-plugin-demo

Simply run the quarkusIntTest task on that project.

You will have to run publishToMavenLocal on this project though, for a library dependency:
https://github.com/Epic-Breakfast-Productions/OpenQuarterMaster/tree/main/software/libs/open-qm-core

Output of uname -a or ver

Linux gen-dev-box 5.13.0-41-generic #46~20.04.1-Ubuntu SMP Wed Apr 20 13:16:21 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk 11.0.15 2022-04-19

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.9.1.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 7.3

Additional information

No response

@GregJohnStewart GregJohnStewart added the kind/bug Something isn't working label May 23, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented May 23, 2022

/cc @stuartwdouglas

@geoand
Copy link
Contributor

geoand commented May 24, 2022

I understand why one would think this could work, but unfortunately it does not because QuarkusIntegrationTest works fundamentally differently than QuarkusTest.

@geoand geoand closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2022
@geoand geoand added the triage/wontfix This will not be worked on label May 24, 2022
@GregJohnStewart
Copy link
Contributor Author

So is there no way to get the config from the running devmode containers? This feels like something that should exist for intTests... again the use case being playing with test data (and at the very least clearing the db between tests).

I guess I will need to swap back to using manually created testcontainers as resources again

@geoand
Copy link
Contributor

geoand commented May 24, 2022

The integration test does not have access to the same information the application under test does. It's meant to interact with it as a black box

@GregJohnStewart
Copy link
Contributor Author

That makes sense, but testing sometimes needs interaction with the data that's stored to setup some specific state; and should definitely be available to reset that state between tests.

I'm not against leaving the service being tested as a black box, but tests should have some access to the databases the service uses.

@stuartwdouglas
Copy link
Member

I don't think it would be unreasonable to set/clear dev services config for each test. We already do this for resource manager properties here: https://github.com/stuartwdouglas/quarkus/blob/12e4c170bd48e61ce0e459f78a48203c0deeaeee/test-framework/junit5/src/main/java/io/quarkus/test/junit/NativeTestExtension.java#L138

We could just do the same thing for de services properties.

@GregJohnStewart
Copy link
Contributor Author

GregJohnStewart commented May 25, 2022

It would be nice, I'm having the darndest time with this...

Trying to setup test resources for the int test is a little different, as you can't tell the running container to just talk to localhost.

Looks like the devservices use a unique hostname for each instance too, further complicating things.

Would be nice to just have the devservices report back to the test code where to access its services

stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue May 25, 2022
This allows integration tests to access dev services config in the same
way you would with a TestResourceManager.

Fixes quarkusio#25730
@quarkus-bot quarkus-bot bot added this to the 2.10 - main milestone May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devservices kind/bug Something isn't working triage/wontfix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants