Blame tests/ip-neigh-sanity-test/runtest.sh

Petr Šabata d9a596
#!/bin/bash
Petr Šabata d9a596
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
Petr Šabata d9a596
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Petr Šabata d9a596
#
Petr Šabata d9a596
#   runtest.sh of /CoreOS/iproute/Sanity/ip-neigh-sanity-test
Petr Šabata d9a596
#   Description: Test basic ip neigh funcionality
Petr Šabata d9a596
#   Author: Jaroslav Aster <jaster@redhat.com>
Petr Šabata d9a596
#
Petr Šabata d9a596
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Petr Šabata d9a596
#
Petr Šabata d9a596
#   Copyright (c) 2014 Red Hat, Inc. All rights reserved.
Petr Šabata d9a596
#
Petr Šabata d9a596
#   This copyrighted material is made available to anyone wishing
Petr Šabata d9a596
#   to use, modify, copy, or redistribute it subject to the terms
Petr Šabata d9a596
#   and conditions of the GNU General Public License version 2.
Petr Šabata d9a596
#
Petr Šabata d9a596
#   This program is distributed in the hope that it will be
Petr Šabata d9a596
#   useful, but WITHOUT ANY WARRANTY; without even the implied
Petr Šabata d9a596
#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
Petr Šabata d9a596
#   PURPOSE. See the GNU General Public License for more details.
Petr Šabata d9a596
#
Petr Šabata d9a596
#   You should have received a copy of the GNU General Public
Petr Šabata d9a596
#   License along with this program; if not, write to the Free
Petr Šabata d9a596
#   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Petr Šabata d9a596
#   Boston, MA 02110-1301, USA.
Petr Šabata d9a596
#
Petr Šabata d9a596
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Petr Šabata d9a596
Petr Šabata d9a596
# Include Beaker environment
Petr Šabata d9a596
. /usr/bin/rhts-environment.sh || exit 1
Petr Šabata d9a596
. /usr/share/beakerlib/beakerlib.sh || exit 1
Petr Šabata d9a596
Petr Šabata d9a596
PACKAGE="iproute"
Petr Šabata d9a596
TEST_IFACE="test-iface"
Petr Šabata d9a596
TEST_IP4_PREFIX="192.168.100"
Petr Šabata d9a596
TEST_IP6_PREFIX="2000::"
Petr Šabata d9a596
TEST_MAC_PREFIX="00:c0:7b:7d:00"
Petr Šabata d9a596
rlIsRHEL '>=7' && MAN_PAGE="ip-neighbour" || MAN_PAGE="ip"
Petr Šabata d9a596
MESSAGES="/var/log/messages"
Petr Šabata d9a596
TMP_MESSAGES="$(mktemp)"
Petr Šabata d9a596
Petr Šabata d9a596
Petr Šabata d9a596
create_dummy_iface()
Petr Šabata d9a596
{
Petr Šabata d9a596
    rlRun "ip link add name ${TEST_IFACE} type dummy" 0 "Creating dummy interface: '${TEST_IFACE}'."
Petr Šabata d9a596
}
Petr Šabata d9a596
Petr Šabata d9a596
delete_dummy_iface()
Petr Šabata d9a596
{
Petr Šabata d9a596
    rlRun "ip link del ${TEST_IFACE}" 0 "Removing dummy interface: '${TEST_IFACE}'."
Petr Šabata d9a596
    rlRun "rmmod dummy" 0,1 "Removing dummy module."
Petr Šabata d9a596
}
Petr Šabata d9a596
Petr Šabata d9a596
Petr Šabata d9a596
rlJournalStart
Petr Šabata d9a596
    rlPhaseStartSetup
Petr Šabata d9a596
        rlCheckRpm "$PACKAGE"
Petr Šabata d9a596
        create_dummy_iface
Petr Šabata d9a596
    rlPhaseEnd
Petr Šabata d9a596
Petr Šabata d9a596
    if rlIsRHEL '>=7'; then
Petr Šabata d9a596
        rlPhaseStartTest
