Merge pull request #877 from p12tic/tests-faster

tests: Optimize speed by using dumb-init to handle SIGTERM signal
This commit is contained in:
Povilas Kanapickas 2024-03-08 14:49:25 +02:00 committed by GitHub
commit a494f20e15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 57 additions and 38 deletions

View File

@ -0,0 +1,12 @@
import os
import subprocess
def create_base_test_image():
subprocess.check_call(
['podman', 'build', '-t', 'nopush/podman-compose-test', '.'],
cwd=os.path.join(os.path.dirname(__file__), "base_image"),
)
create_base_test_image()

View File

@ -0,0 +1,6 @@
FROM docker.io/library/debian:bookworm-slim
RUN apt-get update \
&& apt-get install -y \
dumb-init \
busybox \
wget

View File

@ -1,22 +1,22 @@
version: "3.7" version: "3.7"
services: services:
web: web:
image: busybox image: nopush/podman-compose-test
command: ["/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"] command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
tmpfs: tmpfs:
- /run - /run
- /tmp - /tmp
sleep: sleep:
image: busybox image: nopush/podman-compose-test
command: ["/bin/busybox", "sh", "-c", "sleep 3600"] command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 3600"]
depends_on: depends_on:
- "web" - "web"
tmpfs: tmpfs:
- /run - /run
- /tmp - /tmp
sleep2: sleep2:
image: busybox image: nopush/podman-compose-test
command: ["/bin/busybox", "sh", "-c", "sleep 3600"] command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 3600"]
depends_on: depends_on:
- sleep - sleep
tmpfs: tmpfs:

View File

@ -1,20 +1,20 @@
version: "3" version: "3"
services: services:
too_long: too_long:
image: busybox image: nopush/podman-compose-test
command: ["/bin/busybox", "sh", "-c", "sleep 3600; exit 0"] command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 3600; exit 0"]
tmpfs: tmpfs:
- /run - /run
- /tmp - /tmp
sh1: sh1:
image: busybox image: nopush/podman-compose-test
command: ["/bin/busybox", "sh", "-c", "sleep 5; exit 1"] command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 1; exit 1"]
tmpfs: tmpfs:
- /run - /run
- /tmp - /tmp
sh2: sh2:
image: busybox image: nopush/podman-compose-test
command: ["/bin/busybox", "sh", "-c", "sleep 5; exit 2"] command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 1; exit 2"]
tmpfs: tmpfs:
- /run - /run
- /tmp - /tmp

View File

@ -2,6 +2,6 @@ services:
webapp_default: webapp_default:
webapp_special: webapp_special:
image: busybox image: nopush/podman-compose-test
volumes: volumes:
- "/data" - "/data"

View File

@ -1,7 +1,7 @@
version: "3" version: "3"
services: services:
web: web:
image: busybox image: nopush/podman-compose-test
extends: extends:
file: common-services.yml file: common-services.yml
service: webapp_default service: webapp_default

View File

@ -1 +1 @@
FROM busybox as base FROM nopush/podman-compose-test as base

View File

@ -2,6 +2,6 @@ version: '3.6'
services: services:
web: web:
image: busybox image: nopush/podman-compose-test
command: ["/bin/busybox", "httpd", "-f", "-h", ".", "-p", "8003"] command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", ".", "-p", "8003"]

View File

@ -1,18 +1,18 @@
version: "3" version: "3"
services: services:
web1: web1:
image: busybox image: nopush/podman-compose-test
hostname: web1 hostname: web1
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"] command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
working_dir: /var/www/html working_dir: /var/www/html
ports: ports:
- 8001:8001 - 8001:8001
volumes: volumes:
- ./test1.txt:/var/www/html/index.txt:ro,z - ./test1.txt:/var/www/html/index.txt:ro,z
web2: web2:
image: busybox image: nopush/podman-compose-test
hostname: web2 hostname: web2
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8002"] command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8002"]
working_dir: /var/www/html working_dir: /var/www/html
ports: ports:
- 8002:8002 - 8002:8002

View File

@ -1,24 +1,24 @@
version: "3" version: "3"
services: services:
default-service: default-service:
image: busybox image: nopush/podman-compose-test
command: ["/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"] command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
tmpfs: tmpfs:
- /run - /run
- /tmp - /tmp
service-1: service-1:
image: busybox image: nopush/podman-compose-test
command: ["/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"] command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
tmpfs: tmpfs:
- /run - /run
- /tmp - /tmp
profiles: profiles:
- profile-1 - profile-1
service-2: service-2:
image: busybox image: nopush/podman-compose-test
command: ["/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"] command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
tmpfs: tmpfs:
- /run - /run
- /tmp - /tmp
profiles: profiles:
- profile-2 - profile-2

View File

@ -49,7 +49,7 @@ class TestPodmanComposeInclude(unittest.TestCase, RunSubprocessMixin):
self.run_subprocess_assert_returncode(command_up) self.run_subprocess_assert_returncode(command_up)
out, _ = self.run_subprocess_assert_returncode(command_check_container) out, _ = self.run_subprocess_assert_returncode(command_check_container)
self.assertEqual(out, b'"docker.io/library/busybox:latest"\n') self.assertEqual(out, b'"localhost/nopush/podman-compose-test:latest"\n')
# Get container ID to remove it # Get container ID to remove it
out, _ = self.run_subprocess_assert_returncode(command_container_id) out, _ = self.run_subprocess_assert_returncode(command_container_id)
self.assertNotEqual(out, b"") self.assertNotEqual(out, b"")

View File

@ -155,7 +155,8 @@ class TestPodmanCompose(unittest.TestCase, RunSubprocessMixin):
"run", "run",
"--rm", "--rm",
"-d", "-d",
"busybox", "nopush/podman-compose-test",
"dumb-init",
"/bin/busybox", "/bin/busybox",
"httpd", "httpd",
"-f", "-f",

View File

@ -1,8 +1,8 @@
version: "3" version: "3"
services: services:
web: web:
image: busybox image: nopush/podman-compose-test
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8000"] command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8000"]
working_dir: /var/www/html working_dir: /var/www/html
restart: always restart: always
volumes: volumes:
@ -11,21 +11,21 @@ services:
- /run - /run
- /tmp - /tmp
web1: web1:
image: busybox image: nopush/podman-compose-test
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"] command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
restart: unless-stopped restart: unless-stopped
working_dir: /var/www/html working_dir: /var/www/html
volumes: volumes:
- myvol1:/var/www/html:ro,z - myvol1:/var/www/html:ro,z
web2: web2:
image: busybox image: nopush/podman-compose-test
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8002"] command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8002"]
working_dir: /var/www/html working_dir: /var/www/html
volumes: volumes:
- myvol2:/var/www/html:ro - myvol2:/var/www/html:ro
web3: web3:
image: busybox image: nopush/podman-compose-test
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8003"] command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8003"]
working_dir: /var/www/html working_dir: /var/www/html
volumes: volumes:
- myvol2:/var/www/html - myvol2:/var/www/html