quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.73k stars 2.67k forks source link

Quarkus 2.0 mongodb with devServices option #18830

Closed Srinivasa-Cana closed 3 years ago

Srinivasa-Cana commented 3 years ago

Description

I have quarkus2.0 application running with mongodb database.

To run my tests, I am depending on devServices option if I am not configuring quarkus.mongodb.connection-string for test profile Quarkus will start mongod docker container for tests.

Issue I have how to pass mongodb connection string options (ex: uuidRepresentation=standard). I am using uuidRepresentation=standard option for application.

Connection-String format as per below:

mongodb://username:password@localhost:27017/dbname?authSource=admin&uuidRepresentation=standard

Note : Without above functionality using mongodb 4.0 driver with quarkus 2.0 un-useful. Because default driver comes with UuidRepresentation.UNSPECIFIED value. Pls consider as high priority for this request.

Open this request based on comment on stackover flow comment.

Issue Comment on StackOver Flow

Implementation ideas

you can provide Connection-String options as separate configuration parameter.

Provide Connection-String-Options or Connection-String-Override-Options as another configuration parameter.

Or

should able to configure Connection-String as per below

Connection-String=mongodb://?authSource=admin&uuidRepresentation=standard

Note: with out host, port and user name and password. so that devServices it will start new mongodb container and create actual url before setting MongoClientSettings.

As per mongodb documentation Host name is mandatory. So I will prefer my first option.

quarkus-bot[bot] commented 3 years ago

/cc @evanchooly, @loicmathieu, @stuartwdouglas

evanchooly commented 3 years ago

honestly, the connection string used by dev services should include that by default. I've yet to run across anyone not using the standard UUID representation. Fixing that is a simpler fix as dev services assumes no user defined connection string, iirc.

Srinivasa-Cana commented 3 years ago

Configure default works for me (Since it is new DB).

if any user using it old mongodb server which is having JAVA_LEGACY implementation in their DB? How we are going to support that. May be very less people right now for this option :).

And also how do we configure other OPTIONS like authSource=admin etc...

gsmet commented 3 years ago

I think we should add propertiessimilar to what we have in the datasource support here: https://github.com/quarkusio/quarkus/blob/main/extensions/datasource/runtime/src/main/java/io/quarkus/datasource/runtime/DevServicesBuildTimeConfig.java#L35

geoand commented 3 years ago

I agree with @gsmet, we should be consistent with this. I'll open a PR soon