mirror of
https://github.com/containers/podman-compose.git
synced 2025-08-19 09:51:47 +02:00
Move all tests to single directory "tests"
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
This commit is contained in:
12
tests/integration/__init__.py
Normal file
12
tests/integration/__init__.py
Normal 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()
|
14
tests/integration/additional_contexts/README.md
Normal file
14
tests/integration/additional_contexts/README.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# Test podman-compose with build.additional_contexts
|
||||
|
||||
```
|
||||
podman-compose build
|
||||
podman-compose up
|
||||
podman-compose down
|
||||
```
|
||||
|
||||
expected output would be
|
||||
|
||||
```
|
||||
[dict] | Data for dict
|
||||
[list] | Data for list
|
||||
```
|
@@ -0,0 +1 @@
|
||||
Data for dict
|
@@ -0,0 +1 @@
|
||||
Data for list
|
3
tests/integration/additional_contexts/project/Dockerfile
Normal file
3
tests/integration/additional_contexts/project/Dockerfile
Normal file
@@ -0,0 +1,3 @@
|
||||
FROM busybox
|
||||
COPY --from=data data.txt /data/data.txt
|
||||
CMD ["busybox", "cat", "/data/data.txt"]
|
@@ -0,0 +1,12 @@
|
||||
version: "3.7"
|
||||
services:
|
||||
dict:
|
||||
build:
|
||||
context: .
|
||||
additional_contexts:
|
||||
data: ../data_for_dict
|
||||
list:
|
||||
build:
|
||||
context: .
|
||||
additional_contexts:
|
||||
- data=../data_for_list
|
6
tests/integration/base_image/Dockerfile
Normal file
6
tests/integration/base_image/Dockerfile
Normal file
@@ -0,0 +1,6 @@
|
||||
FROM docker.io/library/debian:bookworm-slim
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y \
|
||||
dumb-init \
|
||||
busybox \
|
||||
wget
|
25
tests/integration/build/README.md
Normal file
25
tests/integration/build/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Test podman-compose with build
|
||||
|
||||
```
|
||||
podman-compose build
|
||||
podman-compose up -d
|
||||
curl http://localhost:8080/index.txt
|
||||
curl http://localhost:8000/index.txt
|
||||
podman inspect my-busybox-httpd2
|
||||
podman-compose down
|
||||
```
|
||||
|
||||
expected output would be something like
|
||||
|
||||
```
|
||||
2019-09-03T15:16:38+0000
|
||||
ALT buildno=2 port 8000 2019-09-03T15:16:38+0000
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
as you can see we were able to override buildno to be 2 instead of 1,
|
||||
and httpd_port to 8000.
|
||||
|
||||
NOTE: build labels are not passed to `podman build`
|
3
tests/integration/build/context/Dockerfile
Normal file
3
tests/integration/build/context/Dockerfile
Normal file
@@ -0,0 +1,3 @@
|
||||
FROM busybox
|
||||
RUN mkdir -p /var/www/html/ && date -Iseconds > /var/www/html/index.txt
|
||||
CMD ["busybox", "httpd", "-f", "-p", "80", "-h", "/var/www/html"]
|
9
tests/integration/build/context/Dockerfile-alt
Normal file
9
tests/integration/build/context/Dockerfile-alt
Normal file
@@ -0,0 +1,9 @@
|
||||
FROM busybox
|
||||
ARG buildno=1
|
||||
ARG httpd_port=80
|
||||
ARG other_variable=not_set
|
||||
ENV httpd_port ${httpd_port}
|
||||
ENV other_variable ${other_variable}
|
||||
RUN mkdir -p /var/www/html/ && \
|
||||
echo "ALT buildno=$buildno port=$httpd_port `date -Iseconds`" > /var/www/html/index.txt
|
||||
CMD httpd -f -p "$httpd_port" -h /var/www/html
|
25
tests/integration/build/docker-compose.yml
Normal file
25
tests/integration/build/docker-compose.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
version: "3"
|
||||
services:
|
||||
web1:
|
||||
build: ./context
|
||||
image: my-busybox-httpd
|
||||
ports:
|
||||
- 8080:80
|
||||
web2:
|
||||
build:
|
||||
context: ./context
|
||||
dockerfile: Dockerfile-alt
|
||||
labels:
|
||||
mykey: myval
|
||||
args:
|
||||
buildno: 2
|
||||
httpd_port: 8000
|
||||
image: my-busybox-httpd2
|
||||
ports:
|
||||
- 8000:8000
|
||||
test_build_arg_argument:
|
||||
build:
|
||||
context: ./context
|
||||
dockerfile: Dockerfile-alt
|
||||
image: my-busybox-httpd2
|
||||
command: env
|
22
tests/integration/build_fail/README.md
Normal file
22
tests/integration/build_fail/README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Test podman-compose with build (fail scenario)
|
||||
|
||||
```shell
|
||||
podman-compose build || echo $?
|
||||
```
|
||||
|
||||
expected output would be something like
|
||||
|
||||
```
|
||||
STEP 1/3: FROM busybox
|
||||
STEP 2/3: RUN this_command_does_not_exist
|
||||
/bin/sh: this_command_does_not_exist: not found
|
||||
Error: building at STEP "RUN this_command_does_not_exist": while running runtime: exit status 127
|
||||
|
||||
exit code: 127
|
||||
```
|
||||
|
||||
Expected `podman-compose` exit code:
|
||||
```shell
|
||||
echo $?
|
||||
127
|
||||
```
|
3
tests/integration/build_fail/context/Dockerfile
Normal file
3
tests/integration/build_fail/context/Dockerfile
Normal file
@@ -0,0 +1,3 @@
|
||||
FROM busybox
|
||||
RUN this_command_does_not_exist
|
||||
CMD ["sh"]
|
5
tests/integration/build_fail/docker-compose.yml
Normal file
5
tests/integration/build_fail/docker-compose.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
version: "3"
|
||||
services:
|
||||
test:
|
||||
build: ./context
|
||||
image: build-fail-img
|
9
tests/integration/build_secrets/Dockerfile
Normal file
9
tests/integration/build_secrets/Dockerfile
Normal file
@@ -0,0 +1,9 @@
|
||||
FROM busybox
|
||||
|
||||
RUN --mount=type=secret,required=true,id=build_secret \
|
||||
ls -l /run/secrets/ && cat /run/secrets/build_secret
|
||||
|
||||
RUN --mount=type=secret,required=true,id=build_secret,target=/tmp/secret \
|
||||
ls -l /run/secrets/ /tmp/ && cat /tmp/secret
|
||||
|
||||
CMD [ 'echo', 'nothing here' ]
|
22
tests/integration/build_secrets/docker-compose.yaml
Normal file
22
tests/integration/build_secrets/docker-compose.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
test:
|
||||
image: test
|
||||
secrets:
|
||||
- run_secret # implicitly mount to /run/secrets/run_secret
|
||||
- source: run_secret
|
||||
target: /tmp/run_secret2 # explicit mount point
|
||||
|
||||
build:
|
||||
context: .
|
||||
secrets:
|
||||
- build_secret # can be mounted in Dockerfile with "RUN --mount=type=secret,id=build_secret"
|
||||
- source: build_secret
|
||||
target: build_secret2 # rename to build_secret2
|
||||
|
||||
secrets:
|
||||
build_secret:
|
||||
file: ./my_secret
|
||||
run_secret:
|
||||
file: ./my_secret
|
18
tests/integration/build_secrets/docker-compose.yaml.invalid
Normal file
18
tests/integration/build_secrets/docker-compose.yaml.invalid
Normal file
@@ -0,0 +1,18 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
test:
|
||||
image: test
|
||||
build:
|
||||
context: .
|
||||
secrets:
|
||||
# invalid target argument
|
||||
#
|
||||
# According to https://github.com/compose-spec/compose-spec/blob/master/build.md, target is
|
||||
# supposed to be the "name of a *file* to be mounted in /run/secrets/". Not a path.
|
||||
- source: build_secret
|
||||
target: /build_secret
|
||||
|
||||
secrets:
|
||||
build_secret:
|
||||
file: ./my_secret
|
1
tests/integration/build_secrets/my_secret
Normal file
1
tests/integration/build_secrets/my_secret
Normal file
@@ -0,0 +1 @@
|
||||
important-secret-is-important
|
4
tests/integration/deps/README.md
Normal file
4
tests/integration/deps/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
```
|
||||
podman-compose run --rm sleep /bin/sh -c 'wget -O - http://web:8000/hosts'
|
||||
```
|
25
tests/integration/deps/docker-compose.yaml
Normal file
25
tests/integration/deps/docker-compose.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
version: "3.7"
|
||||
services:
|
||||
web:
|
||||
image: nopush/podman-compose-test
|
||||
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
sleep:
|
||||
image: nopush/podman-compose-test
|
||||
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 3600"]
|
||||
depends_on:
|
||||
- "web"
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
sleep2:
|
||||
image: nopush/podman-compose-test
|
||||
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 3600"]
|
||||
depends_on:
|
||||
- sleep
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
|
2
tests/integration/env-file-tests/.env
Normal file
2
tests/integration/env-file-tests/.env
Normal file
@@ -0,0 +1,2 @@
|
||||
ZZVAR1='This value is overwritten by env-file-tests/.env'
|
||||
ZZVAR3='This value is loaded from env-file-tests/.env'
|
4
tests/integration/env-file-tests/.gitignore
vendored
Normal file
4
tests/integration/env-file-tests/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
# This overrides the repository root .gitignore (ignoring all .env).
|
||||
# The .env files in this directory are important for the test cases.
|
||||
!.env
|
||||
!project/.env
|
37
tests/integration/env-file-tests/README.md
Normal file
37
tests/integration/env-file-tests/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
running the following commands should always give podman-rocks-123
|
||||
|
||||
```
|
||||
podman-compose -f project/container-compose.yaml --env-file env-files/project-1.env up
|
||||
```
|
||||
|
||||
```
|
||||
podman-compose -f $(pwd)/project/container-compose.yaml --env-file $(pwd)/env-files/project-1.env up
|
||||
```
|
||||
|
||||
```
|
||||
podman-compose -f $(pwd)/project/container-compose.env-file-flat.yaml up
|
||||
```
|
||||
|
||||
```
|
||||
podman-compose -f $(pwd)/project/container-compose.env-file-obj.yaml up
|
||||
```
|
||||
|
||||
```
|
||||
podman-compose -f $(pwd)/project/container-compose.env-file-obj-optional.yaml up
|
||||
```
|
||||
|
||||
based on environment variable precedent this command should give podman-rocks-321
|
||||
|
||||
```
|
||||
ZZVAR1=podman-rocks-321 podman-compose -f $(pwd)/project/container-compose.yaml --env-file $(pwd)/env-files/project-1.env up
|
||||
```
|
||||
|
||||
_The below test should print three environment variables_
|
||||
|
||||
```
|
||||
podman-compose -f $(pwd)/project/container-compose.load-.env-in-project.yaml run --rm app
|
||||
|
||||
ZZVAR1=This value is overwritten by env-file-tests/.env
|
||||
ZZVAR2=This value is loaded from .env in project/ directory
|
||||
ZZVAR3=This value is loaded from env-file-tests/.env
|
||||
```
|
3
tests/integration/env-file-tests/env-files/project-1.env
Normal file
3
tests/integration/env-file-tests/env-files/project-1.env
Normal file
@@ -0,0 +1,3 @@
|
||||
ZZVAR1=podman-rocks-123
|
||||
ZZVAR2=podman-rocks-124
|
||||
ZZVAR3=podman-rocks-125
|
2
tests/integration/env-file-tests/env-files/project-2.env
Normal file
2
tests/integration/env-file-tests/env-files/project-2.env
Normal file
@@ -0,0 +1,2 @@
|
||||
ZZVAR1=podman-rocks-223
|
||||
ZZVAR2=podman-rocks-224
|
2
tests/integration/env-file-tests/project/.env
Normal file
2
tests/integration/env-file-tests/project/.env
Normal file
@@ -0,0 +1,2 @@
|
||||
ZZVAR1='This value is loaded but should be overwritten'
|
||||
ZZVAR2='This value is loaded from .env in project/ directory'
|
@@ -0,0 +1,9 @@
|
||||
services:
|
||||
app:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "sh", "-c", "env | grep ZZ"]
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
env_file:
|
||||
- ../env-files/project-1.env
|
@@ -0,0 +1,11 @@
|
||||
services:
|
||||
app:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "sh", "-c", "env | grep ZZ"]
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
env_file:
|
||||
- path: ../env-files/project-1.env
|
||||
- path: ../env-files/project-2.env
|
||||
required: false
|
@@ -0,0 +1,9 @@
|
||||
services:
|
||||
app:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "sh", "-c", "env | grep ZZ"]
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
env_file:
|
||||
- path: ../env-files/project-1.env
|
@@ -0,0 +1,11 @@
|
||||
services:
|
||||
app:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "sh", "-c", "env | grep ZZ"]
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
environment:
|
||||
ZZVAR1: $ZZVAR1
|
||||
ZZVAR2: $ZZVAR2
|
||||
ZZVAR3: $ZZVAR3
|
@@ -0,0 +1,9 @@
|
||||
services:
|
||||
app:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "sh", "-c", "env | grep ZZ"]
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
environment:
|
||||
ZZVAR1: $ZZVAR1
|
5
tests/integration/env-tests/README.md
Normal file
5
tests/integration/env-tests/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
running the following command should give myval2
|
||||
|
||||
```
|
||||
podman_compose run -l monkey -e ZZVAR1=myval2 env-test
|
||||
```
|
9
tests/integration/env-tests/container-compose.yml
Normal file
9
tests/integration/env-tests/container-compose.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
env-test:
|
||||
image: busybox
|
||||
command: sh -c "export | grep ZZ"
|
||||
environment:
|
||||
- ZZVAR1=myval1
|
||||
|
15
tests/integration/exit-from/README.md
Normal file
15
tests/integration/exit-from/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
We have service named sh1 that exits with code 1 and sh2 that exists with code 2
|
||||
|
||||
```
|
||||
podman-compose up --exit-code-from=sh1
|
||||
echo $?
|
||||
```
|
||||
|
||||
the above should give 1.
|
||||
|
||||
```
|
||||
podman-compose up --exit-code-from=sh2
|
||||
echo $?
|
||||
```
|
||||
|
||||
the above should give 2.
|
21
tests/integration/exit-from/docker-compose.yaml
Normal file
21
tests/integration/exit-from/docker-compose.yaml
Normal file
@@ -0,0 +1,21 @@
|
||||
version: "3"
|
||||
services:
|
||||
too_long:
|
||||
image: nopush/podman-compose-test
|
||||
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 3600; exit 0"]
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
sh1:
|
||||
image: nopush/podman-compose-test
|
||||
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 1; exit 1"]
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
sh2:
|
||||
image: nopush/podman-compose-test
|
||||
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 1; exit 2"]
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
|
29
tests/integration/extends/docker-compose.yaml
Normal file
29
tests/integration/extends/docker-compose.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
version: "3"
|
||||
services:
|
||||
echo:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "echo", "Zero"]
|
||||
ports:
|
||||
- '1234:1234'
|
||||
environment:
|
||||
- FOO=original
|
||||
- BAR=original
|
||||
# volumes:
|
||||
# - ./original:/foo
|
||||
# - ./original:/bar
|
||||
echo1:
|
||||
extends:
|
||||
service: echo
|
||||
command: ["/bin/busybox", "echo", "One"]
|
||||
ports:
|
||||
- '12345:12345'
|
||||
# volumes:
|
||||
# - ./local:/bar
|
||||
# - ./local:/baz
|
||||
env1:
|
||||
extends:
|
||||
service: echo
|
||||
command: ["/bin/busybox", "env"]
|
||||
environment:
|
||||
- BAR=local
|
||||
- BAZ=local
|
@@ -0,0 +1,7 @@
|
||||
services:
|
||||
webapp_default:
|
||||
|
||||
webapp_special:
|
||||
image: nopush/podman-compose-test
|
||||
volumes:
|
||||
- "/data"
|
10
tests/integration/extends_w_empty_service/docker-compose.yml
Normal file
10
tests/integration/extends_w_empty_service/docker-compose.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
version: "3"
|
||||
services:
|
||||
web:
|
||||
image: nopush/podman-compose-test
|
||||
extends:
|
||||
file: common-services.yml
|
||||
service: webapp_default
|
||||
environment:
|
||||
- DEBUG=1
|
||||
cpu_shares: 5
|
7
tests/integration/extends_w_file/common-services.yml
Normal file
7
tests/integration/extends_w_file/common-services.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
webapp:
|
||||
build: .
|
||||
ports:
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- "/data"
|
||||
|
14
tests/integration/extends_w_file/docker-compose.yml
Normal file
14
tests/integration/extends_w_file/docker-compose.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
version: "3"
|
||||
services:
|
||||
web:
|
||||
extends:
|
||||
file: common-services.yml
|
||||
service: webapp
|
||||
environment:
|
||||
- DEBUG=1
|
||||
cpu_shares: 5
|
||||
|
||||
important_web:
|
||||
extends: web
|
||||
cpu_shares: 10
|
||||
|
@@ -0,0 +1,8 @@
|
||||
version: "3"
|
||||
services:
|
||||
web:
|
||||
extends:
|
||||
file: sub/docker-compose.yml
|
||||
service: webapp
|
||||
environment:
|
||||
- DEBUG=1
|
@@ -0,0 +1,12 @@
|
||||
version: "3"
|
||||
services:
|
||||
webapp:
|
||||
build:
|
||||
context: docker/example
|
||||
dockerfile: Dockerfile
|
||||
image: localhost/subdir_test:me
|
||||
ports:
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- "/data"
|
||||
|
@@ -0,0 +1 @@
|
||||
FROM nopush/podman-compose-test as base
|
@@ -0,0 +1,9 @@
|
||||
version: "3"
|
||||
services:
|
||||
cont:
|
||||
image: nopush/podman-compose-test
|
||||
userns_mode: keep-id:uid=1000
|
||||
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-p", "8080"]
|
||||
|
||||
x-podman:
|
||||
in_pod: false
|
@@ -0,0 +1,6 @@
|
||||
version: "3"
|
||||
services:
|
||||
cont:
|
||||
image: nopush/podman-compose-test
|
||||
userns_mode: keep-id:uid=1000
|
||||
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-p", "8080"]
|
@@ -0,0 +1,9 @@
|
||||
version: "3"
|
||||
services:
|
||||
cont:
|
||||
image: nopush/podman-compose-test
|
||||
userns_mode: keep-id:uid=1000
|
||||
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-p", "8080"]
|
||||
|
||||
x-podman:
|
||||
in_pod: true
|
7
tests/integration/include/docker-compose.base.yaml
Normal file
7
tests/integration/include/docker-compose.base.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
version: '3.6'
|
||||
|
||||
services:
|
||||
web:
|
||||
image: nopush/podman-compose-test
|
||||
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", ".", "-p", "8003"]
|
||||
|
6
tests/integration/include/docker-compose.extend.yaml
Normal file
6
tests/integration/include/docker-compose.extend.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
version: '3.6'
|
||||
|
||||
services:
|
||||
web2:
|
||||
image: nopush/podman-compose-test
|
||||
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", ".", "-p", "8004"]
|
5
tests/integration/include/docker-compose.yaml
Normal file
5
tests/integration/include/docker-compose.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
version: '3.6'
|
||||
|
||||
include:
|
||||
- docker-compose.base.yaml
|
||||
- docker-compose.extend.yaml
|
1
tests/integration/interpolation/.env
Normal file
1
tests/integration/interpolation/.env
Normal file
@@ -0,0 +1 @@
|
||||
DOT_ENV_VARIABLE=This value is from the .env file
|
@@ -0,0 +1,8 @@
|
||||
version: "3.7"
|
||||
services:
|
||||
variables:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "sh", "-c", "export | grep EXAMPLE"]
|
||||
environment:
|
||||
EXAMPLE_COLON_QUESTION_ERROR: ${NOT_A_VARIABLE:?Missing variable}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
version: "3.7"
|
||||
services:
|
||||
variables:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "sh", "-c", "export | grep EXAMPLE"]
|
||||
environment:
|
||||
EXAMPLE_QUESTION_ERROR: ${NOT_A_VARIABLE?Missing variable}
|
||||
|
14
tests/integration/interpolation/docker-compose.yml
Normal file
14
tests/integration/interpolation/docker-compose.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
version: "3.7"
|
||||
services:
|
||||
variables:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "sh", "-c", "export | grep EXAMPLE"]
|
||||
environment:
|
||||
EXAMPLE_VARIABLE: "Host user: $USER"
|
||||
EXAMPLE_BRACES: "Host user: ${USER}"
|
||||
EXAMPLE_COLON_DASH_DEFAULT: ${NOT_A_VARIABLE:-My default}
|
||||
EXAMPLE_DASH_DEFAULT: ${NOT_A_VARIABLE-My other default}
|
||||
EXAMPLE_DOT_ENV: $DOT_ENV_VARIABLE
|
||||
EXAMPLE_LITERAL: This is a $$literal
|
||||
EXAMPLE_EMPTY: $NOT_A_VARIABLE
|
||||
|
15
tests/integration/ipam_default/docker-compose.yaml
Normal file
15
tests/integration/ipam_default/docker-compose.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
version: '3'
|
||||
|
||||
# --ipam-driver must not be pass when driver is "default"
|
||||
networks:
|
||||
ipam_test_default:
|
||||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: 172.19.0.0/24
|
||||
|
||||
services:
|
||||
testipam:
|
||||
image: busybox
|
||||
command: ["echo", "ipamtest"]
|
||||
|
19
tests/integration/multicompose/README.md
Normal file
19
tests/integration/multicompose/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Multiple compose files
|
||||
|
||||
to make sure we get results similar to
|
||||
|
||||
```
|
||||
docker-compose -f d1/docker-compose.yml -f d2/docker-compose.yml up -d
|
||||
docker exec -ti d1_web1_1 sh -c 'set'
|
||||
docker exec -ti d1_web2_1 sh -c 'set'
|
||||
curl http://${d1_web1_1}:8001/index.txt
|
||||
curl http://${d1_web1_1}:8002/index.txt
|
||||
```
|
||||
|
||||
we need to verify
|
||||
|
||||
- project base directory and project name is `d1`
|
||||
- `var12='d1/12.env'` which means `enf_file` was appended not replaced (which means that we normalize to array before merge)
|
||||
- `var2='d1/2.env'` which means that paths inside `d2/docker-compose.yml` directory are relative to `d1`
|
||||
|
||||
|
1
tests/integration/multicompose/d1/1.env
Normal file
1
tests/integration/multicompose/d1/1.env
Normal file
@@ -0,0 +1 @@
|
||||
var1=d1/1.env
|
1
tests/integration/multicompose/d1/12.env
Normal file
1
tests/integration/multicompose/d1/12.env
Normal file
@@ -0,0 +1 @@
|
||||
var12=d1/12.env
|
1
tests/integration/multicompose/d1/2.env
Normal file
1
tests/integration/multicompose/d1/2.env
Normal file
@@ -0,0 +1 @@
|
||||
var2=d1/2.env
|
13
tests/integration/multicompose/d1/docker-compose.yml
Normal file
13
tests/integration/multicompose/d1/docker-compose.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
version: '3'
|
||||
services:
|
||||
web1:
|
||||
image: busybox
|
||||
command: busybox httpd -h /var/www/html/ -f -p 8001
|
||||
volumes:
|
||||
- ./1.env:/var/www/html/index.txt:z
|
||||
env_file: ./1.env
|
||||
labels:
|
||||
l1: v1
|
||||
environment:
|
||||
- mykey1=myval1
|
||||
|
1
tests/integration/multicompose/d2/12.env
Normal file
1
tests/integration/multicompose/d2/12.env
Normal file
@@ -0,0 +1 @@
|
||||
var12=d2/12.env
|
1
tests/integration/multicompose/d2/2.env
Normal file
1
tests/integration/multicompose/d2/2.env
Normal file
@@ -0,0 +1 @@
|
||||
var2=d2/2.env
|
19
tests/integration/multicompose/d2/docker-compose.yml
Normal file
19
tests/integration/multicompose/d2/docker-compose.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
version: '3'
|
||||
services:
|
||||
web1:
|
||||
image: busybox
|
||||
env_file: ./12.env
|
||||
labels:
|
||||
- l1=v2
|
||||
- l2=v2
|
||||
environment:
|
||||
mykey1: myval2
|
||||
mykey2: myval2
|
||||
|
||||
web2:
|
||||
image: busybox
|
||||
command: busybox httpd -h /var/www/html/ -f -p 8002
|
||||
volumes:
|
||||
- ./2.env:/var/www/html/index.txt:z
|
||||
env_file: ./2.env
|
||||
|
7
tests/integration/nethost/docker-compose.yaml
Normal file
7
tests/integration/nethost/docker-compose.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
version: '3'
|
||||
services:
|
||||
web:
|
||||
image: busybox
|
||||
command: httpd -f -p 8123 -h /etc/
|
||||
network_mode: host
|
||||
|
16
tests/integration/netprio/docker-compose.yaml
Normal file
16
tests/integration/netprio/docker-compose.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
# https://github.com/compose-spec/compose-spec/blob/master/spec.md#priority
|
||||
services:
|
||||
app:
|
||||
image: busybox
|
||||
command: top
|
||||
networks:
|
||||
app_net_1:
|
||||
app_net_2:
|
||||
priority: 1000
|
||||
app_net_3:
|
||||
priority: 100
|
||||
networks:
|
||||
app_net_1:
|
||||
app_net_2:
|
||||
app_net_3:
|
21
tests/integration/nets_test1/docker-compose.yml
Normal file
21
tests/integration/nets_test1/docker-compose.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
version: "3"
|
||||
services:
|
||||
web1:
|
||||
image: busybox
|
||||
hostname: web1
|
||||
command: ["/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
|
||||
hostname: web2
|
||||
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
|
||||
working_dir: /var/www/html
|
||||
ports:
|
||||
- 8002:8001
|
||||
volumes:
|
||||
- ./test2.txt:/var/www/html/index.txt:ro,z
|
||||
|
1
tests/integration/nets_test1/test1.txt
Normal file
1
tests/integration/nets_test1/test1.txt
Normal file
@@ -0,0 +1 @@
|
||||
test1
|
1
tests/integration/nets_test1/test2.txt
Normal file
1
tests/integration/nets_test1/test2.txt
Normal file
@@ -0,0 +1 @@
|
||||
test2
|
23
tests/integration/nets_test2/docker-compose.yml
Normal file
23
tests/integration/nets_test2/docker-compose.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
version: "3"
|
||||
networks:
|
||||
mystack:
|
||||
services:
|
||||
web1:
|
||||
image: busybox
|
||||
hostname: web1
|
||||
command: ["/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
|
||||
hostname: web2
|
||||
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
|
||||
working_dir: /var/www/html
|
||||
ports:
|
||||
- 8002:8001
|
||||
volumes:
|
||||
- ./test2.txt:/var/www/html/index.txt:ro,z
|
||||
|
1
tests/integration/nets_test2/test1.txt
Normal file
1
tests/integration/nets_test2/test1.txt
Normal file
@@ -0,0 +1 @@
|
||||
test1
|
1
tests/integration/nets_test2/test2.txt
Normal file
1
tests/integration/nets_test2/test2.txt
Normal file
@@ -0,0 +1 @@
|
||||
test2
|
45
tests/integration/nets_test3/docker-compose.yml
Normal file
45
tests/integration/nets_test3/docker-compose.yml
Normal file
@@ -0,0 +1,45 @@
|
||||
version: "3"
|
||||
networks:
|
||||
net1:
|
||||
net2:
|
||||
services:
|
||||
web1:
|
||||
image: busybox
|
||||
#container_name: web1
|
||||
hostname: web1
|
||||
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
|
||||
working_dir: /var/www/html
|
||||
networks:
|
||||
- net1
|
||||
ports:
|
||||
- 8001:8001
|
||||
volumes:
|
||||
- ./test1.txt:/var/www/html/index.txt:ro,z
|
||||
web2:
|
||||
image: busybox
|
||||
#container_name: web2
|
||||
hostname: web2
|
||||
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
|
||||
working_dir: /var/www/html
|
||||
networks:
|
||||
- net1
|
||||
- net2
|
||||
ports:
|
||||
- 8002:8001
|
||||
volumes:
|
||||
- ./test2.txt:/var/www/html/index.txt:ro,z
|
||||
web3:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
|
||||
working_dir: /var/www/html
|
||||
networks:
|
||||
net1:
|
||||
aliases:
|
||||
- alias11
|
||||
- alias12
|
||||
net2:
|
||||
aliases:
|
||||
- alias21
|
||||
volumes:
|
||||
- ./test2.txt:/var/www/html/index.txt:ro,z
|
||||
|
1
tests/integration/nets_test3/test1.txt
Normal file
1
tests/integration/nets_test3/test1.txt
Normal file
@@ -0,0 +1 @@
|
||||
test1
|
1
tests/integration/nets_test3/test2.txt
Normal file
1
tests/integration/nets_test3/test2.txt
Normal file
@@ -0,0 +1 @@
|
||||
test2
|
61
tests/integration/nets_test_ip/docker-compose.yml
Normal file
61
tests/integration/nets_test_ip/docker-compose.yml
Normal file
@@ -0,0 +1,61 @@
|
||||
version: "3"
|
||||
networks:
|
||||
shared-network:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: "172.19.1.0/24"
|
||||
internal-network:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: "172.19.2.0/24"
|
||||
|
||||
services:
|
||||
web1:
|
||||
image: busybox
|
||||
hostname: web1
|
||||
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
|
||||
working_dir: /var/www/html
|
||||
networks:
|
||||
shared-network:
|
||||
ipv4_address: "172.19.1.10"
|
||||
x-podman.mac_address: "02:01:01:00:01:01"
|
||||
internal-network:
|
||||
ipv4_address: "172.19.2.10"
|
||||
x-podman.mac_address: "02:01:01:00:02:01"
|
||||
volumes:
|
||||
- ./test1.txt:/var/www/html/index.txt:ro,z
|
||||
web2:
|
||||
image: busybox
|
||||
hostname: web2
|
||||
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
|
||||
working_dir: /var/www/html
|
||||
mac_address: "02:01:01:00:02:02"
|
||||
networks:
|
||||
internal-network:
|
||||
ipv4_address: "172.19.2.11"
|
||||
volumes:
|
||||
- ./test2.txt:/var/www/html/index.txt:ro,z
|
||||
|
||||
web3:
|
||||
image: busybox
|
||||
hostname: web2
|
||||
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
|
||||
working_dir: /var/www/html
|
||||
networks:
|
||||
internal-network:
|
||||
volumes:
|
||||
- ./test3.txt:/var/www/html/index.txt:ro,z
|
||||
|
||||
web4:
|
||||
image: busybox
|
||||
hostname: web2
|
||||
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
|
||||
working_dir: /var/www/html
|
||||
networks:
|
||||
internal-network:
|
||||
shared-network:
|
||||
ipv4_address: "172.19.1.13"
|
||||
volumes:
|
||||
- ./test4.txt:/var/www/html/index.txt:ro,z
|
1
tests/integration/nets_test_ip/test1.txt
Normal file
1
tests/integration/nets_test_ip/test1.txt
Normal file
@@ -0,0 +1 @@
|
||||
test1
|
1
tests/integration/nets_test_ip/test2.txt
Normal file
1
tests/integration/nets_test_ip/test2.txt
Normal file
@@ -0,0 +1 @@
|
||||
test2
|
1
tests/integration/nets_test_ip/test3.txt
Normal file
1
tests/integration/nets_test_ip/test3.txt
Normal file
@@ -0,0 +1 @@
|
||||
test3
|
1
tests/integration/nets_test_ip/test4.txt
Normal file
1
tests/integration/nets_test_ip/test4.txt
Normal file
@@ -0,0 +1 @@
|
||||
test4
|
7
tests/integration/no_services/docker-compose.yaml
Normal file
7
tests/integration/no_services/docker-compose.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
version: '3'
|
||||
networks:
|
||||
shared-network:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.19.0.0/24
|
6
tests/integration/pid/docker-compose.yml
Normal file
6
tests/integration/pid/docker-compose.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
version: "3"
|
||||
services:
|
||||
serv:
|
||||
image: busybox
|
||||
pid: host
|
||||
command: sh -c "ps all"
|
35
tests/integration/ports/docker-compose.yml
Normal file
35
tests/integration/ports/docker-compose.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
version: "3"
|
||||
services:
|
||||
web1:
|
||||
image: nopush/podman-compose-test
|
||||
hostname: web1
|
||||
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: nopush/podman-compose-test
|
||||
hostname: web2
|
||||
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8002"]
|
||||
working_dir: /var/www/html
|
||||
ports:
|
||||
- 8002:8002
|
||||
- target: 8003
|
||||
host_ip: 127.0.0.1
|
||||
published: 8003
|
||||
protocol: udp
|
||||
- target: 8004
|
||||
host_ip: 127.0.0.1
|
||||
published: 8004
|
||||
protocol: tcp
|
||||
- target: 8005
|
||||
published: 8005
|
||||
- target: 8006
|
||||
protocol: udp
|
||||
- target: 8007
|
||||
host_ip: 127.0.0.1
|
||||
volumes:
|
||||
- ./test2.txt:/var/www/html/index.txt:ro,z
|
||||
|
1
tests/integration/ports/test1.txt
Normal file
1
tests/integration/ports/test1.txt
Normal file
@@ -0,0 +1 @@
|
||||
test1
|
1
tests/integration/ports/test2.txt
Normal file
1
tests/integration/ports/test2.txt
Normal file
@@ -0,0 +1 @@
|
||||
test2
|
24
tests/integration/profile/docker-compose.yml
Normal file
24
tests/integration/profile/docker-compose.yml
Normal file
@@ -0,0 +1,24 @@
|
||||
version: "3"
|
||||
services:
|
||||
default-service:
|
||||
image: nopush/podman-compose-test
|
||||
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
service-1:
|
||||
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: nopush/podman-compose-test
|
||||
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
profiles:
|
||||
- profile-2
|
12
tests/integration/seccomp/docker-compose.yml
Normal file
12
tests/integration/seccomp/docker-compose.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
version: "3"
|
||||
services:
|
||||
web1:
|
||||
image: busybox
|
||||
command: httpd -f -p 80 -h /var/www/html
|
||||
volumes:
|
||||
- ./docker-compose.yml:/var/www/html/index.html
|
||||
ports:
|
||||
- "8080:80"
|
||||
security_opt:
|
||||
- seccomp:unconfined
|
||||
|
@@ -0,0 +1,18 @@
|
||||
version: "3.8"
|
||||
services:
|
||||
test:
|
||||
image: busybox
|
||||
command:
|
||||
- cat
|
||||
- /run/secrets/new_secret
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
secrets:
|
||||
- new_secret
|
||||
|
||||
secrets:
|
||||
new_secret:
|
||||
external: true
|
||||
name: my_secret
|
||||
|
@@ -0,0 +1,18 @@
|
||||
version: "3.8"
|
||||
services:
|
||||
test:
|
||||
image: busybox
|
||||
command:
|
||||
- cat
|
||||
- /run/secrets/my_secret_2
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
secrets:
|
||||
- source: my_secret
|
||||
target: new_secret
|
||||
|
||||
secrets:
|
||||
my_secret:
|
||||
external: true
|
||||
|
48
tests/integration/secrets/docker-compose.yaml
Normal file
48
tests/integration/secrets/docker-compose.yaml
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
# echo "sec" | podman secret create my_secret -
|
||||
# echo "sec2" | podman secret create my_secret_2 -
|
||||
# echo "sec3" | podman secret create my_secret_3 -
|
||||
version: "3.8"
|
||||
services:
|
||||
test:
|
||||
image: busybox
|
||||
command:
|
||||
- /tmp/print_secrets.sh
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
volumes:
|
||||
- ./print_secrets.sh:/tmp/print_secrets.sh:z
|
||||
secrets:
|
||||
- my_secret
|
||||
- my_secret_2
|
||||
- source: my_secret_3
|
||||
target: my_secret_3
|
||||
uid: '103'
|
||||
gid: '103'
|
||||
mode: 400
|
||||
- file_secret
|
||||
- source: file_secret
|
||||
target: custom_name
|
||||
- source: file_secret
|
||||
target: /etc/custom_location
|
||||
- source: file_secret
|
||||
target: unused_params_warning
|
||||
uid: '103'
|
||||
gid: '103'
|
||||
mode: 400
|
||||
- source: my_secret
|
||||
target: ENV_SECRET
|
||||
type: env
|
||||
|
||||
secrets:
|
||||
my_secret:
|
||||
external: true
|
||||
my_secret_2:
|
||||
external: true
|
||||
name: my_secret_2
|
||||
my_secret_3:
|
||||
external: true
|
||||
name: my_secret_3
|
||||
file_secret:
|
||||
file: ./my_secret
|
1
tests/integration/secrets/my_secret
Normal file
1
tests/integration/secrets/my_secret
Normal file
@@ -0,0 +1 @@
|
||||
important-secret-is-important
|
7
tests/integration/secrets/print_secrets.sh
Executable file
7
tests/integration/secrets/print_secrets.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
ls -la /run/secrets/*
|
||||
ls -la /etc/custom_location
|
||||
cat /run/secrets/*
|
||||
cat /etc/custom_location
|
||||
env | grep SECRET
|
14
tests/integration/selinux/docker-compose.yml
Normal file
14
tests/integration/selinux/docker-compose.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
version: "3"
|
||||
services:
|
||||
web1:
|
||||
image: busybox
|
||||
command: httpd -f -p 80 -h /var/www/html
|
||||
volumes:
|
||||
- type: bind
|
||||
source: ./docker-compose.yml
|
||||
target: /var/www/html/index.html
|
||||
bind:
|
||||
selinux: z
|
||||
ports:
|
||||
- "8080:80"
|
||||
|
0
tests/integration/short/data/redis/.keep
Normal file
0
tests/integration/short/data/redis/.keep
Normal file
0
tests/integration/short/data/web/.keep
Normal file
0
tests/integration/short/data/web/.keep
Normal file
40
tests/integration/short/docker-compose.yaml
Normal file
40
tests/integration/short/docker-compose.yaml
Normal file
@@ -0,0 +1,40 @@
|
||||
version: "3"
|
||||
services:
|
||||
redis:
|
||||
image: redis:alpine
|
||||
command: ["redis-server", "--appendonly yes", "--notify-keyspace-events", "Ex"]
|
||||
volumes:
|
||||
- ./data/redis:/data:z
|
||||
tmpfs: /run1
|
||||
ports:
|
||||
- "6379"
|
||||
environment:
|
||||
- SECRET_KEY=aabbcc
|
||||
- ENV_IS_SET
|
||||
web:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8000"]
|
||||
working_dir: /var/www/html
|
||||
volumes:
|
||||
- /var/www/html
|
||||
tmpfs:
|
||||
- /run
|
||||
- /tmp
|
||||
web1:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
|
||||
working_dir: /var/www/html
|
||||
volumes:
|
||||
- ./data/web:/var/www/html:ro,z
|
||||
web2:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8002"]
|
||||
working_dir: /var/www/html
|
||||
volumes:
|
||||
- ~/Downloads/www:/var/www/html:ro,z
|
||||
web3:
|
||||
image: busybox
|
||||
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8003"]
|
||||
working_dir: /var/www/html
|
||||
volumes:
|
||||
- /var/www/html:/var/www/html:ro,z
|
111
tests/integration/test_podman_compose.py
Normal file
111
tests/integration/test_podman_compose.py
Normal file
@@ -0,0 +1,111 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from .test_utils import RunSubprocessMixin
|
||||
|
||||
|
||||
def base_path():
|
||||
"""Returns the base path for the project"""
|
||||
return Path(__file__).parent.parent.parent
|
||||
|
||||
|
||||
def test_path():
|
||||
"""Returns the path to the tests directory"""
|
||||
return os.path.join(base_path(), "tests/integration")
|
||||
|
||||
|
||||
def podman_compose_path():
|
||||
"""Returns the path to the podman compose script"""
|
||||
return os.path.join(base_path(), "podman_compose.py")
|
||||
|
||||
|
||||
class TestPodmanCompose(unittest.TestCase, RunSubprocessMixin):
|
||||
def test_extends_w_file_subdir(self):
|
||||
"""
|
||||
Test that podman-compose can execute podman-compose -f <file> up with extended File which
|
||||
includes a build context
|
||||
:return:
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
|
||||
command_up = [
|
||||
"coverage",
|
||||
"run",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "extends_w_file_subdir", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
command_check_container = [
|
||||
"coverage",
|
||||
"run",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "extends_w_file_subdir", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"ps",
|
||||
"--format",
|
||||
'{{.Image}}',
|
||||
]
|
||||
|
||||
self.run_subprocess_assert_returncode(command_up)
|
||||
# check container was created and exists
|
||||
out, _ = self.run_subprocess_assert_returncode(command_check_container)
|
||||
self.assertEqual(out, b'localhost/subdir_test:me\n')
|
||||
# cleanup test image(tags)
|
||||
self.run_subprocess_assert_returncode([
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "extends_w_file_subdir", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"down",
|
||||
])
|
||||
|
||||
self.run_subprocess_assert_returncode([
|
||||
"podman",
|
||||
"rmi",
|
||||
"--force",
|
||||
"localhost/subdir_test:me",
|
||||
])
|
||||
|
||||
# check container did not exists anymore
|
||||
out, _ = self.run_subprocess_assert_returncode(command_check_container)
|
||||
self.assertEqual(out, b'')
|
||||
|
||||
def test_extends_w_empty_service(self):
|
||||
"""
|
||||
Test that podman-compose can execute podman-compose -f <file> up with extended File which
|
||||
includes an empty service. (e.g. if the file is used as placeholder for more complex
|
||||
configurations.)
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
|
||||
command_up = [
|
||||
"python3",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "extends_w_empty_service", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
self.run_subprocess_assert_returncode(command_up)
|
44
tests/integration/test_podman_compose_additional_contexts.py
Normal file
44
tests/integration/test_podman_compose_additional_contexts.py
Normal file
@@ -0,0 +1,44 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
|
||||
"""Test how additional contexts are passed to podman."""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import unittest
|
||||
|
||||
from .test_podman_compose import podman_compose_path
|
||||
from .test_podman_compose import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
||||
""" "Returns the path to the compose file used for this test module"""
|
||||
return os.path.join(test_path(), "additional_contexts", "project")
|
||||
|
||||
|
||||
class TestComposeBuildAdditionalContexts(unittest.TestCase):
|
||||
def test_build_additional_context(self):
|
||||
"""podman build should receive additional contexts as --build-context
|
||||
|
||||
See additional_context/project/docker-compose.yaml for context paths
|
||||
"""
|
||||
cmd = (
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"--dry-run",
|
||||
"--verbose",
|
||||
"-f",
|
||||
os.path.join(compose_yaml_path(), "docker-compose.yml"),
|
||||
"build",
|
||||
)
|
||||
p = subprocess.run(
|
||||
cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
check=False,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True,
|
||||
)
|
||||
self.assertEqual(p.returncode, 0)
|
||||
self.assertIn("--build-context=data=../data_for_dict", p.stdout)
|
||||
self.assertIn("--build-context=data=../data_for_list", p.stdout)
|
90
tests/integration/test_podman_compose_build_secrets.py
Normal file
90
tests/integration/test_podman_compose_build_secrets.py
Normal file
@@ -0,0 +1,90 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
|
||||
"""Test how secrets in files are passed to podman."""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import unittest
|
||||
|
||||
from .test_podman_compose import podman_compose_path
|
||||
from .test_podman_compose import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
||||
""" "Returns the path to the compose file used for this test module"""
|
||||
return os.path.join(test_path(), "build_secrets")
|
||||
|
||||
|
||||
class TestComposeBuildSecrets(unittest.TestCase):
|
||||
def test_run_secret(self):
|
||||
"""podman run should receive file secrets as --volume
|
||||
|
||||
See build_secrets/docker-compose.yaml for secret names and mount points (aka targets)
|
||||
|
||||
"""
|
||||
cmd = (
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"--dry-run",
|
||||
"--verbose",
|
||||
"-f",
|
||||
os.path.join(compose_yaml_path(), "docker-compose.yaml"),
|
||||
"run",
|
||||
"test",
|
||||
)
|
||||
p = subprocess.run(
|
||||
cmd, stdout=subprocess.PIPE, check=False, stderr=subprocess.STDOUT, text=True
|
||||
)
|
||||
self.assertEqual(p.returncode, 0)
|
||||
secret_path = os.path.join(compose_yaml_path(), "my_secret")
|
||||
self.assertIn(f"--volume {secret_path}:/run/secrets/run_secret:ro,rprivate,rbind", p.stdout)
|
||||
self.assertIn(f"--volume {secret_path}:/tmp/run_secret2:ro,rprivate,rbind", p.stdout)
|
||||
|
||||
def test_build_secret(self):
|
||||
"""podman build should receive secrets as --secret, so that they can be used inside the
|
||||
Dockerfile in "RUN --mount=type=secret ..." commands.
|
||||
|
||||
"""
|
||||
cmd = (
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"--dry-run",
|
||||
"--verbose",
|
||||
"-f",
|
||||
os.path.join(compose_yaml_path(), "docker-compose.yaml"),
|
||||
"build",
|
||||
)
|
||||
p = subprocess.run(
|
||||
cmd, stdout=subprocess.PIPE, check=False, stderr=subprocess.STDOUT, text=True
|
||||
)
|
||||
self.assertEqual(p.returncode, 0)
|
||||
secret_path = os.path.join(compose_yaml_path(), "my_secret")
|
||||
self.assertIn(f"--secret id=build_secret,src={secret_path}", p.stdout)
|
||||
self.assertIn(f"--secret id=build_secret2,src={secret_path}", p.stdout)
|
||||
|
||||
def test_invalid_build_secret(self):
|
||||
"""build secrets in docker-compose file can only have a target argument without directory
|
||||
component
|
||||
|
||||
"""
|
||||
cmd = (
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"--dry-run",
|
||||
"--verbose",
|
||||
"-f",
|
||||
os.path.join(compose_yaml_path(), "docker-compose.yaml.invalid"),
|
||||
"build",
|
||||
)
|
||||
p = subprocess.run(
|
||||
cmd, stdout=subprocess.PIPE, check=False, stderr=subprocess.STDOUT, text=True
|
||||
)
|
||||
self.assertNotEqual(p.returncode, 0)
|
||||
self.assertIn(
|
||||
'ValueError: ERROR: Build secret "build_secret" has invalid target "/build_secret"',
|
||||
p.stdout,
|
||||
)
|
93
tests/integration/test_podman_compose_build_ulimits.py
Normal file
93
tests/integration/test_podman_compose_build_ulimits.py
Normal file
@@ -0,0 +1,93 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
|
||||
"""Test how ulimits are applied in podman-compose build."""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import unittest
|
||||
|
||||
from .test_podman_compose import podman_compose_path
|
||||
from .test_podman_compose import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
||||
""" "Returns the path to the compose file used for this test module"""
|
||||
return os.path.join(test_path(), "ulimit_build")
|
||||
|
||||
|
||||
class TestComposeBuildUlimits(unittest.TestCase):
|
||||
def test_build_ulimits_ulimit1(self):
|
||||
"""podman build should receive and apply limits when building service ulimit1"""
|
||||
|
||||
cmd = (
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"--verbose",
|
||||
"-f",
|
||||
os.path.join(compose_yaml_path(), "docker-compose.yaml"),
|
||||
"build",
|
||||
"--no-cache",
|
||||
"ulimit1",
|
||||
)
|
||||
p = subprocess.run(
|
||||
cmd, stdout=subprocess.PIPE, check=False, stderr=subprocess.STDOUT, text=True
|
||||
)
|
||||
|
||||
self.assertEqual(p.returncode, 0)
|
||||
self.assertIn("--ulimit nofile=1001", p.stdout)
|
||||
self.assertIn("soft nofile limit: 1001", p.stdout)
|
||||
self.assertIn("hard nofile limit: 1001", p.stdout)
|
||||
|
||||
def test_build_ulimits_ulimit2(self):
|
||||
"""podman build should receive and apply limits when building service ulimit2"""
|
||||
|
||||
cmd = (
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"--verbose",
|
||||
"-f",
|
||||
os.path.join(compose_yaml_path(), "docker-compose.yaml"),
|
||||
"build",
|
||||
"--no-cache",
|
||||
"ulimit2",
|
||||
)
|
||||
p = subprocess.run(
|
||||
cmd, stdout=subprocess.PIPE, check=False, stderr=subprocess.STDOUT, text=True
|
||||
)
|
||||
|
||||
self.assertEqual(p.returncode, 0)
|
||||
self.assertIn("--ulimit nofile=1002", p.stdout)
|
||||
self.assertIn("--ulimit nproc=1002:2002", p.stdout)
|
||||
self.assertIn("soft process limit: 1002", p.stdout)
|
||||
self.assertIn("hard process limit: 2002", p.stdout)
|
||||
self.assertIn("soft nofile limit: 1002", p.stdout)
|
||||
self.assertIn("hard nofile limit: 1002", p.stdout)
|
||||
|
||||
def test_build_ulimits_ulimit3(self):
|
||||
"""podman build should receive and apply limits when building service ulimit3"""
|
||||
|
||||
cmd = (
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"--verbose",
|
||||
"-f",
|
||||
os.path.join(compose_yaml_path(), "docker-compose.yaml"),
|
||||
"build",
|
||||
"--no-cache",
|
||||
"ulimit3",
|
||||
)
|
||||
p = subprocess.run(
|
||||
cmd, stdout=subprocess.PIPE, check=False, stderr=subprocess.STDOUT, text=True
|
||||
)
|
||||
|
||||
self.assertEqual(p.returncode, 0)
|
||||
self.assertIn("--ulimit nofile=1003", p.stdout)
|
||||
self.assertIn("--ulimit nproc=1003:2003", p.stdout)
|
||||
self.assertIn("soft process limit: 1003", p.stdout)
|
||||
self.assertIn("hard process limit: 2003", p.stdout)
|
||||
self.assertIn("soft nofile limit: 1003", p.stdout)
|
||||
self.assertIn("hard nofile limit: 1003", p.stdout)
|
82
tests/integration/test_podman_compose_config.py
Normal file
82
tests/integration/test_podman_compose_config.py
Normal file
@@ -0,0 +1,82 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
"""
|
||||
test_podman_compose_config.py
|
||||
|
||||
Tests the podman-compose config command which is used to return defined compose services.
|
||||
"""
|
||||
|
||||
# pylint: disable=redefined-outer-name
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from parameterized import parameterized
|
||||
|
||||
from .test_podman_compose import podman_compose_path
|
||||
from .test_podman_compose import test_path
|
||||
from .test_utils import RunSubprocessMixin
|
||||
|
||||
|
||||
def profile_compose_file():
|
||||
""" "Returns the path to the `profile` compose file used for this test module"""
|
||||
return os.path.join(test_path(), "profile", "docker-compose.yml")
|
||||
|
||||
|
||||
class TestComposeConfig(unittest.TestCase, RunSubprocessMixin):
|
||||
def test_config_no_profiles(self):
|
||||
"""
|
||||
Tests podman-compose config command without profile enablement.
|
||||
"""
|
||||
config_cmd = [
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
profile_compose_file(),
|
||||
"config",
|
||||
]
|
||||
|
||||
out, _ = self.run_subprocess_assert_returncode(config_cmd)
|
||||
|
||||
string_output = out.decode("utf-8")
|
||||
self.assertIn("default-service", string_output)
|
||||
self.assertNotIn("service-1", string_output)
|
||||
self.assertNotIn("service-2", string_output)
|
||||
|
||||
@parameterized.expand(
|
||||
[
|
||||
(
|
||||
["--profile", "profile-1", "config"],
|
||||
{"default-service": True, "service-1": True, "service-2": False},
|
||||
),
|
||||
(
|
||||
["--profile", "profile-2", "config"],
|
||||
{"default-service": True, "service-1": False, "service-2": True},
|
||||
),
|
||||
(
|
||||
["--profile", "profile-1", "--profile", "profile-2", "config"],
|
||||
{"default-service": True, "service-1": True, "service-2": True},
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_config_profiles(self, profiles, expected_services):
|
||||
"""
|
||||
Tests podman-compose
|
||||
:param profiles: The enabled profiles for the parameterized test.
|
||||
:param expected_services: Dictionary used to model the expected "enabled" services in the
|
||||
profile. Key = service name, Value = True if the service is enabled, otherwise False.
|
||||
"""
|
||||
config_cmd = ["coverage", "run", podman_compose_path(), "-f", profile_compose_file()]
|
||||
config_cmd.extend(profiles)
|
||||
|
||||
out, _ = self.run_subprocess_assert_returncode(config_cmd)
|
||||
|
||||
actual_output = out.decode("utf-8")
|
||||
|
||||
self.assertEqual(len(expected_services), 3)
|
||||
|
||||
actual_services = {}
|
||||
for service, _ in expected_services.items():
|
||||
actual_services[service] = service in actual_output
|
||||
|
||||
self.assertEqual(expected_services, actual_services)
|
486
tests/integration/test_podman_compose_in_pod.py
Normal file
486
tests/integration/test_podman_compose_in_pod.py
Normal file
@@ -0,0 +1,486 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from .test_utils import RunSubprocessMixin
|
||||
|
||||
|
||||
def base_path():
|
||||
"""Returns the base path for the project"""
|
||||
return Path(__file__).parent.parent.parent
|
||||
|
||||
|
||||
def test_path():
|
||||
"""Returns the path to the tests directory"""
|
||||
return os.path.join(base_path(), "tests/integration")
|
||||
|
||||
|
||||
def podman_compose_path():
|
||||
"""Returns the path to the podman compose script"""
|
||||
return os.path.join(base_path(), "podman_compose.py")
|
||||
|
||||
|
||||
# If a compose file has userns_mode set, setting in_pod to True, results in error.
|
||||
# Default in_pod setting is True, unless compose file provides otherwise.
|
||||
# Compose file provides custom in_pod option, which can be overridden by command line in_pod option.
|
||||
# Test all combinations of command line argument in_pod and compose file argument in_pod.
|
||||
class TestPodmanComposeInPod(unittest.TestCase, RunSubprocessMixin):
|
||||
# compose file provides x-podman in_pod=false
|
||||
def test_x_podman_in_pod_false_command_line_in_pod_not_exists(self):
|
||||
"""
|
||||
Test that podman-compose will not create a pod, when x-podman in_pod=false and command line
|
||||
does not provide this option
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
|
||||
command_up = [
|
||||
"python3",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "in_pod", "custom_x-podman_false", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
down_cmd = [
|
||||
"python3",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "in_pod", "custom_x-podman_false", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"down",
|
||||
]
|
||||
|
||||
try:
|
||||
self.run_subprocess_assert_returncode(command_up)
|
||||
|
||||
finally:
|
||||
self.run_subprocess_assert_returncode(down_cmd)
|
||||
command_rm_pod = ["podman", "pod", "rm", "pod_custom_x-podman_false"]
|
||||
# throws an error, can not actually find this pod because it was not created
|
||||
self.run_subprocess_assert_returncode(command_rm_pod, expected_returncode=1)
|
||||
|
||||
def test_x_podman_in_pod_false_command_line_in_pod_true(self):
|
||||
"""
|
||||
Test that podman-compose does not allow pod creating even with command line in_pod=True
|
||||
when --userns and --pod are set together: throws an error
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
|
||||
# FIXME: creates a pod anyway, although it should not
|
||||
command_up = [
|
||||
"python3",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"--in-pod=True",
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "in_pod", "custom_x-podman_false", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
try:
|
||||
out, err = self.run_subprocess_assert_returncode(command_up)
|
||||
self.assertEqual(b"Error: --userns and --pod cannot be set together" in err, True)
|
||||
|
||||
finally:
|
||||
command_rm_pod = ["podman", "pod", "rm", "pod_custom_x-podman_false"]
|
||||
# should throw an error of not being able to find this pod (because it should not have
|
||||
# been created) and have expected_returncode=1 (see FIXME above)
|
||||
self.run_subprocess_assert_returncode(command_rm_pod)
|
||||
|
||||
def test_x_podman_in_pod_false_command_line_in_pod_false(self):
|
||||
"""
|
||||
Test that podman-compose will not create a pod as command line sets in_pod=False
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
|
||||
command_up = [
|
||||
"python3",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"--in-pod=False",
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "in_pod", "custom_x-podman_false", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
down_cmd = [
|
||||
"python3",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "in_pod", "custom_x-podman_false", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"down",
|
||||
]
|
||||
|
||||
try:
|
||||
self.run_subprocess_assert_returncode(command_up)
|
||||
|
||||
finally:
|
||||
self.run_subprocess_assert_returncode(down_cmd)
|
||||
command_rm_pod = ["podman", "pod", "rm", "pod_custom_x-podman_false"]
|
||||
# can not actually find this pod because it was not created
|
||||
self.run_subprocess_assert_returncode(command_rm_pod, 1)
|
||||
|
||||
def test_x_podman_in_pod_false_command_line_in_pod_empty_string(self):
|
||||
"""
|
||||
Test that podman-compose will not create a pod, when x-podman in_pod=false and command line
|
||||
command line in_pod=""
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
|
||||
command_up = [
|
||||
"python3",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"--in-pod=",
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "in_pod", "custom_x-podman_false", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
down_cmd = [
|
||||
"python3",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "in_pod", "custom_x-podman_false", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"down",
|
||||
]
|
||||
|
||||
try:
|
||||
self.run_subprocess_assert_returncode(command_up)
|
||||
|
||||
finally:
|
||||
self.run_subprocess_assert_returncode(down_cmd)
|
||||
command_rm_pod = ["podman", "pod", "rm", "pod_custom_x-podman_false"]
|
||||
# can not actually find this pod because it was not created
|
||||
self.run_subprocess_assert_returncode(command_rm_pod, 1)
|
||||
|
||||
# compose file provides x-podman in_pod=true
|
||||
def test_x_podman_in_pod_true_command_line_in_pod_not_exists(self):
|
||||
"""
|
||||
Test that podman-compose does not allow pod creating when --userns and --pod are set
|
||||
together even when x-podman in_pod=true: throws an error
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
|
||||
# FIXME: creates a pod anyway, although it should not
|
||||
# Container is not created, so command 'down' is not needed
|
||||
command_up = [
|
||||
"python3",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "in_pod", "custom_x-podman_true", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
try:
|
||||
out, err = self.run_subprocess_assert_returncode(command_up)
|
||||
self.assertEqual(b"Error: --userns and --pod cannot be set together" in err, True)
|
||||
|
||||
finally:
|
||||
command_rm_pod = ["podman", "pod", "rm", "pod_custom_x-podman_true"]
|
||||
# should throw an error of not being able to find this pod (it should not have been
|
||||
# created) and have expected_returncode=1 (see FIXME above)
|
||||
self.run_subprocess_assert_returncode(command_rm_pod)
|
||||
|
||||
def test_x_podman_in_pod_true_command_line_in_pod_true(self):
|
||||
"""
|
||||
Test that podman-compose does not allow pod creating when --userns and --pod are set
|
||||
together even when x-podman in_pod=true and and command line in_pod=True: throws an error
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
|
||||
# FIXME: creates a pod anyway, although it should not
|
||||
# Container is not created, so command 'down' is not needed
|
||||
command_up = [
|
||||
"python3",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"--in-pod=True",
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "in_pod", "custom_x-podman_true", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
try:
|
||||
out, err = self.run_subprocess_assert_returncode(command_up)
|
||||
self.assertEqual(b"Error: --userns and --pod cannot be set together" in err, True)
|
||||
|
||||
finally:
|
||||
command_rm_pod = ["podman", "pod", "rm", "pod_custom_x-podman_true"]
|
||||
# should throw an error of not being able to find this pod (because it should not have
|
||||
# been created) and have expected_returncode=1 (see FIXME above)
|
||||
self.run_subprocess_assert_returncode(command_rm_pod)
|
||||
|
||||
def test_x_podman_in_pod_true_command_line_in_pod_false(self):
|
||||
"""
|
||||
Test that podman-compose will not create a pod as command line sets in_pod=False
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
|
||||
command_up = [
|
||||
"python3",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"--in-pod=False",
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "in_pod", "custom_x-podman_true", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
down_cmd = [
|
||||
"python3",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "in_pod", "custom_x-podman_true", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"down",
|
||||
]
|
||||
|
||||
try:
|
||||
self.run_subprocess_assert_returncode(command_up)
|
||||
|
||||
finally:
|
||||
self.run_subprocess_assert_returncode(down_cmd)
|
||||
command_rm_pod = ["podman", "pod", "rm", "pod_custom_x-podman_false"]
|
||||
# can not actually find this pod because it was not created
|
||||
self.run_subprocess_assert_returncode(command_rm_pod, 1)
|
||||
|
||||
def test_x_podman_in_pod_true_command_line_in_pod_empty_string(self):
|
||||
"""
|
||||
Test that podman-compose does not allow pod creating when --userns and --pod are set
|
||||
together even when x-podman in_pod=true and command line in_pod="": throws an error
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
|
||||
# FIXME: creates a pod anyway, although it should not
|
||||
# Container is not created, so command 'down' is not needed
|
||||
command_up = [
|
||||
"python3",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"--in-pod=",
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "in_pod", "custom_x-podman_true", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
try:
|
||||
out, err = self.run_subprocess_assert_returncode(command_up)
|
||||
self.assertEqual(b"Error: --userns and --pod cannot be set together" in err, True)
|
||||
|
||||
finally:
|
||||
command_rm_pod = ["podman", "pod", "rm", "pod_custom_x-podman_true"]
|
||||
# should throw an error of not being able to find this pod (because it should not have
|
||||
# been created) and have expected_returncode=1 (see FIXME above)
|
||||
self.run_subprocess_assert_returncode(command_rm_pod)
|
||||
|
||||
# compose file does not provide x-podman in_pod
|
||||
def test_x_podman_in_pod_not_exists_command_line_in_pod_not_exists(self):
|
||||
"""
|
||||
Test that podman-compose does not allow pod creating when --userns and --pod are set
|
||||
together: throws an error
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
|
||||
# FIXME: creates a pod anyway, although it should not
|
||||
# Container is not created, so command 'down' is not needed
|
||||
command_up = [
|
||||
"python3",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests",
|
||||
"integration",
|
||||
"in_pod",
|
||||
"custom_x-podman_not_exists",
|
||||
"docker-compose.yml",
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
try:
|
||||
out, err = self.run_subprocess_assert_returncode(command_up)
|
||||
self.assertEqual(b"Error: --userns and --pod cannot be set together" in err, True)
|
||||
|
||||
finally:
|
||||
command_rm_pod = ["podman", "pod", "rm", "pod_custom_x-podman_not_exists"]
|
||||
# should throw an error of not being able to find this pod (it should not have been
|
||||
# created) and have expected_returncode=1 (see FIXME above)
|
||||
self.run_subprocess_assert_returncode(command_rm_pod)
|
||||
|
||||
def test_x_podman_in_pod_not_exists_command_line_in_pod_true(self):
|
||||
"""
|
||||
Test that podman-compose does not allow pod creating when --userns and --pod are set
|
||||
together even when x-podman in_pod=true: throws an error
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
|
||||
# FIXME: creates a pod anyway, although it should not
|
||||
# Container was not created, so command 'down' is not needed
|
||||
command_up = [
|
||||
"python3",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"--in-pod=True",
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests",
|
||||
"integration",
|
||||
"in_pod",
|
||||
"custom_x-podman_not_exists",
|
||||
"docker-compose.yml",
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
try:
|
||||
out, err = self.run_subprocess_assert_returncode(command_up)
|
||||
self.assertEqual(b"Error: --userns and --pod cannot be set together" in err, True)
|
||||
|
||||
finally:
|
||||
command_rm_pod = ["podman", "pod", "rm", "pod_custom_x-podman_not_exists"]
|
||||
# should throw an error of not being able to find this pod (because it should not have
|
||||
# been created) and have expected_returncode=1 (see FIXME above)
|
||||
self.run_subprocess_assert_returncode(command_rm_pod)
|
||||
|
||||
def test_x_podman_in_pod_not_exists_command_line_in_pod_false(self):
|
||||
"""
|
||||
Test that podman-compose will not create a pod as command line sets in_pod=False
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
|
||||
command_up = [
|
||||
"python3",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"--in-pod=False",
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests",
|
||||
"integration",
|
||||
"in_pod",
|
||||
"custom_x-podman_not_exists",
|
||||
"docker-compose.yml",
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
down_cmd = [
|
||||
"python3",
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests",
|
||||
"integration",
|
||||
"in_pod",
|
||||
"custom_x-podman_not_exists",
|
||||
"docker-compose.yml",
|
||||
)
|
||||
),
|
||||
"down",
|
||||
]
|
||||
|
||||
try:
|
||||
self.run_subprocess_assert_returncode(command_up)
|
||||
|
||||
finally:
|
||||
self.run_subprocess_assert_returncode(down_cmd)
|
||||
|
||||
command_rm_pod = ["podman", "pod", "rm", "pod_custom_x-podman_not_exists"]
|
||||
# can not actually find this pod because it was not created
|
||||
self.run_subprocess_assert_returncode(command_rm_pod, 1)
|
||||
|
||||
def test_x_podman_in_pod_not_exists_command_line_in_pod_empty_string(self):
|
||||
"""
|
||||
Test that podman-compose does not allow pod creating when --userns and --pod are set
|
||||
together: throws an error
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
|
||||
# FIXME: creates a pod anyway, although it should not
|
||||
# Container was not created, so command 'down' is not needed
|
||||
command_up = [
|
||||
"python3",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"--in-pod=",
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests",
|
||||
"integration",
|
||||
"in_pod",
|
||||
"custom_x-podman_not_exists",
|
||||
"docker-compose.yml",
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
try:
|
||||
out, err = self.run_subprocess_assert_returncode(command_up)
|
||||
self.assertEqual(b"Error: --userns and --pod cannot be set together" in err, True)
|
||||
|
||||
finally:
|
||||
command_rm_pod = ["podman", "pod", "rm", "pod_custom_x-podman_not_exists"]
|
||||
# should throw an error of not being able to find this pod (because it should not have
|
||||
# been created) and have expected_returncode=1 (see FIXME above)
|
||||
self.run_subprocess_assert_returncode(command_rm_pod)
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user