forked from fabric8io/docker-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(compose): add integration test for depends_on in compose fabric8…
1 parent
dfcfb87
commit 328737b
Showing
4 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,3 @@ | ||
FROM postgres:13-alpine | ||
HEALTHCHECK --interval=5s --timeout=5s --retries=5 \ | ||
CMD "pg_isready" "-U" "postgres" |
This file contains 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,27 @@ | ||
version: "2.4" | ||
services: | ||
init: | ||
image: alpine:latest | ||
command: | ||
- echo | ||
- "Hello world!" | ||
db: | ||
image: localpg | ||
build: | ||
context: . | ||
dockerfile: Postgres.Dockerfile | ||
environment: | ||
POSTGRES_PASSWORD: supersecret | ||
tmpfs: | ||
- /var/lib/postgresql/data | ||
depends_on: | ||
init: | ||
condition: service_completed_successfully | ||
web: | ||
image: alpine:latest | ||
command: | ||
- echo | ||
- "Hello foobar (after hello world)!" | ||
depends_on: | ||
db: | ||
condition: service_healthy |
This file contains 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,77 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<!-- | ||
Integration test demo with wait configurations mapped from Docker compose depends_on long syntax | ||
Call it with: 'mvn verify' | ||
The test does the following: | ||
* Builds a custom postgres image with a healtcheck (because we do not support adding healthchecks from compose yet) | ||
* Start an init container printing a message | ||
* When successfully exited, database container starts | ||
* Once Postgres enters state healthy, another simple container printing a message is started | ||
* Stops and removes the containers. | ||
--> | ||
|
||
<parent> | ||
<groupId>io.fabric8.dmp.itests</groupId> | ||
<artifactId>dmp-it-parent</artifactId> | ||
<version>0.44-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>dmp-it-docker-compose-dependon</artifactId> | ||
<version>0.44-SNAPSHOT</version> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>docker-maven-plugin</artifactId> | ||
<configuration> | ||
<images> | ||
<image> | ||
<alias>web</alias> | ||
<name>alpine:latest</name> | ||
<external> | ||
<type>compose</type> | ||
<basedir>${project.basedir}</basedir> | ||
</external> | ||
</image> | ||
</images> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>build</id> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
<phase>verify</phase> | ||
</execution> | ||
<execution> | ||
<id>start</id> | ||
<goals> | ||
<goal>start</goal> | ||
</goals> | ||
<phase>verify</phase> | ||
<configuration> | ||
<showLogs>true</showLogs> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>stop</id> | ||
<goals> | ||
<goal>stop</goal> | ||
</goals> | ||
<phase>verify</phase> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
This file contains 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