1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-05-05 15:15:01 +00:00

Add tests for idempotency (#53)

This commit is contained in:
Sergey 2020-06-01 02:04:04 +03:00 committed by GitHub
parent 6256a082bd
commit 2635eab02e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 1255 additions and 6 deletions

View file

@ -75,7 +75,7 @@ jobs:
~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
sudo ~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
- name: Run collection tests for connection
- name: Run collection tests for podman container
run: |
export PATH=~/.local/bin:$PATH

View file

@ -75,7 +75,7 @@ jobs:
~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
sudo ~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
- name: Run collection tests for connection
- name: Run collection tests for podman container info
run: |
export PATH=~/.local/bin:$PATH

View file

@ -75,7 +75,7 @@ jobs:
~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
sudo ~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
- name: Run collection tests for connection
- name: Run collection tests for podman image
run: |
export PATH=~/.local/bin:$PATH

View file

@ -75,7 +75,7 @@ jobs:
~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
sudo ~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
- name: Run collection tests for connection
- name: Run collection tests for podman image info
run: |
export PATH=~/.local/bin:$PATH

View file

@ -73,7 +73,7 @@ jobs:
~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
sudo ~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
- name: Run collection tests for connection
- name: Run collection tests for podman network info
run: |
export PATH=~/.local/bin:$PATH

View file

@ -73,7 +73,7 @@ jobs:
~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
sudo ~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
- name: Run collection tests for connection
- name: Run collection tests for podman volume info
run: |
export PATH=~/.local/bin:$PATH

View file

@ -4,3 +4,5 @@
tasks:
- include_role:
name: podman_container
vars:
idem_image: idempotency_test

View file

@ -0,0 +1,32 @@
FROM alpine
LABEL "key"="amazing value"
LABEL nobody=cares
ARG build_arg
ENV password root
ENV username root
RUN adduser -D user && \
adduser -D user2
COPY start.sh /start
RUN chmod a+rwx /start
EXPOSE 80
EXPOSE 8080/tcp
VOLUME ["/data"]
USER user
WORKDIR /work
STOPSIGNAL 9
# problem with OS w/o systemd
# HEALTHCHECK --interval=5m --timeout=3s \
# CMD date
CMD ["1d"]
ENTRYPOINT ["/start"]

View file

@ -0,0 +1,5 @@
#!/bin/sh
s=${1:-"3h"}
sleep "$s"

View file

@ -0,0 +1,29 @@
---
- name: Create directory for user build images
file:
path: /tmp/usr_img
state: directory
- name: Copy files to container build directory
copy:
src: "{{ item }}"
dest: "/tmp/usr_img/{{ item }}"
mode: 777
loop:
- Dockerfile
- start.sh
- name: Build test docker image for regular user
containers.podman.podman_image:
name: "{{ idem_image }}"
path: /tmp/usr_img
build:
format: docker
- name: Build test docker image for root user
containers.podman.podman_image:
name: "{{ idem_image }}"
path: /tmp/usr_img
build:
format: docker
become: true

View file

@ -0,0 +1,179 @@
# Labels
- containers.podman.podman_container:
name: idempotency
state: absent
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test1
- name: check test1
assert:
that: test1 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
label:
key: "amazing value"
nobody: "cares"
command: 1h
register: test2
- name: check test2
assert:
that: test2 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test3
- name: check test3
assert:
that: test3 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
label:
haha: kukuku
llala: wiwiwiw
command: 1h
register: test4
- name: check test4
assert:
that: test4 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
label:
haha: kukuku
llala: wiwiwiw
command: 1h
register: test5
- name: check test5
assert:
that: test5 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test6
- name: check test6
assert:
that: test6 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
label:
test: notest
command: 1h
register: test7
- name: check test7
assert:
that: test7 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
label:
key: "amazing value"
nobody: "cares"
command: 1h
register: test8
- name: check test8
assert:
that: test8 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test9
- name: check test9
assert:
that: test9 is not changed
- containers.podman.podman_container:
name: idempotency1
state: absent
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test10
- name: check test10
assert:
that: test10 is not changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
label:
razraz: dva
command: sleep 1h
register: test11
- name: check test11
assert:
that: test11 is changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test12
- name: check test12
assert:
that: test12 is changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test13
- name: check test13
assert:
that: test13 is not changed

View file

@ -0,0 +1,230 @@
# Ports
- containers.podman.podman_container:
name: idempotency
state: absent
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test1
- name: check test1
assert:
that: test1 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
ports:
- 7777:8080/tcp
- 127.0.0.1:8888:1929
- 127.0.0.1:5555:9000
command: 1h
register: test2
- name: check test2
assert:
that: test2 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
ports:
- 7777:8080/tcp
- 127.0.0.1:8888:1929
- 127.0.0.1:5555:9000
register: test3
- name: check test3
assert:
that: test3 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
publish_all: true
command: 1h
register: test4
- name: check test4
assert:
that: test4 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
publish_all: true
command: 1h
register: test5
- name: check test5
assert:
that: test5 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test6
- name: check test6
assert:
that: test6 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
ports:
- 10000:8080
command: 1h
register: test7
- name: check test7
assert:
that: test7 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
ports:
- 10001:8080
command: 1h
register: test8
- name: check test8
assert:
that: test8 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
ports:
- 10001:8080/tcp
command: 1h
register: test9
- name: check test9
assert:
that: test9 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
ports:
- 10001:8080/tcp
publish_all: false
command: 1h
register: test9a
- name: check test9a
assert:
that: test9a is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test9b
- name: check test9b
assert:
that: test9b is changed
- containers.podman.podman_container:
name: idempotency1
state: absent
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test10
- name: check test10
assert:
that: test10 is not changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
publish_all: false
command: sleep 1h
register: test11
- name: check test11
assert:
that: test11 is not changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
publish_all: true
command: sleep 1h
register: test11a
- name: check test11a
assert:
that: test11a is not changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
ports:
- 10000:8080
command: sleep 1h
register: test12
- name: check test12
assert:
that: test12 is changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test13
- name: check test13
assert:
that: test13 is changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test14
- name: check test14
assert:
that: test14 is not changed

View file

@ -0,0 +1,204 @@
# Stop signal
- containers.podman.podman_container:
name: idempotency
state: absent
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test1
- name: check test1
assert:
that: test1 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
stop_signal: 9
command: 1h
register: test2
- name: check test2
assert:
that: test2 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test3
- name: check test3
assert:
that: test3 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
stop_signal: 10
command: 1h
register: test4
- name: check test4
assert:
that: test4 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
stop_signal: 10
command: 1h
register: test5
- name: check test5
assert:
that: test5 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test6
- name: check test6
assert:
that: test6 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
stop_signal: 15
command: 1h
register: test7
- name: check test7
assert:
that: test7 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
stop_signal: 9
command: 1h
register: test8
- name: check test8
assert:
that: test8 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test9
- name: check test9
assert:
that: test9 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
stop_signal: 15
command: 1h
register: test9a
- name: check test9a
assert:
that: test9a is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test9b
- name: check test9b
assert:
that: test9b is changed
- containers.podman.podman_container:
name: idempotency1
state: absent
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test10
- name: check test10
assert:
that: test10 is not changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
stop_signal: 15
command: sleep 1h
register: test11
- name: check test11
assert:
that: test11 is not changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
stop_signal: 10
command: sleep 1h
register: test12
- name: check test12
assert:
that: test12 is changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test13
- name: check test13
assert:
that: test13 is changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test14
- name: check test14
assert:
that: test14 is not changed

View file

@ -0,0 +1,169 @@
# Users
- containers.podman.podman_container:
name: idempotency
state: absent
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test1
- name: check test1
assert:
that: test1 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
user: user
command: 1h
register: test2
- name: check test2
assert:
that: test2 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test3
- name: check test3
assert:
that: test3 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
user: user2
command: 1h
register: test4
- name: check test4
assert:
that: test4 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
user: user2
command: 1h
register: test5
- name: check test5
assert:
that: test5 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test6
- name: check test6
assert:
that: test6 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
user: user2
command: 1h
register: test7
- name: check test7
assert:
that: test7 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
user: user
command: 1h
register: test8
- name: check test8
assert:
that: test8 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test9
- name: check test9
assert:
that: test9 is not changed
- containers.podman.podman_container:
name: idempotency1
state: absent
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test10
- name: check test10
assert:
that: test10 is not changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
user: nobody
command: sleep 1h
register: test11
- name: check test11
assert:
that: test11 is changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test12
- name: check test12
assert:
that: test12 is changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test13
- name: check test13
assert:
that: test13 is not changed

View file

@ -0,0 +1,174 @@
# Volumes
- containers.podman.podman_container:
name: idempotency
state: absent
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test1
- name: check test1
assert:
that: test1 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test2
- name: check test2
assert:
that: test2 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test3
- name: check test3
assert:
that: test3 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
volumes:
- /opt:/somedir
command: 1h
register: test4
- name: check test4
assert:
that: test4 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
volumes:
- /opt:/somedir
command: 1h
register: test5
- name: check test5
assert:
that: test5 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test6
- name: check test6
assert:
that: test6 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
volumes:
- /opt:/somedir
- /data
command: 1h
register: test7
- name: check test7
assert:
that: test7 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
volumes:
- /data
command: 1h
register: test8
- name: check test8
assert:
that: test8 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test9
- name: check test9
assert:
that: test9 is not changed
- containers.podman.podman_container:
name: idempotency1
state: absent
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test10
- name: check test10
assert:
that: test10 is not changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
volumes:
- /opt:/data
command: sleep 1h
register: test11
- name: check test11
assert:
that: test11 is changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test12
- name: check test12
assert:
that: test12 is changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test13
- name: check test13
assert:
that: test13 is not changed

View file

@ -0,0 +1,204 @@
# Workdir
- containers.podman.podman_container:
name: idempotency
state: absent
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test1
- name: check test1
assert:
that: test1 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
workdir: /work
command: 1h
register: test2
- name: check test2
assert:
that: test2 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test3
- name: check test3
assert:
that: test3 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
workdir: /app
command: 1h
register: test4
- name: check test4
assert:
that: test4 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
workdir: /app
command: 1h
register: test5
- name: check test5
assert:
that: test5 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test6
- name: check test6
assert:
that: test6 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
workdir: /app
command: 1h
register: test7
- name: check test7
assert:
that: test7 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
workdir: /work
command: 1h
register: test8
- name: check test8
assert:
that: test8 is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test9
- name: check test9
assert:
that: test9 is not changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
workdir: /
command: 1h
register: test9a
- name: check test9a
assert:
that: test9a is changed
- containers.podman.podman_container:
image: "{{ idem_image }}"
name: idempotency
state: present
command: 1h
register: test9b
- name: check test9b
assert:
that: test9b is changed
- containers.podman.podman_container:
name: idempotency1
state: absent
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test10
- name: check test10
assert:
that: test10 is not changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
workdir: /
command: sleep 1h
register: test11
- name: check test11
assert:
that: test11 is not changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
workdir: /app
command: sleep 1h
register: test12
- name: check test12
assert:
that: test12 is changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test13
- name: check test13
assert:
that: test13 is changed
- containers.podman.podman_container:
image: alpine
name: idempotency1
state: present
command: sleep 1h
register: test14
- name: check test14
assert:
that: test14 is not changed

View file

@ -433,3 +433,24 @@
- name: Remove pod
shell: podman pod rm -f testidempod
- name: Prepare a container
include_tasks: build_test_container.yml
- name: Test idempotency of users
include_tasks: idem_users.yml
- name: Test idempotency of workdir
include_tasks: idem_workdir.yml
- name: Test idempotency of labels
include_tasks: idem_labels.yml
- name: Test idempotency of stop signal
include_tasks: idem_stopsignal.yml
- name: Test idempotency of ports
include_tasks: idem_ports.yml
- name: Test idempotency of volumes
include_tasks: idem_volumes.yml