Skip to content

Commit 086b0fa

Browse files
committed
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/
1 parent faa28e6 commit 086b0fa

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tests/kola/files/alternatives

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
## kola:
3+
## description: Verify that the alternatives config is properly migrated and test the migration
4+
5+
# See
6+
# - https://github.com/coreos/fedora-coreos-tracker/issues/1818
7+
8+
set -xeuo pipefail
9+
10+
# shellcheck disable=SC1091
11+
. "$KOLA_EXT_DATA/commonlib.sh"
12+
13+
if test -e "/var/lib/alternatives"; then
14+
ls -al "/var/lib/alternatives"
15+
fatal "Error: Found '/var/lib/alternatives' which should not exists"
16+
fi
17+
if ! test -d "/etc/alternatives"; then
18+
fatal "Error: '/etc/alternatives' is missing"
19+
fi
20+
if ! test -d "/etc/alternatives-admindir"; then
21+
fatal "Error: '/etc/alternatives-admindir' is missing"
22+
fi
23+
24+
# To test the migration we will re-create the setup from an older FCOS node
25+
26+
# First, reset iptables to the legacy backend
27+
alternatives --set iptables /usr/sbin/iptables-legacy
28+
if [[ $(alternatives --display iptables | grep -c "link currently points to /usr/sbin/iptables-legacy") != "1" ]]; then
29+
fatal "Could not set iptables to legacy backend for testing"
30+
fi
31+
if [[ $(iptables --version | grep -c "legacy") != "1" ]]; then
32+
fatal "Could not set iptables to legacy backend for testing"
33+
fi
34+
35+
# Then re-create the broken alternatives folder in /var
36+
install -dm0755 /var/lib/alternatives
37+
38+
# Do the migration, explicitely using the new configuration directory to ignore
39+
# the empty one in /var
40+
alternatives --admindir /etc/alternatives-admindir --set iptables /usr/sbin/iptables-nft
41+
if [[ $(alternatives --admindir /etc/alternatives-admindir --display iptables | grep -c "link currently points to /usr/sbin/iptables-nft") != "1" ]]; then
42+
fatal "Could not set iptables to nft backend for migration"
43+
fi
44+
if [[ $(iptables --version | grep -c "nf_tables") != "1" ]]; then
45+
fatal "Error: iptables not reset to nftables backend"
46+
fi

0 commit comments

Comments
 (0)