question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

db-kind cannot be overridden from QuarkusTestResourceLifecycle manager

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lordofthejarscommented, Jan 18, 2021

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 😃

0reactions
geoandcommented, Jan 18, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found