-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix dev service ephemeral ports: Make test resource config override dev service config and system props #48815
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 dev service ephemeral ports: Make test resource config override dev service config and system props #48815
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
6197eea to
7971356
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
7971356 to
b0ee374
Compare
This comment has been minimized.
This comment has been minimized.
|
🎊 PR Preview 34e5e88 has been successfully built and deployed to https://quarkus-pr-main-48815-preview.surge.sh/version/main/guides/
|
b0ee374 to
2fc2b7a
Compare
This comment has been minimized.
This comment has been minimized.
2fc2b7a to
5dbdfae
Compare
This comment has been minimized.
This comment has been minimized.
5dbdfae to
f349dd1
Compare
This comment has been minimized.
This comment has been minimized.
f349dd1 to
c409e7d
Compare
This comment has been minimized.
This comment has been minimized.
c409e7d to
4fe21dd
Compare
This comment has been minimized.
This comment has been minimized.
4fe21dd to
c39886d
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
You can do this by using a Internally, Since the DevServices configuration is already resolved before the runtime Config, the DevServices config could be used in a factory to selectively set the desired values. If required, a factory can provide multiple sources with different ordinals. All the resolved sources are ordered with the main ones to assemble the final list, but having the ability to query the current config and set what you need should be enough, and you shouldn't require creating different sources with different ordinals. |
|
Is there an eta? :( We are blocked to update to the new quarkus lts cause we use random test-ports. |
|
@holly-cummins do you want me to write my alternate proposal? |
|
Hi, are there any updates? |
|
@holly-cummins @radcortez Is there an update pls? |
|
I'm working on #51209, which would create the foundations to fix this, but it may still take a while... sorry for the inconvenience, and thank you for your patience. |
|
Should we consider merging the fix in this PR while we wait for the longer term solution, @radcortez? |
|
#51209 must go in a new minor, hopefully in 3.31, but most likely we are skipping the December release and doing it only in January: https://github.com/quarkusio/quarkus/wiki/Release-Planning So, if this cannot wait until then, I'm in favor of merging this. I already have a prototype using #51209 to fix this, which conceptually is not very different from what you have done here (but without relying directly on Config), but I'm still exploring other options. Since we need to rebase this, I would ask to add a couple of Do you want me to do the rebase? |
Yes please, thank you! +1 on the deprecated annotations, seems reasonable. |
Also switch to runtime config
c39886d to
296c455
Compare
|
Ok, rebased and added the |
Status for workflow
|
This comment has been minimized.
This comment has been minimized.
|
@holly-cummins, please check if this is ok. |
Yes it looks good! |
|
Rerunning the job with test failures. The failures seem unrelated. |
Status for workflow
|
|
Could this be ported to 3.27 lts please? |

After the big test classloading rewrite, ephemeral ports for the lambda dev service stopped working (that is, if a user sets the port as 0 in
application.properties, in hopes that they get a randomly assigned one, injected clients will attempt to connect to a port "0"). This issue would also affect other services where a user explicitly configured a port of 0. To fix that, the dev service needs to be moved to the new model, but that's not enough. The lazy config source that knows the random port needs to have a higher priority than the '0' hardcoded in the application properties.Fixing this is (almost) a straightforward matter of bumping the priority (ordinal) to something 400 or higher. Sadly that simple fix creates a ripple of other problems:
MultiClientImportPreloadingTestin theredis-clienttest suite uses a TestResource to start and stop a redis instance, but the test doesn't disable dev services, so there are actually two redis instances. (I've checked, and this is the case even on 3.21.) For some of the test to pass, they needs to connect to the test resource one, not the dev service one, and for that to work, the dev services config needs to be lower priority than application properties. Arguably, this is a slightly silly test for starting things twice, but I don't want to regress behaviour that currently works.KakfaCompanionResourcetest resource used by theintegration-tests/reactive-messaging-hibernate-ormandintegration-tests/opentelemetry-reactive-messagingtests interacts with the dev services, and for it to work, test resources need to have a higher priority than dev servicesextensions/resteasy-classic/resteasy-clientuses aQuarkusUnitTest.overrideConfigKeyto configure the port to 0.QuarkusUnitTest.overrideConfigKeyuses the sameRuntimeOverrideConfigSourceconfig source as test resources do. For this test to pass, unit test sources need to have a lower priority than dev service sources.So we have the following desired behaviours:
QuarkusUnitTest().overrideConfigKeyshould have a lower priority than dynamic dev services config-Dservice.port=0wouldn't work).As a hierarchy of priorities, that would be (from highest to lowest):
So I see two options. One is to split the
RuntimeOverrideConfigSourceinto two so it can have two priorities for the two different scenarios, and the other is to split the dev service source into an 'underride' and 'override' pair. I worried that I might keep finding scenarios where the test resource config wasn't quite at the right relative priority, whereas the "this should override" vs "this should not override" distinction for dev services seemed clearer. So I went that way.It should be really clean to just say 'only have this as an override if the same property is found in the original, user-defined, config' but getting that list wasn't so easy, and passing in the hardcoded config just made the API really confusing. I wondered about using
ConfigUtils.isPropertyNonEmpty(propName)but that would be introducing the same problem of fighting with test resource overrides, but with some extra sequencing fun.As part of this, I also had to make the port a runtime config element. Otherwise, CI was green, but there was a warning in the logs.