Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/kola: adapt for new pure-RHEL variants #3032

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions tests/kola/data/commonlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ is_fcos() {
# Note when using this, you probably also want to check `get_rhel_maj_ver`.
is_rhcos() {
source /etc/os-release
{ [ "${ID}" == "rhel" ] && [ "${VARIANT_ID}" == "coreos" ]; } || \
[ "${ID}" == "rhcos" ]
}

Expand All @@ -46,19 +47,20 @@ get_fedora_ver() {

get_rhel_maj_ver() {
source /etc/os-release
echo "${RHEL_VERSION%%.*}"
}

# rhcos8
is_rhcos8() {
source /etc/os-release
[ "${ID}" == "rhcos" ] && [ "${RHEL_VERSION%%.*}" -eq 8 ]
if [ "${ID}" == "rhcos" ]; then
echo "${RHEL_VERSION%%.*}"
elif [ "${ID}" == "rhel" ]; then
echo "${VERSION_ID%%.*}"
else
fatal "Unknown ID $ID"
fi
}

# rhcos9
is_rhcos9() {
source /etc/os-release
[ "${ID}" == "rhcos" ] && [ "${RHEL_VERSION%%.*}" -eq 9 ]
{ [ "${ID}" == "rhcos" ] && [ "${RHEL_VERSION%%.*}" -eq 9 ]; } || \
{ [ "${ID}" == "rhel" ] && [ "${VERSION_ID%%.*}" -eq 9 ]; }
}

# scos
Expand Down
10 changes: 3 additions & 7 deletions tests/kola/files/initrd/compression
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ set -xeuo pipefail
. "$KOLA_EXT_DATA/commonlib.sh"

# Check initrd for zstd magic number
if is_rhcos8; then
ok "Skipping initrd zstd compression test on RHCOS 8"
else
if ! LANG=C grep -aUPq "\x28\xb5\x2f\xfd" /boot/ostree/*/init*; then
fatal "Didn't find zstd compression in initrd"
fi
ok "Found zstd compression in initrd"
if ! LANG=C grep -aUPq "\x28\xb5\x2f\xfd" /boot/ostree/*/init*; then
fatal "Didn't find zstd compression in initrd"
fi
ok "Found zstd compression in initrd"
8 changes: 1 addition & 7 deletions tests/kola/files/rpmdb-sqlite
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
## kola:
## # Read only test thus safe to run in parallel
## exclusive: false
## description: Verify that we're using the sqlite rpmdb backend
## for RHCOS 9+ and FCOS 33+.
## description: Verify that we're using the sqlite rpmdb backend.

# See https://github.com/coreos/fedora-coreos-tracker/issues/623

Expand All @@ -12,11 +11,6 @@ set -xeuo pipefail
# shellcheck disable=SC1091
. "$KOLA_EXT_DATA/commonlib.sh"

if is_rhcos8; then
ok "nothing to check for RHCOS 8"
exit 0
fi

if [ ! -f /usr/share/rpm/rpmdb.sqlite ]; then
fatal "Didn't find file /usr/share/rpm/rpmdb.sqlite"
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ if [ "$ID" == "fedora" ]; then
else
fatal "fail: not operating on expected OS version"
fi
elif [[ "${ID_LIKE}" =~ "rhel" ]]; then
elif [[ "${ID}" = "rhel" ]] || [[ "${ID_LIKE}" =~ "rhel" ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we've mostly used == for comparisons like these. I'm fine leaving it as is though because it's identical behavior in bash.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's kind of a mess. Would've been nice if bash only supported one kind. I don't think we have any consistency overall in this codebase one way or the other.

# For the version comparison use string substitution to remove the
# '.` from the version so we can use integer comparison

Expand Down
45 changes: 18 additions & 27 deletions tests/kola/networking/hostname/fallback-hostname/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,25 @@ set -xeuo pipefail
# shellcheck disable=SC1091
. "$KOLA_EXT_DATA/commonlib.sh"

if is_rhcos8; then
if [ $(hostnamectl --transient) != 'localhost' ]; then
fatal "transient hostname was not expected"
fi
if [ ! -z $(hostnamectl --static) ]; then
fatal "static hostname not expected to be set"
fi
else
output=$(hostnamectl --json=pretty)
hostname=$(echo "$output" | jq -r '.Hostname')
fallback=$(echo "$output" | jq -r '.DefaultHostname')
static=$(echo "$output" | jq -r '.StaticHostname')
namesource=$(echo "$output" | jq -r '.HostnameSource')
output=$(hostnamectl --json=pretty)
hostname=$(echo "$output" | jq -r '.Hostname')
fallback=$(echo "$output" | jq -r '.DefaultHostname')
static=$(echo "$output" | jq -r '.StaticHostname')
namesource=$(echo "$output" | jq -r '.HostnameSource')

if [ "$hostname" != 'localhost' ]; then
fatal "hostname was not expected"
fi
if [ "$fallback" != 'localhost' ]; then
fatal "fallback hostname was not expected"
fi
if [ "$static" != 'null' ]; then
fatal "static hostname not expected to be set"
fi
if [ "$namesource" != 'default' ]; then
# For this test since we disabled NM setting the hostname we
# expect the hostname to have been set via the fallback/default
fatal "hostname was set from non-default/fallback source"
fi
if [ "$hostname" != 'localhost' ]; then
fatal "hostname was not expected"
fi
if [ "$fallback" != 'localhost' ]; then
fatal "fallback hostname was not expected"
fi
if [ "$static" != 'null' ]; then
fatal "static hostname not expected to be set"
fi
if [ "$namesource" != 'default' ]; then
# For this test since we disabled NM setting the hostname we
# expect the hostname to have been set via the fallback/default
fatal "hostname was set from non-default/fallback source"
fi

ok "fallback hostname wired up correctly"
4 changes: 0 additions & 4 deletions tests/kola/podman/rootless-systemd
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ main() {
sleep 5

retryflag="--retry-all-errors"
# --retry-all-errors flag passed to curl is not available on RHEL8
if is_rhcos8; then
retryflag="--retry-connrefused"
fi
# Try to grab the web page. Retry as it might not be up fully yet.
if ! curl --silent --show-error --retry 5 ${retryflag} http://localhost:8080 >/dev/null; then
runascoreuser podman logs httpd
Expand Down
Loading