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
Unify devservices datatabase, username and password and allow configuration #25288
Unify devservices datatabase, username and password and allow configuration #25288
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's indeed a very good idea, thanks.
Only one small gripe: we avoid star imports in Quarkus. Any chance you could remove them?
Also please squash all the commits when done. |
6cdefc9
to
0687d78
Compare
This comment has been minimized.
This comment has been minimized.
0687d78
to
9631bfb
Compare
I force pushed a formatting fix to your branch. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
92194db
to
9ac7195
Compare
DB2 really putted on a fight. Will the light prevail now or is it another round? ¯_(ツ)_/¯ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comments. There is a big mix up between username and password in the patch.
...yment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DatabaseDefaultSetupConfig.java
Outdated
Show resolved
Hide resolved
...adb/src/main/java/io/quarkus/devservices/mariadb/deployment/MariaDBDevServicesProcessor.java
Outdated
Show resolved
Hide resolved
@@ -48,7 +48,7 @@ public void testDatasource() throws Exception { | |||
fail("Datasource should not be null"); | |||
} | |||
assertTrue(configuration.connectionFactoryConfiguration().jdbcUrl().contains("jdbc:postgresql:")); | |||
assertEquals("quarkus", configuration.connectionFactoryConfiguration().principal().getName()); | |||
assertEquals("quarku_1", configuration.connectionFactoryConfiguration().principal().getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you use the constants? BTW, this is a consequence of the mix you made between username and password. This should be the username here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would require adding a dependency.
...yment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DatabaseDefaultSetupConfig.java
Outdated
Show resolved
Hide resolved
...yment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DatabaseDefaultSetupConfig.java
Outdated
Show resolved
Hide resolved
137fb26
to
2d6f47a
Compare
This comment has been minimized.
This comment has been minimized.
2d6f47a
to
9e606d6
Compare
This comment has been minimized.
This comment has been minimized.
Not sure why this test fails. Works here with JDK 11 when I run it via |
Would this be a breaking change, for anyone who had manual connection strings specifying the database in their tests before? |
I would not think so. The whole point of the dev services is that your app does not specify any connection details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some suggestions and questions. Could you have a look?
I want to make sure we don't do any mistakes here.
(I think we're nearly there)
"sa", | ||
"sa", | ||
DEFAULT_DATABASE_USERNAME, | ||
DEFAULT_DATABASE_PASSWORD, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checking but we have the full permissions when doing that and not using sa
? I thought it had a special meaning? Given I don't see us defining permissions for the quarkus
user, I'm wondering how this works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, if the database specified in the embedded URL does not yet exist, a new (empty) database is created automatically. The user that created the database automatically becomes the administrator of this database.
From H2 docu https://h2database.com/html/tutorial.html#creating_new_databases
sa
is the abriviation for System Administrator
, but seems to have no special permissions. It is just some default IMHO.
...s/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java
Outdated
Show resolved
Hide resolved
public static final String DEFAULT_DATABASE_USERNAME = "quarkus"; | ||
|
||
// mssql container enforces a 'strong' password with min 8 chars, upper/lowercase, number or special char | ||
public static final String DEFAULT_DATABASE_PASSWORD = "quarkus1!"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would rather use quarkus
for the password and have a STRONG_DEFAULT_DATABASE_PASSWORD
for databases that requires it so only MSSQL for now.
Rationale is that in some cases you want to connect to the database while dev mode is running. And it's better to have a simple password if we can.
9e606d6
to
ec77b00
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This PR needs a rebase since the |
I'm working on this as I want to make other changes in this area and thought it would be better to build on this one. |
24b78ff
to
aee2dd8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a few adjustments for the doc and also added a commit to be able to easily override database names, usernames and passwords.
It's not obvious from the GitHub UI but authorship of the first commit has been preserved: Author: newur <newur@mailbox.org>
. My guess is that there's a mismatch between email used in commit and emails declared on GitHub.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI failures seem related, probably because it needs to use the DEFAULT_DATABASE_STRONG_PASSWORD
.
BTW I think the DEFAULT_DATABASE_STRONG_PASSWORD
should be used in all databases instead of having just for MSSQL
...s/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java
Outdated
Show resolved
Hide resolved
...s/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI failures seem related, probably because it needs to use the DEFAULT_DATABASE_STRONG_PASSWORD
.
BTW I think the DEFAULT_DATABASE_STRONG_PASSWORD
should be used in all databases instead of having just for MSSQL
How about changing the password as something easier to remember? Like |
I changed the password to As for using the strong password everywhere, I don't think it's worth making things complicated for the small number of SQL Server users compared to the users of all the other databases. |
Not all database containers support everything but it's implemented for all everything that is supported.
aee2dd8
to
c7b90ee
Compare
I merged it, it's a step in the right direction. Thanks @newur for starting this work! |
I wanted to inspect the Postgres database started by devservices. While searching for the login credentials I noticed that different databases use different credentials and db names. I think it is nicer to use the same for all. Bonus, at least for Postgres the login via
psql
becomes shorter when the username and db name are equalpsql -h localhost -p <randomPort> -U quarkus
instead of
psql -h localhost -p <randomPort> -U quarkus -d default
I did not find the information how to connect to the devservices datasources in the docu. Would be worth to add it IMO. Any hints where I should put it?