forked from coreos/fedora-coreos-config
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: coreos/fedora-coreos-tracker#1818 See: coreos/fedora-coreos-tracker#677 See: https://docs.fedoraproject.org/en-US/fedora-coreos/alternatives/
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
## kola: | ||
## 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 | ||
|
||
# To test the migration we will re-create the setup from an older FCOS node | ||
|
||
# First, reset iptables to the legacy backend | ||
alternatives --set iptables /usr/sbin/iptables-legacy | ||
if [[ $(alternatives --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 | ||
|
||
# Then re-create the broken alternatives folder in /var | ||
install -dm0755 /var/lib/alternatives | ||
|
||
# Do the migration, explicitely using the new configuration directory to ignore | ||
# the empty one in /var | ||
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 |