1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00

Optimize the podman_runlabel integration test

I used [1] as example.

[1]: https://fossies.org/linux/podman/test/system/037-runlabel.bats

Signed-off-by: Pavel Dostál <pdostal@pdostal.cz>
This commit is contained in:
Pavel Dostál 2023-09-02 13:22:26 +02:00
parent e160458eb6
commit e4d303b4c1
No known key found for this signature in database
GPG key ID: 65BDCDAB70974BA9
5 changed files with 16 additions and 48 deletions

View file

@ -77,7 +77,7 @@ def main():
results = {
"changed": changed,
"stdout": out,
"stderr": err,
"stderr": err
}
module.exit_json(**results)

View file

@ -1,34 +1,6 @@
FROM alpine
LABEL "key"="amazing value"
LABEL nobody=cares
LABEL install="touch /tmp/testedinstallfortests"
LABEL run="touch /tmp/testedrunfortests"
ARG build_arg
ENV password root
ENV username root
WORKDIR /work
RUN adduser -D user && \
adduser -D user2
COPY start.sh /start
RUN chmod a+rwx /start
EXPOSE 80
EXPOSE 8080/tcp
VOLUME ["/data", "/data2"]
USER user
STOPSIGNAL KILL
# problem with OS w/o systemd
# HEALTHCHECK --interval=5m --timeout=3s \
# CMD date
CMD ["1d"]
ENTRYPOINT ["/start"]
LABEL install="podman run --env IMAGE=IMAGE --rm IMAGE /bin/sh /testinstall.sh"
LABEL run="/usr/bin/touch /tmp/testedrunfortests"
ADD testinstall.sh /

View file

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

View file

@ -0,0 +1,2 @@
#!/usr/bin/env bash
echo -n "Installed."

View file

@ -4,14 +4,14 @@
path: /tmp/usr_img
state: directory
- name: Copy files to container build directory
- name: Copy Dockerfile to container build directory
copy:
src: "{{ item }}"
dest: "/tmp/usr_img/{{ item }}"
mode: 777
mode: 755
loop:
- Dockerfile
- start.sh
- testinstall.sh
- name: Build test docker image for regular user
containers.podman.podman_image:
@ -22,21 +22,17 @@
format: docker
extra_args: --cgroup-manager=cgroupfs
- name: Run container runlabel install
- name: Run container label install
containers.podman.podman_runlabel:
image: "{{ runlabel_image }}"
label: install
register: install_runlabel
- name: Run container runlabel run
- name: Run container label run
containers.podman.podman_runlabel:
image: "{{ runlabel_image }}"
label: run
- name: Check file for install exists
stat:
path: /tmp/testedinstallfortests
register: testedinstallfortests
- name: Check file for run exists
stat:
path: /tmp/testedrunfortests
@ -45,5 +41,8 @@
- name: Make sure files exist
assert:
that:
- testedinstallfortests.stat.exists
- testedrunfortests.stat.exists
- name: Make sure install label exited with 128
assert:
that: install_runlabel.stdout == 'Installed.'