Repository navigation
Adding database suppliers - #31073
Conversation
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.federation.ldap.LDAPReadOnlyTest#testReadOnlyUserGetsPermanentlyLocked |
There was a problem hiding this comment.
I think it can be left like this because the dbconfig() returns the default value (DefaultDatabaseConfig.class) if it is not entered.
| DatabaseConfig databaseConfig = annotation.dbconfig() != null ? SupplierHelpers.getInstance(annotation.dbconfig()) : new DefaultDatabaseConfig(); | |
| DatabaseConfig databaseConfig = SupplierHelpers.getInstance(annotation.dbconfig()); |
9ca00b2 to
93f632e
Compare
There was a problem hiding this comment.
What I had in mind is close to this, but not quite.
My idea was that we would have multiple database suppliers:
- PostgresDatabaseSupplier
- MySQLDatabaseSupplier
- DevFileDatabaseSupplier
- DevMemDatabaseSupplier
Each supplier would supply a TestDatabase with start/stop methods, and a getConfig() method.
You'd select which DB supplier to use with #30609 in the same way as we would select a different server run-mode or browser.
TestDatabase would be responsible for starting/stopping the DB container using test containers.
For now it's fine that DBs are not configurable (we just let it auto configure itself to some sensible defaults), and that we don't support connecting to external DBs, we can do that as a follow-up.
18f01af to
cf6eae4
Compare
20c5a3f to
a7f61f5
Compare
db709fe to
9869df8
Compare
There was a problem hiding this comment.
What's the purpose of this class?
There was a problem hiding this comment.
This should not create the database supplier, but it should just use the registry to look it up:
TestDatabase database = registry.getDependency(TestDatabase.class, wrapper);
See
as an example on how to get a dependency in a supplier.There was a problem hiding this comment.
Rather then getting supplier I am thinking of fully manged DB called within the KeycloakIntegrationTest annotation as a prerequisite, do you think @stianst it makes sense?
There was a problem hiding this comment.
Don't you want to introduce rather DefaultDatabaseConfig class?
There was a problem hiding this comment.
Did you consider some TestManagedDatabase annotation which will be reused within KeycloakIntegrationTest annotation for ServiceLoader injection?
There was a problem hiding this comment.
There was a problem hiding this comment.
Maybe it would be cleaner to just pass the DatabaseConfig? Makes it clear that it shouldn't be stopping/starting the db or anything like that ;)
There was a problem hiding this comment.
Since the annotation introduction this could be then omitted and used like this: https://github.com/keycloak/keycloak/blob/main/test-poc/framework/src/main/java/org/keycloak/test/framework/KeycloakIntegrationTest.java#L15
173da6f to
053a1a2
Compare
There was a problem hiding this comment.
Do we want to provide default implementations here? Or would all database providers have to implement this? Perhaps we can provide something else than an empty string such as null or Optional.empty()?
There was a problem hiding this comment.
Both vendor and containerImage are not used anywhere, perhaps remove these until we need them to support a functionality?
| default String vendor() { | |
| return ""; | |
| } | |
| default String containerImage() { | |
| return ""; | |
| } |
There was a problem hiding this comment.
This method is never used anywhere.
| public TestDatabase getTestDatabase() { | |
| return testDatabase; | |
| } |
There was a problem hiding this comment.
None of these methods currently do anything? Is there a place where we actually need to start a database and tear it down? Also it seems that stop() is never called.
Signed-off-by: Miquel Simon <msimonma@redhat.com>
* Closes keycloak#30616. Added database suppliers. Signed-off-by: Miquel Simon <msimonma@redhat.com> Co-authored-by: stianst <stianst@gmail.com>
Closes #30616