Petr Šabata d9a596
            for word in add del change replace show flush all proxy to dev nud unused permanent reachable probe failed incomplete stale delay noarp none; do
Petr Šabata d9a596
		if ! { [ "$word" = "unused" ] || [ "$word" = "all" ]; }; then
Petr Šabata d9a596
                    rlRun "ip n help 2>&1 | grep -e '[^[:alnum:]]${word}[^[:alnum:]]'" 0 "Checking there is '${word}' in ip neighbour help."
Petr Šabata d9a596
		fi
Petr Šabata d9a596
                rlRun "man ${MAN_PAGE} | col -b | grep -e '[^[:alnum:]]${word}[^[:alnum:]]'" 0 "Checking there is '${word}' in ${MAN_PAGE} man page."
Petr Šabata d9a596
            done
Petr Šabata d9a596
        rlPhaseEnd
Petr Šabata d9a596
    fi
Petr Šabata d9a596
Petr Šabata d9a596
    rlPhaseStartTest "Functional Test"
Petr Šabata d9a596
        rlLogInfo "IPv4"
Petr Šabata d9a596
        rlRun "ip neigh add ${TEST_IP4_PREFIX}.1 lladdr ${TEST_MAC_PREFIX}:c6 dev ${TEST_IFACE} nud permanent"
Petr Šabata d9a596
        rlRun "ip neigh show ${TEST_IP4_PREFIX}.1 | grep 'PERMANENT'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh add ${TEST_IP4_PREFIX}.2 lladdr ${TEST_MAC_PREFIX}:c7 dev ${TEST_IFACE}"
Petr Šabata d9a596
        rlRun "ip neigh show ${TEST_IP4_PREFIX}.2 | grep 'PERMANENT'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh add ${TEST_IP4_PREFIX}.3 lladdr ${TEST_MAC_PREFIX}:c8 dev ${TEST_IFACE} nud noarp"
Petr Šabata d9a596
        rlRun "ip neigh show nud all ${TEST_IP4_PREFIX}.3 | grep 'NOARP'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh add ${TEST_IP4_PREFIX}.4 lladdr ${TEST_MAC_PREFIX}:c9 dev ${TEST_IFACE} nud noarp"
Petr Šabata d9a596
        rlRun "ip neigh show nud all ${TEST_IP4_PREFIX}.4 | grep 'NOARP'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh add lladdr ${TEST_MAC_PREFIX}:ce dev ${TEST_IFACE} proxy ${TEST_IP4_PREFIX}.10"
Petr Šabata d9a596
        rlIsRHEL ">=7" && rlRun "ip neigh show proxy | grep ${TEST_IP4_PREFIX}.10"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "test $(ip neigh show dev ${TEST_IFACE} | wc -l) -eq 2" 0 "There are two items in neighbours."
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh del ${TEST_IP4_PREFIX}.1 dev ${TEST_IFACE}"
Petr Šabata d9a596
        rlRun "ip neigh show ${TEST_IP4_PREFIX}.1 | grep 'FAILED'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh change ${TEST_IP4_PREFIX}.2 lladdr ${TEST_MAC_PREFIX}:ca dev ${TEST_IFACE} nud reachable"
Petr Šabata d9a596
        rlRun "ip neigh show ${TEST_IP4_PREFIX}.2 | grep 'REACHABLE'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh replace ${TEST_IP4_PREFIX}.3 lladdr ${TEST_MAC_PREFIX}:cb dev ${TEST_IFACE} nud permanent"
Petr Šabata d9a596
        rlRun "ip neigh show nud all ${TEST_IP4_PREFIX}.3 | grep 'PERMANENT'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "test $(ip neigh show dev ${TEST_IFACE} nud permanent | wc -l) -eq 1" 0 "There is one permanent item in neighbours."
Petr Šabata d9a596
        rlRun "test $(ip neigh show dev ${TEST_IFACE} nud reachable | wc -l) -eq 1" 0 "There is one reachable item in neighbours."
