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

Being able to fix the Postgres listening port property with DevServices #16768

Closed
agoncal opened this issue Apr 23, 2021 · 6 comments · Fixed by #17012
Closed

Being able to fix the Postgres listening port property with DevServices #16768

agoncal opened this issue Apr 23, 2021 · 6 comments · Fixed by #17012
Labels
kind/enhancement New feature or request
Milestone

Comments

@agoncal
Copy link
Contributor

agoncal commented Apr 23, 2021

Description

When you use DevServices in Dev and Test mode to startup a Postgres database, the listening port is random and you get a different one each time you startup or execute the tests (eg. localhost:55046/default, localhost:55048/default, etc.). But in development mode, it's sometimes useful to access the database. And to get the port, you need to check the Dev UI to know this random port.

Having a random port in test, is fine, but in dev it would be nice to have to fix the port number (using a property).

@agoncal agoncal added the kind/enhancement New feature or request label Apr 23, 2021
@maxandersen
Copy link
Member

Not sure what the good way would be here.

With contionous testing you wouldn’t want random ports as otherwise there would be conflicts.

So it would only be the first one that would be “fixed”.

@agoncal
Copy link
Contributor Author

agoncal commented Apr 26, 2021

I'm more interested in having a fix port in %dev. Like all the devservices property, it won't be available in production, and then you could have either %dev%.quarkus.datasource.devservices.port=5432 only for dev, but if you have the property for %test, then, as you say, only the first one would be fixed.

@gsmet
Copy link
Member

gsmet commented Apr 27, 2021

@stuartwdouglas I don't know if you have seen this one but I think it makes a lot of sense? If you agree it does, I can work on it.

@stuartwdouglas
Copy link
Member

Because we are using testcontainers this is not as simple as it sounds, even though it makes sense, as testcontainers always picks a random port. I think the best you could do is open a socket on the 'fixed' port, and just use it to manually port forward to the underlying instance.

We may end up needing to do our own stuff rather than continuing to use testcontainers, another use case I have that they don't support is persistent containers, where you create a container with a specific name (based on the project and datasource), leave it running and just re-connect to it if it is already started.

@stuartwdouglas
Copy link
Member

Looks like you probably could do it if you override the configure() method in PostgreSQLContainer and add a call to addFixedExposedPort.

gsmet added a commit to gsmet/quarkus that referenced this issue May 5, 2021
gsmet added a commit to gsmet/quarkus that referenced this issue May 5, 2021
gsmet added a commit to gsmet/quarkus that referenced this issue May 6, 2021
gsmet added a commit to gsmet/quarkus that referenced this issue May 7, 2021
@quarkus-bot quarkus-bot bot added this to the 2.0 - main milestone May 10, 2021
@gsmet gsmet modified the milestones: 2.0 - main, 1.13.4.Final May 10, 2021
gsmet added a commit to gsmet/quarkus that referenced this issue May 10, 2021
gsmet added a commit to gsmet/quarkus that referenced this issue May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants