Skip to content
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

tests: Optimize speed by using dumb-init to handle SIGTERM signal #877

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -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()
6 changes: 6 additions & 0 deletions tests/base_image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM docker.io/library/debian:bookworm-slim
RUN apt-get update \
&& apt-get install -y \
dumb-init \
busybox \
wget
12 changes: 6 additions & 6 deletions tests/deps/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
version: "3.7"
services:
web:
image: busybox
command: ["/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
image: nopush/podman-compose-test
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
tmpfs:
- /run
- /tmp
sleep:
image: busybox
command: ["/bin/busybox", "sh", "-c", "sleep 3600"]
image: nopush/podman-compose-test
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 3600"]
depends_on:
- "web"
tmpfs:
- /run
- /tmp
sleep2:
image: busybox
command: ["/bin/busybox", "sh", "-c", "sleep 3600"]
image: nopush/podman-compose-test
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 3600"]
depends_on:
- sleep
tmpfs:
Expand Down
12 changes: 6 additions & 6 deletions tests/exit-from/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
version: "3"
services:
too_long:
image: busybox
command: ["/bin/busybox", "sh", "-c", "sleep 3600; exit 0"]
image: nopush/podman-compose-test
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 3600; exit 0"]
tmpfs:
- /run
- /tmp
sh1:
image: busybox
command: ["/bin/busybox", "sh", "-c", "sleep 5; exit 1"]
image: nopush/podman-compose-test
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 1; exit 1"]
tmpfs:
- /run
- /tmp
sh2:
image: busybox
command: ["/bin/busybox", "sh", "-c", "sleep 5; exit 2"]
image: nopush/podman-compose-test
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 1; exit 2"]
tmpfs:
- /run
- /tmp
Expand Down
2 changes: 1 addition & 1 deletion tests/extends_w_empty_service/common-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ services:
webapp_default:

webapp_special:
image: busybox
image: nopush/podman-compose-test
volumes:
- "/data"
2 changes: 1 addition & 1 deletion tests/extends_w_empty_service/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3"
services:
web:
image: busybox
image: nopush/podman-compose-test
extends:
file: common-services.yml
service: webapp_default
Expand Down
2 changes: 1 addition & 1 deletion tests/extends_w_file_subdir/sub/docker/example/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM busybox as base
FROM nopush/podman-compose-test as base
4 changes: 2 additions & 2 deletions tests/include/docker-compose.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ version: '3.6'

services:
web:
image: busybox
command: ["/bin/busybox", "httpd", "-f", "-h", ".", "-p", "8003"]
image: nopush/podman-compose-test
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", ".", "-p", "8003"]

8 changes: 4 additions & 4 deletions tests/ports/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
version: "3"
services:
web1:
image: busybox
image: nopush/podman-compose-test
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
ports:
- 8001:8001
volumes:
- ./test1.txt:/var/www/html/index.txt:ro,z
web2:
image: busybox
image: nopush/podman-compose-test
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
ports:
- 8002:8002
Expand Down
14 changes: 7 additions & 7 deletions tests/profile/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
version: "3"
services:
default-service:
image: busybox
command: ["/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
image: nopush/podman-compose-test
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
tmpfs:
- /run
- /tmp
service-1:
image: busybox
command: ["/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
image: nopush/podman-compose-test
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
tmpfs:
- /run
- /tmp
profiles:
- profile-1
service-2:
image: busybox
command: ["/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
image: nopush/podman-compose-test
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
tmpfs:
- /run
- /tmp
profiles:
- profile-2
- profile-2
2 changes: 1 addition & 1 deletion tests/test_podman_compose_include.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_podman_compose_include(self):

self.run_subprocess_assert_returncode(command_up)
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
out, _ = self.run_subprocess_assert_returncode(command_container_id)
self.assertNotEqual(out, b"")
Expand Down
3 changes: 2 additions & 1 deletion tests/test_podman_compose_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ def test_down_with_orphans(self):
"run",
"--rm",
"-d",
"busybox",
"nopush/podman-compose-test",
"dumb-init",
"/bin/busybox",
"httpd",
"-f",
Expand Down
16 changes: 8 additions & 8 deletions tests/vol/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: "3"
services:
web:
image: busybox
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8000"]
image: nopush/podman-compose-test
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8000"]
working_dir: /var/www/html
restart: always
volumes:
Expand All @@ -11,21 +11,21 @@ services:
- /run
- /tmp
web1:
image: busybox
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
image: nopush/podman-compose-test
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
restart: unless-stopped
working_dir: /var/www/html
volumes:
- myvol1:/var/www/html:ro,z
web2:
image: busybox
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8002"]
image: nopush/podman-compose-test
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8002"]
working_dir: /var/www/html
volumes:
- myvol2:/var/www/html:ro
web3:
image: busybox
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8003"]
image: nopush/podman-compose-test
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8003"]
working_dir: /var/www/html
volumes:
- myvol2:/var/www/html
Expand Down
Loading