Skip to content

Commit

Permalink
Merge pull request #8553 from baude/composeci
Browse files Browse the repository at this point in the history
add compose regression to ci
  • Loading branch information
openshift-merge-robot authored Dec 12, 2020
2 parents 36bec38 + cb91bf9 commit a226e6e
Show file tree
Hide file tree
Showing 33 changed files with 603 additions and 1 deletion.
18 changes: 17 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ env:
PRIOR_UBUNTU_NAME: "ubuntu-19"

# Google-cloud VM Images
IMAGE_SUFFIX: "c5402398833246208"
IMAGE_SUFFIX: "c4704091098054656"
FEDORA_CACHE_IMAGE_NAME: "fedora-${IMAGE_SUFFIX}"
PRIOR_FEDORA_CACHE_IMAGE_NAME: "prior-fedora-${IMAGE_SUFFIX}"
UBUNTU_CACHE_IMAGE_NAME: "ubuntu-${IMAGE_SUFFIX}"
Expand Down Expand Up @@ -434,6 +434,21 @@ apiv2_test_task:
podman_system_info_script: '$SCRIPT_BASE/logcollector.sh podman'
time_script: '$SCRIPT_BASE/logcollector.sh time'

compose_test_task:
name: "compose test on $DISTRO_NV"
alias: compose_test
depends_on:
- validate
gce_instance: *standardvm
env:
<<: *stdenvars
TEST_FLAVOR: compose
clone_script: *noop # Comes from cache
gopath_cache: *ro_gopath_cache
setup_script: *setup
main_script: *main
always: *logs_artifacts


# Execute the podman integration tests on all primary platforms and release
# versions, as root, without involving the podman-remote client.
Expand Down Expand Up @@ -619,6 +634,7 @@ success_task:
- docker-py_test
- unit_test
- apiv2_test
- compose_test
- local_integration_test
- remote_integration_test
- rootless_integration_test
Expand Down
4 changes: 4 additions & 0 deletions contrib/cirrus/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ function _run_apiv2() {
make localapiv2 |& logformatter
}

function _run_compose() {
./test/compose/test-compose |& logformatter
}

function _run_int() {
dotest integration
}
Expand Down
1 change: 1 addition & 0 deletions contrib/cirrus/setup_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ case "$TEST_FLAVOR" in
build) make clean ;;
unit) ;;
apiv2) ;& # use next item
compose) ;&
int) ;&
sys) ;&
bindings) ;&
Expand Down
47 changes: 47 additions & 0 deletions test/compose/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Tests for docker-compose
========================

This directory contains tests for docker-compose under podman.

