|
Packit Service |
2a3f3d |
#!/bin/bash
|
|
Packit Service |
2a3f3d |
#
|
|
Packit Service |
2a3f3d |
# Copyright (C) 2016 Red Hat, Inc.
|
|
Packit Service |
2a3f3d |
#
|
|
Packit Service |
2a3f3d |
# SPDX-License-Identifier: LGPL-2.0+
|
|
Packit Service |
2a3f3d |
#
|
|
Packit Service |
2a3f3d |
# This library is free software; you can redistribute it and/or
|
|
Packit Service |
2a3f3d |
# modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
2a3f3d |
# License as published by the Free Software Foundation; either
|
|
Packit Service |
2a3f3d |
# version 2 of the License, or (at your option) any later version.
|
|
Packit Service |
2a3f3d |
#
|
|
Packit Service |
2a3f3d |
# This library is distributed in the hope that it will be useful,
|
|
Packit Service |
2a3f3d |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
2a3f3d |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
2a3f3d |
# Lesser General Public License for more details.
|
|
Packit Service |
2a3f3d |
#
|
|
Packit Service |
2a3f3d |
# You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
2a3f3d |
# License along with this library; if not, write to the
|
|
Packit Service |
2a3f3d |
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
Packit Service |
2a3f3d |
# Boston, MA 02111-1307, USA.
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
set -euo pipefail
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
. $(dirname $0)/libtest.sh
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
echo "1..3"
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
setup_fake_remote_repo1 "archive"
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
setup_mirror () {
|
|
Packit Service |
2a3f3d |
name=$1; shift
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
cd ${test_tmpdir}
|
|
Packit Service |
2a3f3d |
mkdir $name
|
|
Packit Service |
2a3f3d |
cd $name
|
|
Packit Service |
2a3f3d |
cp -a ${test_tmpdir}/ostree-srv ostree
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
${OSTREE_HTTPD} --autoexit --daemonize \
|
|
Packit Service |
2a3f3d |
-p ${test_tmpdir}/${name}-port
|
|
Packit Service |
2a3f3d |
port=$(cat ${test_tmpdir}/${name}-port)
|
|
Packit Service |
2a3f3d |
echo "http://127.0.0.1:${port}" > ${test_tmpdir}/${name}-address
|
|
Packit Service |
2a3f3d |
}
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
setup_mirror content_mirror1
|
|
Packit Service |
2a3f3d |
setup_mirror content_mirror2
|
|
Packit Service |
2a3f3d |
setup_mirror content_mirror3
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
# Let's delete a file from 1 so that it falls back on 2
|
|
Packit Service |
2a3f3d |
cd ${test_tmpdir}/content_mirror1/ostree/gnomerepo
|
|
Packit Service |
2a3f3d |
filez=$((find objects/ -name '*.filez' || true) | head -n 1)
|
|
Packit Service |
2a3f3d |
rm ${filez}
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
# Let's delete a file from 1 and 2 so that it falls back on 3
|
|
Packit Service |
2a3f3d |
cd ${test_tmpdir}/content_mirror1/ostree/gnomerepo
|
|
Packit Service |
2a3f3d |
filez=$((find objects/ -name '*.filez' || true) | head -n 1)
|
|
Packit Service |
2a3f3d |
rm ${filez}
|
|
Packit Service |
2a3f3d |
cd ${test_tmpdir}/content_mirror2/ostree/gnomerepo
|
|
Packit Service |
2a3f3d |
rm ${filez}
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
# OK, let's just shove the mirrorlist in the first httpd
|
|
Packit Service |
2a3f3d |
cat > ${test_tmpdir}/ostree-srv/mirrorlist <
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
# comment with empty lines around
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
$(cat ${test_tmpdir}/content_mirror1-address)/ostree/non-existent-repo
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
$(cat ${test_tmpdir}/content_mirror1-address)/ostree/gnomerepo
|
|
Packit Service |
2a3f3d |
$(cat ${test_tmpdir}/content_mirror2-address)/ostree/gnomerepo
|
|
Packit Service |
2a3f3d |
$(cat ${test_tmpdir}/content_mirror3-address)/ostree/gnomerepo
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
EOF
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
# first let's try just url
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
cd ${test_tmpdir}
|
|
Packit Service |
2a3f3d |
mkdir repo
|
|
Packit Service |
2a3f3d |
ostree_repo_init repo
|
|
Packit Service |
2a3f3d |
${CMD_PREFIX} ostree --repo=repo remote add origin --no-sign-verify \
|
|
Packit Service |
2a3f3d |
mirrorlist=$(cat httpd-address)/ostree/mirrorlist
|
|
Packit Service |
2a3f3d |
${CMD_PREFIX} ostree --repo=repo pull origin:main
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
echo "ok pull objects from mirrorlist"
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
# now let's try contenturl only mirrorlist
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
cd ${test_tmpdir}
|
|
Packit Service |
2a3f3d |
rm -rf repo
|
|
Packit Service |
2a3f3d |
mkdir repo
|
|
Packit Service |
2a3f3d |
ostree_repo_init repo
|
|
Packit Service |
2a3f3d |
${CMD_PREFIX} ostree --repo=repo remote add origin --no-sign-verify \
|
|
Packit Service |
2a3f3d |
--contenturl=mirrorlist=$(cat httpd-address)/ostree/mirrorlist \
|
|
Packit Service |
2a3f3d |
$(cat httpd-address)/ostree/gnomerepo
|
|
Packit Service |
2a3f3d |
${CMD_PREFIX} ostree --repo=repo pull origin:main
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
echo "ok pull objects from contenturl mirrorlist"
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
# both
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
cd ${test_tmpdir}
|
|
Packit Service |
2a3f3d |
rm -rf repo
|
|
Packit Service |
2a3f3d |
mkdir repo
|
|
Packit Service |
2a3f3d |
ostree_repo_init repo
|
|
Packit Service |
2a3f3d |
${CMD_PREFIX} ostree --repo=repo remote add origin --no-sign-verify \
|
|
Packit Service |
2a3f3d |
--contenturl=mirrorlist=$(cat httpd-address)/ostree/mirrorlist \
|
|
Packit Service |
2a3f3d |
mirrorlist=$(cat httpd-address)/ostree/mirrorlist
|
|
Packit Service |
2a3f3d |
${CMD_PREFIX} ostree --repo=repo pull origin:main
|
|
Packit Service |
2a3f3d |
|
|
Packit Service |
2a3f3d |
echo "ok pull objects from split urls mirrorlists"
|