Blame tests/p_podman/15_podman_socket_tests.sh
|
Carlos R.F |
55da49 |
#!/bin/bash
|
|
Carlos R.F |
55da49 |
|
|
Carlos R.F |
55da49 |
# Author: Carlos Rodriguez-Fernandez <carlosrodrifernandez@gmail.com>
|
|
Carlos R.F |
55da49 |
|
|
Carlos R.F |
55da49 |
t_Log "Running $0 - podman socket tests"
|
|
Carlos R.F |
55da49 |
|
|
Carlos R.F |
55da49 |
if [ "$centos_ver" -lt 8 ] ; then
|
|
Carlos R.F |
55da49 |
t_Log "SKIP $0: only run on centos stream 8 or greater"
|
|
Carlos R.F |
55da49 |
exit 0
|
|
Carlos R.F |
55da49 |
fi
|
|
Carlos R.F |
55da49 |
|
|
Carlos R.F |
55da49 |
useradd podman-remote-test
|
|
Carlos R.F |
55da49 |
loginctl enable-linger podman-remote-test
|
|
Carlos R.F |
55da49 |
output_file=$(mktemp)
|
|
Carlos R.F |
55da49 |
trap "loginctl terminate-user podman-remote-test && loginctl disable-linger podman-remote-test && sleep 1 && userdel -r podman-remote-test && rm -f ${output_file}" EXIT
|
|
Carlos R.F |
55da49 |
|
|
Carlos Rodriguez-Fernandez |
e5de35 |
# give time to loginctl linger
|
|
Carlos Rodriguez-Fernandez |
e5de35 |
sleep 3
|
|
Carlos Rodriguez-Fernandez |
e5de35 |
|
|
Carlos R.F |
55da49 |
su -l podman-remote-test > ${output_file} 2>&1 <
|
|
Carlos R.F |
55da49 |
set -e
|
|
Carlos R.F |
55da49 |
export XDG_RUNTIME_DIR=/run/user/\$(id -u)
|
|
Carlos R.F |
55da49 |
systemctl --user enable --now podman.socket
|
|
Carlos R.F |
55da49 |
podman --url unix://run/user/\$(id -u)/podman/podman.sock run --name simple-test-with-port-mapping -d -p 8080:80 docker.io/nginx
|
|
Carlos R.F |
55da49 |
pid=\$(systemctl --user show --property MainPID --value podman.service)
|
|
Carlos R.F |
55da49 |
while [ "\${pid}" -ne 0 ] && [ -d /proc/\${pid} ]; do sleep 1; echo "Waiting for podman to exit"; done
|
|
Carlos R.F |
55da49 |
echo "Continuing"
|
|
Carlos R.F |
55da49 |
podman --url unix://run/user/\$(id -u)/podman/podman.sock ps | grep -q -e simple-test-with-port-mapping
|
|
Carlos R.F |
55da49 |
podman --url unix://run/user/\$(id -u)/podman/podman.sock container rm -f simple-test-with-port-mapping
|
|
Carlos R.F |
55da49 |
systemctl --user disable --now podman.socket
|
|
Carlos R.F |
55da49 |
EOF
|
|
Carlos R.F |
55da49 |
|
|
Carlos R.F |
55da49 |
if [ "$?" -ne 0 ]; then
|
|
Carlos R.F |
55da49 |
cat ${output_file}
|
|
Carlos R.F |
55da49 |
t_CheckExitStatus 1
|
|
Carlos R.F |
55da49 |
fi
|
|
Carlos R.F |
a2e534 |
t_CheckExitStatus 0
|