Describe the bug
Tests use only the DataSource configured in main resources instead of the one in test resources.
Expected behavior
The in-memory DataSource configured in the test resources is used like in 1.4.0.CR1 and before.
Actual behavior
The in-memory test resource H2 database is started but agroal is configured to use main resources PostgreSQL DataSource.
To Reproduce
Steps to reproduce the behavior:
Configuration
Main application.properties:
# Add your application.properties here, if applicable.
quarkus.datasource.db-kind = postgresql
quarkus.datasource.jdbc.url = jdbc:postgresql://localhost:2345/test-db
quarkus.datasource.username = postgres
quarkus.datasource.password = secret
Test application.properties:
# Add your application.properties here, if applicable.
quarkus.datasource.url = jdbc:h2:tcp://localhost/mem:test-db;MODE=PostgreSQL
quarkus.datasource.driver = org.h2.Driver
Screenshots
(If applicable, add screenshots to help explain your problem.)
Environment (please complete the following information):
uname -a or ver: Linux voyager 5.6.7-arch1-1 #1 SMP PREEMPT Thu, 23 Apr 2020 09:13:56 +0000 x86_64 GNU/Linuxjava -version: openjdk version "11.0.6" 2020-01-14mvnw --version or gradlew --version): Gradle 6.3TBH, I don't think we ever consciously supported using
src/test/resources/application.properties.
I am pretty sure that what you are seeing is a result of https://github.com/quarkusio/quarkus/pull/8284 (which made things a lot more sensible).
You should be able to use differentiate the test properties by using %test.as a prefix in
src/main/resources/application.properties
(as explained here)
cc @gsmet @aloubyansky
We used to support it and we got several complaints of it not working so I would be in favor of having it working again.
See https://github.com/quarkusio/quarkus/issues/8845 for another report.
@geoand this is not so clear when following the data source guide [1] where the prefix is not mentioned.
Also I prefer to separate test related configuration from the main configuration where I use different profiles for different flavors of the application. So I'd vote to introduce this again as supported feature.
/edit: I also noticed that for using '%test.' properties, I need to add h2 driver to main dependencies (implementation or runtimeOnly) resulting in test related classes showing up in the final runner jar file.
[1] https://quarkus.io/guides/datasource#in-memory-databases
Is this a regression in 1.4.1? Do you guys want me to look into it?
I guess it is a regression, although from my POV I don't think we ever advertised this way of doing things - but I might just have missed it.
@geoand I'm quiet sure someone advertised it.. ;)
https://stackoverflow.com/questions/55063778/how-can-use-an-in-memory-h2-database-when-testing-my-quarkus-application
That's what I get for answering questions on SO... :facepalm: :facepalm: :facepalm:
Better keep my mouth shut next time :laughing:
FWIW, I'd just like to throw in a big fat +1 for @pschyma's statement:
Also I prefer to separate test related configuration from the main configuration where I use different profiles for different flavors of the application.
This is a Gradle-only issue, AFAICT.
I think it's the same issue as #8845
Most helpful comment
We used to support it and we got several complaints of it not working so I would be in favor of having it working again.