db-kind cannot be overridden from QuarkusTestResourceLifecycle manager
See original GitHub issueDescribe the bug
I’ve got the following configuration at application.properties
file:
%test.quarkus.datasource.db-kind=h2
%test.quarkus.datasource.username=sa
%test.quarkus.datasource.password=
%test.quarkus.datasource.jdbc.url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
%test.quarkus.hibernate-orm.database.generation=update
Then I created the following QuarkusTestResourceLifecycle manager:
public class MariaDBResource implements QuarkusTestResourceLifecycleManager {
static MariaDBContainer<?> db = new MariaDBContainer<>("mariadb:10.3.6")
.withDatabaseName("mydb")
.withUsername("developer")
.withPassword("developer");
@Override
public Map<String, String> start() {
db.start();
final Map<String, String> conf = new HashMap<>();
conf.put("%test.quarkus.datasource.jdbc.url", db.getJdbcUrl());
conf.put("%test.quarkus.datasource.username", "developer");
conf.put("%test.quarkus.datasource.password", "developer");
conf.put("%test.quarkus.datasource.db-kind", "mariadb");
return conf;
}
@Override
public void stop() {
db.stop();
}
}
Notice that by default test profile is configured to use H2 but then I override the configuration.
Expected behavior
MariaDB configuration us used.
Actual behavior
Some of the properties are overridden but not db-kind
.
I notice that because of the following log line:
WARN: Datasource '<default>': Driver does not support the provided URL: jdbc:mariadb://localhost:32785/mydb
Jan 18, 2021 3:21:28 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
Notice that the URL is correct but it says that the driver do not support the schema as it is taking the H2.
If then I go to application.properties
and I change manually the db-kind
to mariadb
then everything works as expected.
Environment (please complete the following information):
Quarkus 1.10.5
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, the workaround is Maven profiles and Quarkus profiles, I completely agree and I understand that if this has been there for several optimizations then it is not going to change 😃
You could also use different Maven profiles to do your testing.
Although I understand this is a limiation, it is something we’ve done from day 1 and something which enables various other optimizations.
cc @gsmet