From 484d98bf7b8774ca373041b920310c05468533c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Ravier?= Date: Wed, 13 Nov 2024 18:57:44 +0100 Subject: [PATCH] tests: Add initial alternatives test This makes sure that the system is setup properly and that the migration script will do the right thing on older systems. See: https://github.com/coreos/fedora-coreos-tracker/issues/1818 See: https://github.com/coreos/fedora-coreos-tracker/issues/677 See: https://docs.fedoraproject.org/en-US/fedora-coreos/alternatives/ --- tests/kola/files/alternatives | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 tests/kola/files/alternatives diff --git a/tests/kola/files/alternatives b/tests/kola/files/alternatives new file mode 100755 index 0000000000..7fd1cd2162 --- /dev/null +++ b/tests/kola/files/alternatives @@ -0,0 +1,40 @@ +#!/bin/bash +## kola: +## exclusive: true +## description: Verify that the alternatives config is properly migrated and test the migration + +# See +# - https://github.com/coreos/fedora-coreos-tracker/issues/1818 + +set -xeuo pipefail + +# shellcheck disable=SC1091 +. "$KOLA_EXT_DATA/commonlib.sh" + +if test -e "/var/lib/alternatives"; then + ls -al "/var/lib/alternatives" + fatal "Error: Found '/var/lib/alternatives' which should not exists" +fi +if ! test -d "/etc/alternatives"; then + fatal "Error: '/etc/alternatives' is missing" +fi +if ! test -d "/etc/alternatives-admindir"; then + fatal "Error: '/etc/alternatives-admindir' is missing" +fi + +# Re-create the setup form an older FCOS node +alternatives --admindir /etc/alternatives-admindir --set iptables /usr/sbin/iptables-legacy +if [[ $(alternatives --admindir /etc/alternatives-admindir --display iptables | grep -c "link currently points to /usr/sbin/iptables-legacy") != "1" ]]; then + fatal "Could not set iptables to legacy backend for testing" +fi +if [[ $(iptables --version | grep -c "legacy") != "1" ]]; then + fatal "Could not set iptables to legacy backend for testing" +fi +install -dm0755 /var/lib/alternatives +alternatives --admindir /etc/alternatives-admindir --set iptables /usr/sbin/iptables-nft +if [[ $(alternatives --admindir /etc/alternatives-admindir --display iptables | grep -c "link currently points to /usr/sbin/iptables-nft") != "1" ]]; then + fatal "Could not set iptables to nft backend for migration" +fi +if [[ $(iptables --version | grep -c "nf_tables") != "1" ]]; then + fatal "Error: iptables not reset to nftables backend" +fi