Petr Šabata d9a596
        rlRun "test $(ip neigh show dev ${TEST_IFACE} nud noarp | wc -l) -eq 1" 0 "There is one noarp item in neighbours."
Petr Šabata d9a596
        rlRun "test $(ip neigh show dev ${TEST_IFACE} nud failed | wc -l) -eq 1" 0 "There is one failed item in neighbours."
Petr Šabata d9a596
        rlIsRHEL ">=7" && rlRun "test $(ip neigh show dev ${TEST_IFACE} proxy | wc -l) -eq 1" 0 "There is one proxy item in neighbours."
Petr Šabata d9a596
        rlRun "test $(ip neigh show dev ${TEST_IFACE} | grep -e PERMANENT -e REACHABLE -e FAILED | wc -l) -eq 3" 0 "There are three permanent or reachable or failed items in neighbours."
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh show dev ${TEST_IFACE} unused"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh change ${TEST_IP4_PREFIX}.4 dev ${TEST_IFACE} nud delay"
Petr Šabata d9a596
        rlRun "ip neigh flush ${TEST_IP4_PREFIX}.4 dev ${TEST_IFACE}"
Petr Šabata d9a596
        rlRun "ip neigh show nud all | grep '${TEST_IP4_PREFIX}.4'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -s neigh flush ${TEST_IP4_PREFIX}.4 dev ${TEST_IFACE}"
Petr Šabata d9a596
        rlRun "ip -s -s neigh flush ${TEST_IP4_PREFIX}.4 dev ${TEST_IFACE}"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh add ${TEST_IP4_PREFIX}.11 lladdr ${TEST_MAC_PREFIX}:c8 dev ${TEST_IFACE} nud permanent"
Petr Šabata d9a596
        rlRun "ip neigh show ${TEST_IP4_PREFIX}.11 | grep 'PERMANENT'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh change ${TEST_IP4_PREFIX}.11 dev ${TEST_IFACE} nud reachable"
Petr Šabata d9a596
        rlRun "ip neigh show ${TEST_IP4_PREFIX}.11 | grep 'REACHABLE'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh change ${TEST_IP4_PREFIX}.11 dev ${TEST_IFACE} nud probe"
Petr Šabata d9a596
        rlRun "ip neigh show ${TEST_IP4_PREFIX}.11 | grep 'PROBE'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh change ${TEST_IP4_PREFIX}.11 lladdr ${TEST_MAC_PREFIX}:c9 dev ${TEST_IFACE} nud failed"
Petr Šabata d9a596
        rlRun "ip neigh show ${TEST_IP4_PREFIX}.11 | grep 'FAILED'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh change ${TEST_IP4_PREFIX}.11 dev ${TEST_IFACE} nud incomplete"
Petr Šabata d9a596
        rlRun "ip neigh show ${TEST_IP4_PREFIX}.11 | grep 'INCOMPLETE'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh replace ${TEST_IP4_PREFIX}.11 lladdr ${TEST_MAC_PREFIX}:cb dev ${TEST_IFACE} nud stale"
Petr Šabata d9a596
        rlRun "ip neigh show ${TEST_IP4_PREFIX}.11 | grep '${TEST_MAC_PREFIX}:cb' | grep 'STALE'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh replace ${TEST_IP4_PREFIX}.11 dev ${TEST_IFACE} nud delay"
Petr Šabata d9a596
        rlRun "ip neigh show ${TEST_IP4_PREFIX}.11 | grep -e 'DELAY' -e 'PROBE'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh replace ${TEST_IP4_PREFIX}.11 dev ${TEST_IFACE} nud noarp"
Petr Šabata d9a596
        rlRun "ip neigh show nud all ${TEST_IP4_PREFIX}.11 | grep 'NOARP'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh change ${TEST_IP4_PREFIX}.11 dev ${TEST_IFACE} nud none"
Petr Šabata d9a596
        rlRun "ip neigh show nud none | grep ${TEST_IP4_PREFIX}.11"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip neigh show ${TEST_IP4_PREFIX}.0/24"
