From a686f168c3eabe2c2f141ec85001ef55b4f2e75a Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Thu, 30 Nov 2023 02:10:42 -0700 Subject: [PATCH] correct some tests --- func/README.md | 13 +++++++------ func/core/pkg_acl/00-install-acl.sh | 5 +++-- func/core/pkg_cpio/10-cpio.sh | 2 +- func/core/pkg_findutils/10-find.sh | 6 +++++- func/core/pkg_openssh/10-test-login.sh | 4 ++-- func/core/pkg_postfix/00-install-postfix.sh | 1 + func/core/pkg_postfix/40-postfix-tls.sh | 20 ++++++++++++-------- func/core/pkg_release/50-release-ver.sh | 2 +- func/core/pkg_shadow-utils/40-pw.sh | 6 ++++-- 9 files changed, 36 insertions(+), 23 deletions(-) diff --git a/func/README.md b/func/README.md index db7e929..785423f 100644 --- a/func/README.md +++ b/func/README.md @@ -5,22 +5,20 @@ These are a set of scripts that are designed to test the core functionality of a Rocky Linux system. They are designed to work on current versions of Rocky and are used to test a system as a Release Engineering self-QA but can be used by others for their own personal testing (under the assumption -that you just want to see what happens, we don't judge :). +that you just want to see what happens, we don't judge. -These tests *must* pass for a release to be considered "Core Validated" -Checking against the upstream repositories for package matches are not enough -and are/will be addressed by other tools. +These tests *must* pass for a X.0 release to be considered "Core Validated". * common -> Functions that our scripts and tests may or may not use. Templates and other files should come here too under common/files and scripts that use them should reference them as `./common/files/...` * core -> Core functionality and testing. For example, packages and service functionality. -* lib -> Library tests (these may be done elsewhere) +* lib -> Library tests (these may be done elsewhere, such as openqa) * log -> Log output. This repository has example logs of running on Rocky Linux. * modules -> Tests for module streams and their basic tests -* stacks -> Software stacks, think like LAMP. +* stacks -> Software stacks, think like LAMP (may be done elsewhere, such as openqa) How to Run ---------- @@ -154,6 +152,9 @@ system. No. The point is to test Rocky packages, not EPEL. There are also package differences that will break (eg: nc -> nmap-ncat vs netcat). +### What about CRB or extras? +It may say it's a failure, but it will continue anyway. + Current Tree ------------ ``` diff --git a/func/core/pkg_acl/00-install-acl.sh b/func/core/pkg_acl/00-install-acl.sh index 4394fd7..36fb837 100755 --- a/func/core/pkg_acl/00-install-acl.sh +++ b/func/core/pkg_acl/00-install-acl.sh @@ -1,6 +1,7 @@ #!/bin/bash r_log "acl" "Install the acl package" p_installPackageNormal acl -r_log "acl" "Remount filesystems with ACL support (this normally should not be needed)" -mount -o remount,acl / +# This normally is not needed. +#r_log "acl" "Remount filesystems with ACL support" +#mount -o remount,acl / sleep 3 diff --git a/func/core/pkg_cpio/10-cpio.sh b/func/core/pkg_cpio/10-cpio.sh index e3239c4..7e98742 100755 --- a/func/core/pkg_cpio/10-cpio.sh +++ b/func/core/pkg_cpio/10-cpio.sh @@ -27,7 +27,7 @@ popd || exit 1 r_log "cpio" "Test basic passthrough" pushd "$INNER" || exit 1 -find /tmp | cpio -pd "$PASSER" +find . | cpio -pd "$PASSER" r_checkExitStatus $? popd || exit 1 diff --git a/func/core/pkg_findutils/10-find.sh b/func/core/pkg_findutils/10-find.sh index c365e73..57c6c87 100755 --- a/func/core/pkg_findutils/10-find.sh +++ b/func/core/pkg_findutils/10-find.sh @@ -38,4 +38,8 @@ r_log "findutils" "Perform for xargs test: fails with spaces in the name" # shellcheck disable=SC2038 find "$TMPDIR" -type f | xargs ls &> /dev/null && { r_log "findutils" "Why did this get a 0 exit?"; exit "$FAIL"; } ret_val=$? -r_checkExitStatus $ret_val +if [ "$ret_val" -ne "0" ]; then + r_checkExitStatus 0 +else + r_checkExitStatus 1 +fi diff --git a/func/core/pkg_openssh/10-test-login.sh b/func/core/pkg_openssh/10-test-login.sh index 5ccffdf..d52722d 100755 --- a/func/core/pkg_openssh/10-test-login.sh +++ b/func/core/pkg_openssh/10-test-login.sh @@ -1,15 +1,15 @@ #!/bin/bash r_log "openssh" "Testing basic login (using sshpass)" +trap 'userdel -rf sshpasstest; unset SSHPASS' EXIT if sshd -T | grep -q "passwordauthentication yes"; then r_log "openssh" "Creating test user" - SSHPASS="Blu30nyx!" + export SSHPASS="Blu30nyx!" useradd sshpasstest echo "${SSHPASS}" | passwd --stdin sshpasstest r_log "openssh" "Testing login" sshpass -e ssh sshpasstest@localhost echo 'hello' r_checkExitStatus $? - userdel -rf sshpasstest else r_log "openssh" "Skipping test" exit 0 diff --git a/func/core/pkg_postfix/00-install-postfix.sh b/func/core/pkg_postfix/00-install-postfix.sh index 7e8e49b..2844658 100755 --- a/func/core/pkg_postfix/00-install-postfix.sh +++ b/func/core/pkg_postfix/00-install-postfix.sh @@ -1,5 +1,6 @@ #!/bin/bash r_log "postfix" "Install postfix (requires stop of other pieces)" +# This is OK if it fails - This is also not logged except in stderr m_serviceCycler sendmail stop p_installPackageNormal postfix nc dovecot openssl m_serviceCycler postfix enable diff --git a/func/core/pkg_postfix/40-postfix-tls.sh b/func/core/pkg_postfix/40-postfix-tls.sh index 7ecaab1..a5fe9c1 100755 --- a/func/core/pkg_postfix/40-postfix-tls.sh +++ b/func/core/pkg_postfix/40-postfix-tls.sh @@ -2,6 +2,17 @@ r_log "postfix" "Test postfix with TLS" DROPDIR=/var/tmp/postfix +function cleanup() { + mv /etc/postfix/main.cf.backup /etc/postfix/main.cf + mv /etc/dovecot/dovecot.conf.backup /etc/dovecot/dovecot.conf + rm /etc/pki/tls/certs/mail.crt + rm /etc/pki/tls/private/mail.key + rm -rf $DROPDIR/mail.* + rm -rf /var/tmp/postfix +} + +trap cleanup EXIT + cp -a /etc/postfix/main.cf /etc/postfix/main.cf.backup cp -a /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.backup @@ -59,11 +70,4 @@ r_log "postfix" "Testing that postfix offers STARTTLS" echo "ehlo test" | nc -w 3 127.0.0.1 25 | grep -q "STARTTLS" ret_val=$? -mv /etc/postfix/main.cf.backup /etc/postfix/main.cf -mv /etc/dovecot/dovecot.conf.backup /etc/dovecot/dovecot.conf -rm /etc/pki/tls/certs/mail.crt -rm /etc/pki/tls/certs/mail.key -rm -rf $DROPDIR/mail.* -rm -rf /var/tmp/postfix - -r_checkExitStatus $? +r_checkExitStatus $ret_val diff --git a/func/core/pkg_release/50-release-ver.sh b/func/core/pkg_release/50-release-ver.sh index cdb17b8..0081f97 100755 --- a/func/core/pkg_release/50-release-ver.sh +++ b/func/core/pkg_release/50-release-ver.sh @@ -5,7 +5,7 @@ r_log "rocky release" "Checking that the package is at least X.Y-1.B" RELEASE_VER="$(rpm -q rocky-release --qf '%{RELEASE}')" RELNUM="${RELEASE_VER:0:1}" if [ "${RELNUM}" -ge "1" ]; then - if [ "${RELEASE_VER:0:3}" == [${RELNUM}.[:digit:]] ]; then + if [[ "${RELEASE_VER:0:3}" =~ ^${RELNUM}.[[:digit:]] ]]; then ret_val="0" else r_log "rocky release" "FAIL: The release package is not in X.Y-A.B format" diff --git a/func/core/pkg_shadow-utils/40-pw.sh b/func/core/pkg_shadow-utils/40-pw.sh index da0aa9f..5596e87 100755 --- a/func/core/pkg_shadow-utils/40-pw.sh +++ b/func/core/pkg_shadow-utils/40-pw.sh @@ -15,9 +15,11 @@ pwck -rq ./common/files/incorrect-passwd ./common/files/incorrect-shadow ret_val=$? if [ "$ret_val" -eq 0 ]; then r_log "shadow" "They're correct." - exit 1 + r_checkExitStatus 1 +else + r_log "shadow" "They're incorrect." + r_checkExitStatus 0 fi -r_checkExitStatus $ret_val r_log "shadow" "Check that pwconv is functional" mkdir -p /var/tmp/pwconv