-
Notifications
You must be signed in to change notification settings - Fork 3k
Use dev services instead of docker-maven-plugin for Postgresql #51066
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
Open
holly-cummins
wants to merge
1
commit into
quarkusio:main
Choose a base branch
from
holly-cummins:convert-postgresql-tests-to-devservices
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+118
−447
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
integration-tests/jpa-postgresql-withxml/src/main/resources/application.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,10 +13,6 @@ | |
| <name>Quarkus - Integration Tests - JPA - PostgreSQL</name> | ||
| <description>Module that contains JPA related tests running with the PostgreSQL database</description> | ||
|
|
||
| <properties> | ||
| <postgres.url>jdbc:postgresql://localhost:5431/hibernate_orm_test</postgres.url> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>io.quarkus</groupId> | ||
|
|
@@ -46,6 +42,28 @@ | |
| <artifactId>quarkus-junit5-internal</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <!-- <dependency>--> | ||
| <!-- <groupId>org.junit.platform</groupId>--> | ||
| <!-- <artifactId>junit-platform-suite</artifactId>--> | ||
| <!-- <scope>test</scope>--> | ||
| <!-- </dependency>--> | ||
|
Comment on lines
+45
to
+49
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be removed? Or maybe we need a comment to explain why it's here and commented out? |
||
| <dependency> | ||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>postgresql</artifactId> | ||
| <exclusions> | ||
| <exclusion> | ||
| <groupId>junit</groupId> | ||
| <artifactId>junit</artifactId> | ||
| </exclusion> | ||
| </exclusions> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <!-- Until we have testcontainers 2, which has https://github.com/testcontainers/testcontainers-java/issues/970, add back JUnit 4 so testcontainers doesn't break everything :( --> | ||
| <dependency> | ||
| <groupId>junit</groupId> | ||
| <artifactId>junit</artifactId> | ||
| <version>${junit4.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.rest-assured</groupId> | ||
| <artifactId>rest-assured</artifactId> | ||
|
|
@@ -171,86 +189,6 @@ | |
| </plugins> | ||
| </build> | ||
| </profile> | ||
|
|
||
| <profile> | ||
| <id>docker-postgresql</id> | ||
| <activation> | ||
| <property> | ||
| <name>start-containers</name> | ||
| </property> | ||
| </activation> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>io.fabric8</groupId> | ||
| <artifactId>docker-maven-plugin</artifactId> | ||
| <configuration> | ||
| <images> | ||
| <image> | ||
| <name>${postgres.image}</name> | ||
| <alias>postgresql</alias> | ||
| <run> | ||
| <env> | ||
| <POSTGRES_USER>hibernate_orm_test</POSTGRES_USER> | ||
| <POSTGRES_PASSWORD>hibernate_orm_test</POSTGRES_PASSWORD> | ||
| <POSTGRES_DB>hibernate_orm_test</POSTGRES_DB> | ||
| </env> | ||
| <ports> | ||
| <port>5431:5432</port> | ||
| </ports> | ||
| <wait> | ||
| <!-- For some reason, Postgres will tell us it's ready *twice*, | ||
| and that's the truth the second time only. | ||
| See https://github.com/fabric8io/docker-maven-plugin/issues/628 | ||
| See also how the condition is configured in testcontainers: | ||
| https://github.com/testcontainers/testcontainers-java/blob/c64aab9fd5e3a452ee0faf793560327eb4da9841/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java#L52-L55 --> | ||
| <time>20000</time> | ||
| <log>(?s)ready to accept connections.*ready to accept connections</log> | ||
| </wait> | ||
| </run> | ||
| </image> | ||
| </images> | ||
| <!--Stops all postgres images currently running, not just those we just started. | ||
| Useful to stop processes still running from a previously failed integration test run --> | ||
| <allContainers>true</allContainers> | ||
| </configuration> | ||
| <executions> | ||
| <execution> | ||
| <id>docker-start</id> | ||
| <phase>compile</phase> | ||
| <goals> | ||
| <goal>stop</goal> | ||
| <goal>start</goal> | ||
| </goals> | ||
| </execution> | ||
| <execution> | ||
| <id>docker-stop</id> | ||
| <phase>post-integration-test</phase> | ||
| <goals> | ||
| <goal>stop</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.codehaus.mojo</groupId> | ||
| <artifactId>exec-maven-plugin</artifactId> | ||
| <executions> | ||
| <execution> | ||
| <id>docker-prune</id> | ||
| <phase>generate-resources</phase> | ||
| <goals> | ||
| <goal>exec</goal> | ||
| </goals> | ||
| <configuration> | ||
| <executable>${docker-prune.location}</executable> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </profile> | ||
| </profiles> | ||
|
|
||
|
|
||
|
|
||
3 changes: 0 additions & 3 deletions
3
integration-tests/jpa-postgresql/src/main/resources/application.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...n-tests/jpa-postgresql/src/test/java/io/quarkus/it/jpa/postgresql/ConfigOverrideTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package io.quarkus.it.jpa.postgresql; | ||
|
|
||
| import static org.hamcrest.Matchers.is; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import io.quarkus.test.junit.QuarkusTest; | ||
| import io.quarkus.test.junit.QuarkusTestProfile; | ||
| import io.quarkus.test.junit.TestProfile; | ||
| import io.restassured.RestAssured; | ||
|
|
||
| /* Exercises OverrideJdbcUrlBuildTimeConfigSource, which cannot coexist with dev services. */ | ||
| @TestProfile(ConfigOverrideTest.Profile.class) | ||
| @QuarkusTest | ||
| public class ConfigOverrideTest { | ||
|
|
||
| @Test | ||
| public void base() { | ||
| RestAssured.when().get("/jpa/testfunctionality/base").then().body(is("OK")); | ||
| } | ||
|
|
||
| public static class Profile implements QuarkusTestProfile { | ||
| @Override | ||
| public Map<String, String> getConfigOverrides() { | ||
| // Disable dev services so we know we're connecting to the right database | ||
| return Map.of("quarkus.devservices.enabled", "false"); | ||
| } | ||
|
|
||
| @Override | ||
| public String getConfigProfile() { | ||
| return "someotherprofile"; | ||
| } | ||
|
|
||
| @Override | ||
| public List<TestResourceEntry> testResources() { | ||
| return Collections.singletonList(new TestResourceEntry(PostgresTestResourceLifecycleManager.class)); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...esql/src/test/java/io/quarkus/it/jpa/postgresql/PostgresTestResourceLifecycleManager.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package io.quarkus.it.jpa.postgresql; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import org.testcontainers.containers.PostgreSQLContainer; | ||
|
|
||
| import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; | ||
|
|
||
| public class PostgresTestResourceLifecycleManager implements QuarkusTestResourceLifecycleManager { | ||
|
|
||
| private static PostgreSQLContainer<?> postgres; | ||
|
|
||
| @SuppressWarnings("resource") | ||
| @Override | ||
| public Map<String, String> start() { | ||
| postgres = new PostgreSQLContainer<>("postgres:14") // the exact value doesn't really matter here | ||
| .withDatabaseName("testdb") | ||
| .withUsername("test") | ||
| .withPassword("test"); | ||
|
|
||
| postgres.start(); | ||
|
|
||
| return Map.of("quarkus.datasource.jdbc.url", postgres.getJdbcUrl(), "quarkus.datasource.username", "test", | ||
| "quarkus.datasource.password", "test"); | ||
| } | ||
|
|
||
| @Override | ||
| public void stop() { | ||
|
|
||
| if (postgres != null) { | ||
| postgres.stop(); | ||
| } | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 missed this in your other PRs... but I think it's incorrect?
postgres.urlis no longer mentioned in the configuration of this integration test, so I don't think setting it will do anything.In order for this to be true, I think you'd need to keep the line
quarkus.datasource.jdbc.url=${postgres.url}inapplication.properties. And set the default value ofpostgres.urlto an empty string inpom.xml, so that by default the configuration will look likequarkus.datasource.jdbc.url=(no value), which means dev services will kick in.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.
That, or we remove this part of the README and expect people to always use dev services to run these tests. Which is perfectly fine IMO, but others might disagree -- @gsmet maybe?