Each subdirectory must contain one docker-compose.yml file along with
all necessary infrastructure for it (e.g. Containerfile, any files
to be copied into the container, and so on.

The `test-compose` script will, for each test subdirectory:

* set up a fresh podman root under an empty working directory;
* run a podman server rooted therein;
* cd to the test subdirectory, and run `docker-compose up -d`;
* source `tests.sh`;
* run `docker-compose down`.

As a special case, `setup.sh` and `teardown.sh` in the test directory
will contain commands to be executed prior to `docker-compose up` and
after `docker-compose down` respectively.

tests.sh will probably contain commands of the form

test_port 12345 = 'hello there'

Where 12345 is the port to curl to; '=' checks equality, '~' uses `expr`
to check substrings; and 'hello there' is a string to look for in
the curl results.

Usage:

$ sudo test/compose/test-compose [pattern]

By default, all subdirs will be run. If given a pattern, only those
subdirectories matching 'pattern' will be run.

If `$COMPOSE_WAIT` is set, `test-compose` will pause before running
`docker-compose down`. This can be helpful for you to debug failing tests:

$ env COMPOSE_WAIT=1 sudo --preserve-env=COMPOSE_WAIT test/compose/test-compose

Then, in another window,

# ls -lt /var/tmp/
# X=/var/tmp/test-compose.tmp.XXXXXX <--- most recent results of above
# podman --root $X/root --runroot $X/runroot ps -a
# podman --root $X/root --runroot $X/runroot logs -l
12 changes: 12 additions & 0 deletions test/compose/env_and_volume/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
environment variable and volume
===============

This test creates two containers both of which are running flask. The first container has
an environment variable called PODMAN_MSG. That container pipes the contents of PODMAN_MSG
to a file on a shared volume between the containers. The second container then reads the
file are returns the PODMAN_MSG value via flask (http).

Validation
------------
* curl http://localhost:5000 and verify message
* curl http://localhost:5001 and verify message
18 changes: 18 additions & 0 deletions test/compose/env_and_volume/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3'
services:
writer:
environment:
- PODMAN_MSG=podman_rulez
build: write
ports:
- '5000:5000'
volumes:
- data:/data
reader:
build: read
ports:
- '5001:5000'
volumes:
- data:/data
volumes:
data:
5 changes: 5 additions & 0 deletions test/compose/env_and_volume/read/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM quay.io/libpod/podman_python
WORKDIR /app
COPY . /app
ENTRYPOINT ["python3"]
CMD ["app.py"]
10 changes: 10 additions & 0 deletions test/compose/env_and_volume/read/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello():
f = open("/data/message", "r")
return f.read()

if __name__ == '__main__':
app.run(host='0.0.0.0')
4 changes: 4 additions & 0 deletions test/compose/env_and_volume/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- bash -*-

test_port 5000 = "done"
test_port 5001 = "podman_rulez"
5 changes: 5 additions & 0 deletions test/compose/env_and_volume/write/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM quay.io/libpod/podman_python
WORKDIR /app
COPY . /app
ENTRYPOINT ["python3"]
CMD ["app.py"]
13 changes: 13 additions & 0 deletions test/compose/env_and_volume/write/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from flask import Flask
import os
app = Flask(__name__)

@app.route('/')
def hello():
f = open("/data/message", "w")
f.write(os.getenv("PODMAN_MSG"))
f.close()
return "done"

if __name__ == '__main__':
app.run(host='0.0.0.0')
5 changes: 5 additions & 0 deletions test/compose/images/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
images
======

Use these directories for images that are needed for the compose testing. These
images should be then pushed to `quay.io/libpod` for consumption.
3 changes: 3 additions & 0 deletions test/compose/images/podman-python/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM alpine
WORKDIR /app
RUN apk update && apk add py3-pip && pip3 install flask && rm -fr /var/cache/apk/*
9 changes: 9 additions & 0 deletions test/compose/mount_and_label/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
mount and label
===============

This test creates a container with a mount (not volume) and also adds a label to the container.

Validation
------------
* curl http://localhost:5000 and verify message
* inspect the container to make the label exists on it
10 changes: 10 additions & 0 deletions test/compose/mount_and_label/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3'
services:
web:
build: frontend
ports:
- '5000:5000'
volumes:
- /tmp/data:/data:ro
labels:
- "io.podman=the_best"
5 changes: 5 additions & 0 deletions test/compose/mount_and_label/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM quay.io/libpod/podman_python
WORKDIR /app
COPY . /app
ENTRYPOINT ["python3"]
CMD ["app.py"]
10 changes: 10 additions & 0 deletions test/compose/mount_and_label/frontend/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello():
f = open("/data/message")
return f.read()

if __name__ == '__main__':
app.run(host='0.0.0.0')
2 changes: 2 additions & 0 deletions test/compose/mount_and_label/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mkdir -p /tmp/data
echo "Podman rulez!" > /tmp/data/message
1 change: 1 addition & 0 deletions test/compose/mount_and_label/teardown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rm /tmp/data/message
4 changes: 4 additions & 0 deletions test/compose/mount_and_label/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- bash -*-

test_port 5000 = "Podman rulez!"
podman container inspect -l --format '{{.Config.Labels}}' | grep "the_best"
9 changes: 9 additions & 0 deletions test/compose/port_map_diff_port/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
port map on different port
===============

This test creates a container that runs flask on different ports for the container
and the host

Validation
------------
* curl http://localhost:5001 and verify message
6 changes: 6 additions & 0 deletions test/compose/port_map_diff_port/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: '3'
services:
web:
build: frontend
ports:
- '5001:5000'
5 changes: 5 additions & 0 deletions test/compose/port_map_diff_port/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM quay.io/libpod/podman_python
WORKDIR /app
COPY . /app
ENTRYPOINT ["python3"]
CMD ["app.py"]
9 changes: 9 additions & 0 deletions test/compose/port_map_diff_port/frontend/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello():
return "Podman rulez!"

if __name__ == '__main__':
app.run(host='0.0.0.0')
3 changes: 3 additions & 0 deletions test/compose/port_map_diff_port/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- bash -*-

test_port 5001 = "Podman rulez!"
3 changes: 3 additions & 0 deletions test/compose/setup.sh.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- bash -*-

export ENV_PASSTHRU=$(random_string 20)
9 changes: 9 additions & 0 deletions test/compose/simple_port_map/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
simple port map to host
===============

This test creates a container that runs flask on and maps to the same
host port

Validation
------------
* curl http://localhost:5000 and verify message
6 changes: 6 additions & 0 deletions test/compose/simple_port_map/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: '3'
services:
web:
build: frontend
ports:
- '5000:5000'
6 changes: 6 additions & 0 deletions test/compose/simple_port_map/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM alpine
WORKDIR /app
RUN apk update && apk add py3-pip && pip3 install flask
COPY . /app
ENTRYPOINT ["python3"]
CMD ["app.py"]
10 changes: 10 additions & 0 deletions test/compose/simple_port_map/frontend/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from flask import Flask
import os
app = Flask(__name__)

@app.route('/')
def hello():
return "Podman rulez!"

if __name__ == '__main__':
app.run(host='0.0.0.0')
3 changes: 3 additions & 0 deletions test/compose/simple_port_map/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- bash -*-

test_port 5000 = "Podman rulez!"
4 changes: 4 additions & 0 deletions test/compose/teardown.sh.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- bash -*-

# FIXME: this is completely unnecessary; it's just an example of a teardown
unset ENV_PASSTHRU
Loading

0 comments on commit a226e6e

Please sign in to comment.