tests: Migrate test-pull-many.sh to installed on FAH

`test-pull-many.sh` is was just too slow to be a unit test.  Generating
a bunch of files via shell is slow, the delta generation is slow, etc.
Every developer doesn't need to run it every time.

Somewhat address this by converting it into our installed test framework, which
moves it out of the developer fast paths.  Another advantage to this is
that we can simply reuse the FAH tree content rather than synthesizing
new bits each time.

Closes: #840
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-05-08 13:37:50 -04:00 committed by Atomic Bot
parent 2800d176bc
commit 48d2637e98
4 changed files with 70 additions and 53 deletions

View File

@ -77,7 +77,6 @@ _installed_or_uninstalled_test_scripts = \
tests/test-pull-resume.sh \
tests/test-pull-repeated.sh \
tests/test-pull-untrusted.sh \
tests/test-pull-many.sh \
tests/test-pull-override-url.sh \
tests/test-local-pull.sh \
tests/test-local-pull-depth.sh \

27
tests/installed/itest-pull.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
# Using the host ostree, test HTTP pulls
set -xeuo pipefail
dn=$(dirname $0)
. ${dn}/libinsttest.sh
test_tmpdir=$(prepare_tmpdir)
trap _tmpdir_cleanup EXIT
# Take the host's ostree, and make it archive
cd /var/srv
rm repo bare-repo -rf
mkdir repo
ostree --repo=repo init --mode=archive
echo -e '[archive]\nzlib-level=1\n' >> repo/config
host_nonremoteref=$(echo ${host_refspec} | sed 's,[^:]*:,,')
ostree --repo=repo pull-local /ostree/repo ${host_commit}
ostree --repo=repo refs ${host_commit} --create=${host_nonremoteref}
run_tmp_webserver $(pwd)/repo
# Now test pulling via HTTP (no deltas) to a new bare-user repo
ostree --repo=bare-repo init --mode=bare-user
ostree --repo=bare-repo remote add origin --set=gpg-verify=false $(cat ${test_tmpdir}/httpd-address)
ostree --repo=bare-repo pull --disable-static-deltas origin ${host_nonremoteref}

View File

@ -20,6 +20,49 @@
dn=$(dirname $0)
. ${dn}/libtest-core.sh
# Copy of bits from tap-test
test_tmpdir=
function _tmpdir_cleanup () {
if test -n "${test_tmpdir}" && test -f ${test_tmpdir}/.testtmp; then
rm "${test_tmpdir}" -rf
fi
}
prepare_tmpdir() {
test_tmpdir=$(mktemp -d)
touch ${test_tmpdir}/.testtmp
cd ${test_tmpdir}
echo ${test_tmpdir}
}
# This is copied from flatpak/flatpak/tests/test-webserver.sh
run_tmp_webserver() {
dir=$1
test -n ${test_tmpdir}
cd ${dir}
env PYTHONUNBUFFERED=1 setsid python -m SimpleHTTPServer 0 &>${test_tmpdir}/httpd-output &
cd -
child_pid=$!
for x in $(seq 50); do
# Snapshot the output
cp ${test_tmpdir}/httpd-output{,.tmp}
# If it's non-empty, see whether it matches our regexp
if test -s ${test_tmpdir}/httpd-output.tmp; then
sed -e 's,Serving HTTP on 0.0.0.0 port \([0-9]*\) \.\.\.,\1,' < ${test_tmpdir}/httpd-output.tmp > ${test_tmpdir}/httpd-port
if ! cmp ${test_tmpdir}/httpd-output.tmp ${test_tmpdir}/httpd-port 1>/dev/null; then
# If so, we've successfully extracted the port
break
fi
fi
sleep 0.1
done
port=$(cat ${test_tmpdir}/httpd-port)
echo "http://127.0.0.1:${port}" > ${test_tmpdir}/httpd-address
echo "$child_pid" > ${test_tmpdir}/httpd-pid
}
# Determine our origin refspec - we'll use this as a test base
rpmostree=$(which rpm-ostree 2>/dev/null)
if test -z "${rpmostree}"; then

View File

@ -1,52 +0,0 @@
#!/bin/bash
#
# Copyright (C) 2017 Colin Walters <walters@verbum.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
set -euo pipefail
. $(dirname $0)/libtest.sh
setup_exampleos_repo
echo '1..3'
cd ${test_tmpdir}
set -x
echo "$(date): Pulling content..."
rev=$(${CMD_PREFIX} ostree --repo=ostree-srv/exampleos/repo rev-parse ${REF})
${CMD_PREFIX} ostree --repo=repo pull --disable-static-deltas origin ${REF}
${CMD_PREFIX} ostree --repo=repo fsck
assert_streq ${rev} $(${CMD_PREFIX} ostree --repo=repo rev-parse ${REF})
echo "ok without deltas"
previous=$(${CMD_PREFIX} ostree --repo=repo rev-parse ${rev}^)
rm repo/refs/{heads,remotes}/* -rf
${CMD_PREFIX} ostree --repo=repo prune --refs-only
${CMD_PREFIX} ostree --repo=repo pull origin ${REF}@${previous}
${CMD_PREFIX} ostree --repo=repo pull --dry-run --require-static-deltas origin ${REF} > output.txt
assert_file_has_content output.txt 'Delta update: 0/1 parts, 0 bytes/1.[012] MB, 1.[345] MB total uncompressed'
echo "ok delta dry-run"
${CMD_PREFIX} ostree --repo=repo pull --require-static-deltas origin ${REF}
assert_streq $(${CMD_PREFIX} ostree --repo=repo rev-parse ${REF}) ${rev}
${CMD_PREFIX} ostree --repo=repo fsck
echo "ok"