|
|
1f9579a |
#!/bin/bash
|
|
|
1f9579a |
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
|
|
1f9579a |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
1f9579a |
#
|
|
|
1f9579a |
# runtest.sh of /CoreOS/lftp/Regression/bz732863-IPv6-to-IPv4-fallback
|
|
|
1f9579a |
# Description: Test if lftp tries to connect over IPv4 when IPv6 not available
|
|
|
1f9579a |
# Author: Martin Frodl <mfrodl@redhat.com>
|
|
|
1f9579a |
#
|
|
|
1f9579a |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
1f9579a |
#
|
|
|
1f9579a |
# Copyright (c) 2015 Red Hat, Inc.
|
|
|
1f9579a |
#
|
|
|
1f9579a |
# This program is free software: you can redistribute it and/or
|
|
|
1f9579a |
# modify it under the terms of the GNU General Public License as
|
|
|
1f9579a |
# published by the Free Software Foundation, either version 2 of
|
|
|
1f9579a |
# the License, or (at your option) any later version.
|
|
|
1f9579a |
#
|
|
|
1f9579a |
# This program is distributed in the hope that it will be
|
|
|
1f9579a |
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
|
1f9579a |
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
1f9579a |
# PURPOSE. See the GNU General Public License for more details.
|
|
|
1f9579a |
#
|
|
|
1f9579a |
# You should have received a copy of the GNU General Public License
|
|
|
1f9579a |
# along with this program. If not, see http://www.gnu.org/licenses/.
|
|
|
1f9579a |
#
|
|
|
1f9579a |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
1f9579a |
|
|
|
1f9579a |
# Include Beaker environment
|
|
|
1f9579a |
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
|
|
1f9579a |
|
|
|
1f9579a |
PACKAGES=${PACKAGES:-"lftp"}
|
|
|
1f9579a |
REQUIRES=${REQUIRES:-"httpd"}
|
|
|
1f9579a |
|
|
|
1f9579a |
TESTDIR='bz732863'
|
|
|
1f9579a |
IP4='3.14.15.92'
|
|
|
1f9579a |
IP6='3:14:15:92:65:35:89:79'
|
|
|
1f9579a |
|
|
|
1f9579a |
rlJournalStart
|
|
|
1f9579a |
rlPhaseStartSetup
|
|
|
1f9579a |
rlRun "rlImport httpd/http" 0 "Importing httpd library" || rlDie
|
|
|
1f9579a |
rlAssertRpm --all
|
|
|
1f9579a |
|
|
|
1f9579a |
rlRun "ip addr add ${IP4} dev lo" 0 "Adding IP ${IP4} to lo interface"
|
|
|
1f9579a |
rlRun "ip route add ${IP4} dev lo" 0 "${IP4} will be routed via lo"
|
|
|
1f9579a |
rlRun "ip route add ${IP6} dev lo" 0 "${IP6} will be routed via lo"
|
|
|
1f9579a |
|
|
|
1f9579a |
HOSTS="/etc/hosts"
|
|
|
1f9579a |
rlRun "rlFileBackup ${HOSTS}"
|
|
|
1f9579a |
rlRun "echo '${IP4} italmas' >> ${HOSTS}" 0 "Adding IPv4 entry to hosts"
|
|
|
1f9579a |
rlRun "echo '${IP6} italmas' >> ${HOSTS}" 0 "Adding IPv6 entry to hosts"
|
|
|
1f9579a |
|
|
|
1f9579a |
rlRun "rlFileBackup --clean ${httpROOTDIR}"
|
|
|
1f9579a |
rlRun "mkdir ${httpROOTDIR}/${TESTDIR}" 0 "Creating test directory"
|
|
|
1f9579a |
rlServiceStop "httpd"
|
|
|
1f9579a |
sleep 10
|
|
|
1f9579a |
rlRun "httpStart" 0 "Starting httpd"
|
|
|
1f9579a |
rlPhaseEnd
|
|
|
1f9579a |
|
|
|
1f9579a |
rlPhaseStartTest
|
|
|
1f9579a |
# Make sure that 3.14.15.92 is reachable via loopback interface, whereas
|
|
|
1f9579a |
# 3:14:15:92:65:35:89:79 is not
|
|
|
1f9579a |
rlRun "ping -w 5 ${IP4}" 0 "Trying to contact local server over IPv4"
|
|
|
1f9579a |
rlRun "ping6 -w 5 ${IP6}" 1,2 "Trying to contact local server over IPv6"
|
|
|
1f9579a |
|
|
|
1f9579a |
URL="http://italmas/${TESTDIR}/"
|
|
|
1f9579a |
rlRun -s "lftp -de exit ${URL}" 0 "Connecting to localhost with lftp"
|
|
|
1f9579a |
rlAssertGrep 'Network is unreachable' ${rlRun_LOG}
|
|
|
1f9579a |
rlAssertGrep "200 OK" ${rlRun_LOG}
|
|
|
1f9579a |
rlIsRHEL 6 && rlAssertGrep "cd ok, cwd=/${TESTDIR}" ${rlRun_LOG}
|
|
|
1f9579a |
rlPhaseEnd
|
|
|
1f9579a |
|
|
|
1f9579a |
rlPhaseStartCleanup
|
|
|
1f9579a |
rlServiceStop "httpd"
|
|
|
1f9579a |
rlRun "httpStop" 0 "Stopping httpd"
|
|
|
1f9579a |
rlRun "rlFileRestore" 0 "Restoring original files"
|
|
|
1f9579a |
rlRun "ip addr del ${IP4} dev lo" 0 \
|
|
|
1f9579a |
"Removing IP ${IP4} from lo interace"
|
|
|
1f9579a |
rlRun "ip route del ${IP4}" 0 "Deleting routing entry for ${IP4}"
|
|
|
1f9579a |
rlRun "ip route del ${IP6}" 0 "Deleting routing entry for ${IP6}"
|
|
|
1f9579a |
rlRun "rlServiceRestore ${httpHTTPD}" 0 "Restoring httpd service"
|
|
|
1f9579a |
rlPhaseEnd
|
|
|
1f9579a |
rlJournalPrintText
|
|
|
1f9579a |
rlJournalEnd
|