automation-tests/test/compose
Giuseppe Scrivano 18e29076f7
pkg/api: honor cdi devices from the hostconfig
pass down the devices specifies in the resources block so that CDI
devices in the compose file are honored.

Tested manually with the following compose file:

services:
  testgpupodman_count:
    image: ubuntu:latest
    command: ["nvidia-smi"]
    profiles: [gpu]
    deploy:
      resources:
        reservations:
          devices:
          - driver: nvidia
            count: 1
            capabilities: [gpu]
  testgpupodman_deviceid:
      image: docker.io/ubuntu:latest
      command: ["nvidia-smi"]
      deploy:
        resources:
          reservations:
            devices:
            - driver: cdi
              device_ids: ['nvidia.com/gpu=all']
              capabilities: [gpu]

Closes: https://github.com/containers/podman/issues/19338

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-01-31 15:26:09 +01:00
..
cdi_device pkg/api: honor cdi devices from the hostconfig 2025-01-31 15:26:09 +01:00
disable_healthcheck Docker-compose disable healthcheck properly handled 2022-07-05 08:02:22 -04:00
env_and_volume add compose test descriptions 2020-12-11 10:07:13 -06:00
etc_hosts test/compose: remove compose v1 code 2024-04-18 14:48:37 +02:00
images add compose test descriptions 2020-12-11 10:07:13 -06:00
ipam_set_ip Set network ID if available during container inspect 2025-01-20 15:55:26 +01:00
mount_and_label Fix AVC denials in tests of volume mounts 2021-08-18 12:04:06 -04:00
port_map_diff_port add compose test descriptions 2020-12-11 10:07:13 -06:00
simple_port_map Improve compose tests 2023-12-16 12:04:25 -05:00
slirp4netns_opts Improve compose tests 2023-12-16 12:04:25 -05:00
two_networks test/compose: remove compose v1 code 2024-04-18 14:48:37 +02:00
update_network_mtu (rootful) docker-compose now updates network MTU 2022-07-05 07:54:09 -04:00
uptwice Set network ID if available during container inspect 2025-01-20 15:55:26 +01:00
uptwice_idempotent Set network ID if available during container inspect 2025-01-20 15:55:26 +01:00
README.md test/compose: remove compose v1 code 2024-04-18 14:48:37 +02:00
setup.sh.example add compose test descriptions 2020-12-11 10:07:13 -06:00
teardown.sh.example add compose test descriptions 2020-12-11 10:07:13 -06:00
test-compose Disable compose-warning-logs if PODMAN_COMPOSE_WARNING_LOGS=false 2024-07-30 12:06:11 +00:00

README.md

Tests for docker-compose v2

This directory contains tests for docker-compose v2 under podman. docker-compose v1 is no longer supported upstream so we no longer test with it.

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