#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/lftp/Regression/bz1228484-mirror-directory-hang
# Description: Test mirroring with subdirectories
# Author: Martin Frodl <mfrodl@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2016 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
PACKAGES="lftp"
random() {
tr -dc a-z < /dev/urandom | head -c 8
}
rlJournalStart
rlPhaseStartSetup
rlRun "rlImport httpd/http"
rlAssertRpm --all
rlFileBackup --clean ${httpROOTDIR}
TESTDIR="${httpROOTDIR}/bz1228484"
rlLogInfo "Creating directory tree on HTTP server"
mkdir ${TESTDIR}
cd ${TESTDIR}
for i in {1..4}; do
echo $(random) > $(random)
SUBDIR=$(random)
mkdir ${SUBDIR}
cd ${SUBDIR}
done
rlRun "httpStart"
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd ${TmpDir}"
rlPhaseEnd
rlPhaseStartTest
LFTP='lftp -c "mirror -v -v -v http://localhost/bz1228484/"'
rlRun "rlWatchdog '${LFTP}' 8" 0 "Mirroring local server with lftp"
du bz1228484
du ${TESTDIR}
rlRun "diff -r ./bz1228484 ${TESTDIR}"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r ${TmpDir}" 0 "Removing tmp directory"
rlRun "httpStop"
rlRun "rlFileRestore"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd