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:
1 parent
2800d176bc
commit
48d2637e98
4 files changed
+70
-53
No files matched your search
Executable
+27
@@ -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}
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user