add actual podman tests, start using trap
This commit is contained in:
parent
f5a4d2f563
commit
3529b7a5e1
@ -2,6 +2,7 @@
|
||||
ACLFILE=/tmp/testfile_acl
|
||||
r_log "acl" "Test that the acl get and set functions work"
|
||||
touch "${ACLFILE}"
|
||||
trap '/bin/rm -f ${ACLFILE}' EXIT
|
||||
|
||||
# Use setfacl for readonly
|
||||
r_log "acl" "Set readonly ACL for the user nobody"
|
||||
@ -12,4 +13,3 @@ r_log "acl" "Verifying that the nobody user is set to read only"
|
||||
getfacl "${ACLFILE}" | grep -q 'user:nobody:r--'
|
||||
|
||||
r_checkExitStatus $?
|
||||
/bin/rm -f "${ACLFILE}"
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/bin/bash
|
||||
r_log "archive" "Test bzip/bzcat/bunzip"
|
||||
FILE=/var/tmp/bziptest.txt
|
||||
trap '/bin/rm -f ${FILE}' EXIT
|
||||
|
||||
cat > "$FILE" <<EOF
|
||||
testing text
|
||||
@ -23,5 +24,3 @@ fi
|
||||
grep -q 'testing text' "${FILE}"
|
||||
|
||||
r_checkExitStatus $?
|
||||
|
||||
/bin/rm -f "${FILE}*"
|
||||
|
@ -4,6 +4,9 @@ r_log "archive" "Test gzip/zcat/gunzip"
|
||||
FILE=/var/tmp/gzip-test.txt
|
||||
MD5HASH=e6331c582fbad6653832860f469f7d1b
|
||||
|
||||
# clean up
|
||||
trap '/bin/rm $FILE* &> /dev/null && /bin/rm -rf /var/tmp/gziptest &> /dev/null' EXIT
|
||||
|
||||
# Double check that stuff is cleared out
|
||||
/bin/rm $FILE* &> /dev/null
|
||||
/bin/rm -rf /var/tmp/gziptest &> /dev/null
|
||||
@ -107,7 +110,3 @@ tar -czf $FILE.tgz $FILE &> /dev/null
|
||||
gunzip $FILE.tgz
|
||||
[ -e $FILE.tar ]
|
||||
r_checkExitStatus $?
|
||||
|
||||
# clean up
|
||||
/bin/rm $FILE* &> /dev/null
|
||||
/bin/rm -rf /var/tmp/gziptest &> /dev/null
|
||||
|
@ -2,6 +2,8 @@
|
||||
r_log "archive" "Checking gzexe"
|
||||
r_log "archive" "Creating archive"
|
||||
FILE=/var/tmp/gzexe-test-script
|
||||
trap '/bin/rm -f $FILE* 2>/dev/null' EXIT
|
||||
|
||||
/bin/rm -f $FILE* &>/dev/null
|
||||
|
||||
cat > $FILE <<EOF
|
||||
@ -18,5 +20,3 @@ r_log "archive" "Test gzexe"
|
||||
r_log "archive" "Check that it actually runs"
|
||||
$FILE | grep -q "Hello!"
|
||||
r_checkExitStatus $?
|
||||
|
||||
/bin/rm -f $FILE* 2>/dev/null
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/bin/bash
|
||||
r_log "archive" "Check zcmp and zdiff"
|
||||
BASEFILE="/var/tmp/gziptest"
|
||||
trap '/bin/rm -f ${BASEFILE}*' EXIT
|
||||
/bin/rm -f ${BASEFILE}
|
||||
|
||||
cat > ${BASEFILE}.1 <<EOF
|
||||
@ -15,5 +16,3 @@ r_log "archive" "Check zcmp"
|
||||
|
||||
r_log "archive" "Check zdiff"
|
||||
/bin/zdiff ${BASEFILE}.1.gz ${BASEFILE}.2.gz || r_checkExitStatus 1
|
||||
|
||||
/bin/rm -f ${BASEFILE}*
|
||||
|
@ -2,6 +2,7 @@
|
||||
r_log "archive" "Testing zforce"
|
||||
|
||||
BASEFILE="/var/tmp/abcdefg"
|
||||
trap '/bin/rm "$BASEFILE.gz"' EXIT
|
||||
/bin/rm $BASEFILE* &>/dev/null
|
||||
|
||||
cat > $BASEFILE <<EOF
|
||||
@ -14,5 +15,3 @@ mv $BASEFILE.gz $BASEFILE
|
||||
zforce $BASEFILE || r_checkExitStatus 1
|
||||
[ -e "$BASEFILE.gz" ]
|
||||
r_checkExitStatus $?
|
||||
|
||||
/bin/rm "$BASEFILE.gz"
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/bin/bash
|
||||
r_log "archive" "Testing zgrep"
|
||||
BASEFILE=/var/tmp/zgreptest
|
||||
trap '/bin/rm $BASEFILE*' EXIT
|
||||
/bin/rm $BASEFILE* &> /dev/null
|
||||
|
||||
cat > $BASEFILE <<EOF
|
||||
@ -11,5 +12,3 @@ gzip $BASEFILE
|
||||
|
||||
zgrep -q 'Green Obsidian' $BASEFILE.gz
|
||||
r_checkExitStatus $?
|
||||
|
||||
/bin/rm $BASEFILE*
|
||||
|
@ -4,6 +4,7 @@ r_log "archive" "Test tar create and extract"
|
||||
TARDIR="/var/tmp/tartest"
|
||||
FILE1="$TARDIR/test.1.txt"
|
||||
FILE2="$TARDIR/test.2.txt"
|
||||
trap '/bin/rm -rf /var/tmp/tarfile.tar $TARDIR' EXIT
|
||||
|
||||
mkdir -p $TARDIR
|
||||
cat > $FILE1 <<EOF
|
||||
@ -32,5 +33,3 @@ if [ $RES1 == 0 ] && [ $RES2 == 0 ]; then
|
||||
fi
|
||||
|
||||
r_checkExitStatus $ret_val
|
||||
|
||||
/bin/rm -rf /var/tmp/tarfile.tar $TARDIR
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/bin/bash
|
||||
r_log "archive" "Check xzcmp and xzdiff"
|
||||
BASEFILE="/var/tmp/xztest"
|
||||
trap '/bin/rm -f ${BASEFILE}*' EXIT
|
||||
/bin/rm -f ${BASEFILE}
|
||||
|
||||
cat > ${BASEFILE}.1 <<EOF
|
||||
@ -15,5 +16,3 @@ r_log "archive" "Check xzcmp"
|
||||
|
||||
r_log "archive" "Check xzdiff"
|
||||
/bin/zdiff ${BASEFILE}.1.xz ${BASEFILE}.2.xz || r_checkExitStatus 1
|
||||
|
||||
/bin/rm -f ${BASEFILE}*
|
||||
|
@ -4,6 +4,7 @@ r_log "archive" "Test zip create and extract"
|
||||
ZIPDIR="/var/tmp/ziptest"
|
||||
FILE1="$ZIPDIR/test.1.txt"
|
||||
FILE2="$ZIPDIR/test.2.txt"
|
||||
trap '/bin/rm -rf /var/tmp/zipfile.zip $ZIPDIR' EXIT
|
||||
|
||||
mkdir -p $ZIPDIR
|
||||
cat > $FILE1 <<EOF
|
||||
@ -31,6 +32,4 @@ if [ $RES1 == 0 ] && [ $RES2 == 0 ]; then
|
||||
ret_val=0
|
||||
fi
|
||||
|
||||
r_checkExitStatus $ret_val
|
||||
|
||||
/bin/rm -rf /var/tmp/zipfile.zip $ZIPDIR
|
||||
r_checkExitStatus "$ret_val"
|
||||
|
@ -2,6 +2,7 @@
|
||||
r_log "archive" "Testing lzop compress and decompress"
|
||||
|
||||
LZOFILE=/var/tmp/obsidian.txt
|
||||
trap '/bin/rm ${LZOFILE}' EXIT
|
||||
|
||||
echo 'Green Obsidian is the release name' > ${LZOFILE}
|
||||
|
||||
@ -13,5 +14,5 @@ lzop -d ${LZOFILE}.lzo -o ${LZOFILE}
|
||||
/bin/rm ${LZOFILE}.lzo
|
||||
|
||||
grep -q 'Green Obsidian' ${LZOFILE}
|
||||
|
||||
/bin/rm ${LZOFILE}
|
||||
ret_val="$?"
|
||||
r_checkExitStatus "$ret_val"
|
||||
|
@ -2,3 +2,31 @@
|
||||
|
||||
r_log "podman" "Testing podman"
|
||||
|
||||
test_to_run=(
|
||||
"podman version"
|
||||
"podman info"
|
||||
"podman run --rm quay.io/rockylinux/rockylinux:${RL_VER}"
|
||||
"podman system service -t 1"
|
||||
"touch ${HOME}/test.txt && \
|
||||
podman run --rm --privileged -v ${HOME}/test.txt:/test.txt quay.io/rockylinux/rockylinux:${RL_VER} bash -c 'echo HELLO > /test.txt' && \
|
||||
grep -qe 'HELLO' ${HOME}/test.txt && \
|
||||
rm -f ${HOME}/test.txt"
|
||||
"printf \"FROM quay.io/rockylinux/rockylinux:${RL_VER}\nCMD echo 'HELLO'\n\" > ${HOME}/Containerfile && \
|
||||
podman build -t test:latest -f ${HOME}/Containerfile && \
|
||||
podman image rm localhost/test:latest && \
|
||||
rm -rf ${HOME}/Containerfile"
|
||||
)
|
||||
|
||||
tmpoutput="$(mktemp)"
|
||||
trap 'rm -f ${tmpoutput}' EXIT
|
||||
|
||||
for command in "${test_to_run[@]}"; do
|
||||
r_log "podman" "Running $0: ${command}"
|
||||
if ! eval "${command}" > "${tmpoutput}" 2>&1; then
|
||||
r_log "podman" "${command} has failed."
|
||||
cat "${tmpoutput}"
|
||||
exit 1
|
||||
else
|
||||
r_checkExitStatus 0
|
||||
fi
|
||||
done
|
||||
|
@ -1,3 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
r_log "podman" "Testing podman sockets"
|
||||
|
||||
useradd podman-remote
|
||||
loginctl enable-linger podman-remote
|
||||
tmpoutput="$(mktemp)"
|
||||
|
||||
trap 'loginctl terminate-user podman-remote && loginctl disable-linger podman-remote && sleep 1 && userdel -r podman-remote && rm -f ${tmpoutput}' EXIT
|
||||
|
||||
sleep 3
|
||||
|
||||
su -l podman-remote > "${tmpoutput}" 2>&1 <<EOF
|
||||
set -e
|
||||
export XDG_RUNTIME_DIR=/run/user/\$(id -u)
|
||||
systemctl --user enable --now podman.socket
|
||||
podman --url unix://run/user/\$(id -u)/podman/podman.sock run --name port-mapping-test -d -p 8080:80 docker.io/nginx
|
||||
pid=\$(systemctl --user show --property MainPID --value podman.service)
|
||||
while [ "\${pid}" -ne 0 ] && [ -d /proc/\${pid} ]; do sleep 1; echo "Waiting for podman to exit"; done
|
||||
podman --url unix://run/user/\$(id -u)/podman/podman.sock ps | grep -q -e port-mapping-test
|
||||
podman --url unix://run/user/\$(id -u)/podman/podman.sock container rm -f port-mapping-test
|
||||
systemctl --user disable --now podman.socket
|
||||
EOF
|
||||
|
||||
ret_val=$?
|
||||
|
||||
if [ "$ret_val" -ne 0 ]; then
|
||||
cat "${tmpoutput}"
|
||||
r_checkExitStatus 1
|
||||
fi
|
||||
r_checkExitStatus 0
|
||||
|
Loading…
Reference in New Issue
Block a user