diff --git a/tests/zdev-migration/main.fmf b/tests/zdev-migration/main.fmf new file mode 100644 index 0000000..05fdff8 --- /dev/null +++ b/tests/zdev-migration/main.fmf @@ -0,0 +1,17 @@ +summary: zdev-migration +description: | + Check if the legacy device config can be migrated to the zdev style +#link: https://redhat.atlassian.net/browse/RHEL-157238 +contact: Daniel Horák +component: + - s390utils +test: ./runtest.sh +framework: beakerlib +require: + - s390utils-base +duration: 5m +enabled: true +adjust: + - when: arch != s390x + enabled: false + because: This test applies only to s390x systems. diff --git a/tests/zdev-migration/runtest.sh b/tests/zdev-migration/runtest.sh new file mode 100755 index 0000000..25a1abd --- /dev/null +++ b/tests/zdev-migration/runtest.sh @@ -0,0 +1,129 @@ +#!/bin/bash +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Description: Check if the legacy device config can be migrated to +# the zdev style +# Author: Dan Horák +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2026 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="s390utils-base" + +rulesdir=/etc/udev/rules.d + +rlJournalStart +rlPhaseStartSetup + rlAssertRpm $PACKAGE + + rlLog "Make backups for live configs" + [ -f /etc/dasd.conf ] && cp /etc/dasd.conf /etc/dasd.conf.pre-zdev + [ -f /etc/zfcp.conf ] && cp /etc/zfcp.conf /etc/zfcp.conf.pre-zdev + for f in /etc/NetworkManager/system-connections/*; do + cp $f $f.nm-pre-zdev + done + [ -f $rulesdir/41-cio-ignore.rules ] && cp $rulesdir/41-cio-ignore.rules $rulesdir/41-cio-ignore.rules.pre-zdev + + rlLog "Create sample configs" + echo "0.0.1234" > /etc/dasd.conf + echo "0.0.2345 0x10020123456789ab 0x0001000000000000" > /etc/zfcp.conf + + cat > /etc/NetworkManager/system-connections/enc3450.nmconnection << EOF +[connection] +id=enc3450 +uuid=a398c979-06b4-4e92-ae53-ab69d46f109d +type=ethernet +interface-name=enc3450 + +[ethernet] +s390-nettype=qeth +s390-subchannels=0.0.3450;0.0.3451;0.0.3452; + +[ethernet-s390-options] +layer2=1 +portno=2 + +[ipv4] +method=auto + +[ipv6] +addr-gen-mode=eui64 +method=auto + +[proxy] +EOF + +rlPhaseEnd + +rlPhaseStartTest "Check dasd.conf migration" + rlRun "dasdconfmigrate.sh" + rlAssertExists $rulesdir/41-cio-ignore.rules + rlAssertGrep "1234" $rulesdir/41-cio-ignore.rules + rlAssertNotExists /etc/dasd.conf + rlAssertExists $rulesdir/41-dasd-*-0.0.1234.rules +rlPhaseEnd + +rlPhaseStartTest "Check zfcp.conf migration" + rlRun "zfcpconfmigrate.sh" + rlAssertExists $rulesdir/41-cio-ignore.rules + rlAssertGrep "2345" $rulesdir/41-cio-ignore.rules + rlAssertNotExists /etc/zfcp.conf + rlAssertExists $rulesdir/41-zfcp-host-0.0.2345.rules + rlAssertExists $rulesdir/41-zfcp-lun-0.0.2345:0x10020123456789ab:0x0001000000000000.rules +rlPhaseEnd + +rlPhaseStartTest "Check network config migration" + rlRun "znetconfmigrate.sh" + rlAssertExists $rulesdir/41-cio-ignore.rules + rlAssertGrep "3450" $rulesdir/41-cio-ignore.rules + rlAssertExists /etc/NetworkManager/system-connections/enc3450.nmconnection + rlAssertExists $rulesdir/41-qeth-0.0.3450.rules + rlAssertGrep "ATTR{\[ccwgroup/0\.0\.3450\]layer2}=\"1\"" $rulesdir/41-qeth-0.0.3450.rules + rlAssertGrep "ATTR{\[ccwgroup/0\.0\.3450\]portno}=\"2\"" $rulesdir/41-qeth-0.0.3450.rules +rlPhaseEnd + +rlPhaseStartCleanup + rlLog "Remove migrated configs" + rm /etc/dasd.conf.*.migrated-to-chzdev{,.log} + rm /etc/zfcp.conf.*.migrated-to-chzdev{,.log} + rm /etc/NetworkManager/system-connections/enc3450.nmconnection + + rlLog "Remove migrated rules" + rm $rulesdir/41-dasd-*-0.0.1234.rules + rm $rulesdir/41-zfcp-*-0.0.2345*.rules + rm $rulesdir/41-qeth-0.0.3450.rules + if [ -f $rulesdir/41-cio-ignore.rules.pre-zdev ]; then + mv $rulesdir/41-cio-ignore.rules.pre-zdev $rulesdir/41-cio-ignore.rules + else + rm $rulesdir/41-cio-ignore.rules + fi + + rlLog "Restore live configs" + [ -f /etc/dasd.conf.pre-zdev ] && mv /etc/dasd.conf.pre-zdev /etc/dasd.conf + [ -f /etc/zfcp.conf.pre-zdev ] && mv /etc/zfcp.conf.pre-zdev /etc/zfcp.conf + for f in /etc/NetworkManager/system-connections/*.nm-pre-zdev; do + mv $f $(basename -s .nm-pre-zdev $f) + done +rlPhaseEnd + +rlJournalPrintText +rlJournalEnd