Petr Šabata d9a596
Petr Šabata d9a596
        rlLogInfo "IPv6"
Petr Šabata d9a596
        rlRun "ip -6 neigh add ${TEST_IP6_PREFIX}1 lladdr ${TEST_MAC_PREFIX}:c6 dev ${TEST_IFACE} nud permanent"
Petr Šabata d9a596
        rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}1 | grep 'PERMANENT'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh add ${TEST_IP6_PREFIX}2 lladdr ${TEST_MAC_PREFIX}:c7 dev ${TEST_IFACE}"
Petr Šabata d9a596
        rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}2 | grep 'PERMANENT'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh add ${TEST_IP6_PREFIX}3 lladdr ${TEST_MAC_PREFIX}:c8 dev ${TEST_IFACE} nud noarp"
Petr Šabata d9a596
        rlRun "ip -6 neigh show nud all ${TEST_IP6_PREFIX}3 | grep 'NOARP'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh add ${TEST_IP6_PREFIX}4 lladdr ${TEST_MAC_PREFIX}:c9 dev ${TEST_IFACE} nud noarp"
Petr Šabata d9a596
        rlRun "ip -6 neigh show nud all ${TEST_IP6_PREFIX}4 | grep 'NOARP'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh add lladdr ${TEST_MAC_PREFIX}:ce dev ${TEST_IFACE} proxy ${TEST_IP6_PREFIX}10"
Petr Šabata d9a596
        rlIsRHEL ">=7" && rlRun "ip -6 neigh show proxy | grep ${TEST_IP6_PREFIX}10"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "test $(ip -6 neigh show dev ${TEST_IFACE} | wc -l) -eq 2" 0 "There are two items in neighbours."
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh del ${TEST_IP6_PREFIX}1 dev ${TEST_IFACE}"
Petr Šabata d9a596
        rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}1 | grep 'FAILED'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh change ${TEST_IP6_PREFIX}2 lladdr ${TEST_MAC_PREFIX}:ca dev ${TEST_IFACE} nud reachable"
Petr Šabata d9a596
        rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}2 | grep 'REACHABLE'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh replace ${TEST_IP6_PREFIX}3 lladdr ${TEST_MAC_PREFIX}:cb dev ${TEST_IFACE} nud permanent"
Petr Šabata d9a596
        rlRun "ip -6 neigh show nud all ${TEST_IP6_PREFIX}3 | grep 'PERMANENT'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "test $(ip -6 neigh show dev ${TEST_IFACE} nud permanent | wc -l) -eq 1" 0 "There is one permanent item in neighbours."
Petr Šabata d9a596
        rlRun "test $(ip -6 neigh show dev ${TEST_IFACE} nud reachable | wc -l) -eq 1" 0 "There is one reachable item in neighbours."
Petr Šabata d9a596
        rlRun "test $(ip -6 neigh show dev ${TEST_IFACE} nud noarp | wc -l) -eq 1" 0 "There is one noarp item in neighbours."
Petr Šabata d9a596
        rlRun "test $(ip -6 neigh show dev ${TEST_IFACE} nud failed | wc -l) -eq 1" 0 "There is one failed item in neighbours."
Petr Šabata d9a596
        rlIsRHEL ">=7" && rlRun "test $(ip -6 neigh show dev ${TEST_IFACE} proxy | wc -l) -eq 1" 0 "There is one proxy item in neighbours."
Petr Šabata d9a596
        rlRun "test $(ip -6 neigh show dev ${TEST_IFACE} | grep -e PERMANENT -e REACHABLE -e FAILED | wc -l) -eq 3" 0 "There are three permanent or reachable or failed items in neighbours."
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh show dev ${TEST_IFACE} unused"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh change ${TEST_IP6_PREFIX}4 dev ${TEST_IFACE} nud delay"
Petr Šabata d9a596
        rlRun "ip -6 neigh flush ${TEST_IP6_PREFIX}4 dev ${TEST_IFACE}"
Petr Šabata d9a596
        rlRun "ip -6 neigh show nud all | grep '${TEST_IP6_PREFIX}4'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 -s neigh flush ${TEST_IP6_PREFIX}4 dev ${TEST_IFACE}"
Petr Šabata d9a596
        rlRun "ip -6 -s -s neigh flush ${TEST_IP6_PREFIX}4 dev ${TEST_IFACE}"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh add ${TEST_IP6_PREFIX}11 lladdr ${TEST_MAC_PREFIX}:c8 dev ${TEST_IFACE} nud permanent"
Petr Šabata d9a596
        rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}11 | grep 'PERMANENT'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh change ${TEST_IP6_PREFIX}11 dev ${TEST_IFACE} nud reachable"
Petr Šabata d9a596
        rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}11 | grep 'REACHABLE'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh change ${TEST_IP6_PREFIX}11 dev ${TEST_IFACE} nud probe"
Petr Šabata d9a596
        rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}11 | grep 'PROBE'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh change ${TEST_IP6_PREFIX}11 lladdr ${TEST_MAC_PREFIX}:c9 dev ${TEST_IFACE} nud failed"
Petr Šabata d9a596
        rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}11 | grep 'FAILED'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh change ${TEST_IP6_PREFIX}11 dev ${TEST_IFACE} nud incomplete"
Petr Šabata d9a596
        rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}11 | grep 'INCOMPLETE'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh replace ${TEST_IP6_PREFIX}11 lladdr ${TEST_MAC_PREFIX}:cb dev ${TEST_IFACE} nud stale"
Petr Šabata d9a596
        rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}11 | grep '${TEST_MAC_PREFIX}:cb' | grep 'STALE'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh replace ${TEST_IP6_PREFIX}11 dev ${TEST_IFACE} nud delay"
Petr Šabata d9a596
        rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}11 | grep -e 'DELAY' -e 'PROBE'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh replace ${TEST_IP6_PREFIX}11 dev ${TEST_IFACE} nud noarp"
Petr Šabata d9a596
        rlRun "ip -6 neigh show nud all ${TEST_IP6_PREFIX}11 | grep 'NOARP'"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh change ${TEST_IP6_PREFIX}11 dev ${TEST_IFACE} nud none"
Petr Šabata d9a596
        rlRun "ip -6 neigh show nud none | grep ${TEST_IP6_PREFIX}11"
Petr Šabata d9a596
Petr Šabata d9a596
        rlRun "ip -6 neigh show ${TEST_IP6_PREFIX}0/24"
Petr Šabata d9a596
    rlPhaseEnd
Petr Šabata d9a596
Petr Šabata d9a596
    rlPhaseStartTest
Petr Šabata d9a596
        pushd /tmp # because of coredump file
Petr Šabata d9a596
        tail -f -n 0 "$MESSAGES" > "$TMP_MESSAGES" &
Petr Šabata d9a596
        tail_pid="$!"
Petr Šabata d9a596
        rlRun "ip neigh add ${TEST_IP4_PREFIX}.11 lladdr ${TEST_MAC_PREFIX}:c16 dev ${TEST_IFACE} nud permanent" 1,255
Petr Šabata d9a596
        kill "$tail_pid"
Petr Šabata d9a596
        rlRun "grep -i -e 'segfault' -e 'unhandled signal' -e 'User process fault' ${TMP_MESSAGES}" 1 "Checking there is no segfault in /var/log/messages."
Petr Šabata d9a596
        popd
Petr Šabata d9a596
    rlPhaseEnd
Petr Šabata d9a596
Petr Šabata d9a596
    rlPhaseStartCleanup
Petr Šabata d9a596
        delete_dummy_iface
Petr Šabata d9a596
        rlRun "rm ${TMP_MESSAGES}" 0 "Removing tmp files and dirs."
Petr Šabata d9a596
    rlPhaseEnd
Petr Šabata d9a596
Petr Šabata d9a596
    rlJournalPrintText
Petr Šabata d9a596
rlJournalEnd