2017-05-08 20:37:50 +03:00
#!/bin/bash
2020-07-17 04:36:51 +03:00
# FIXME just for webserver
# kola: { "tags": "needs-internet" }
2017-05-08 20:37:50 +03:00
# Using the host ostree, test HTTP pulls
set -xeuo pipefail
2018-04-20 21:17:20 +03:00
# FIXME: https://github.com/ostreedev/ostree/pull/1548
exit 0
2020-03-11 23:00:14 +03:00
. ${ KOLA_EXT_DATA } /libinsttest.sh
2018-03-22 23:40:35 +03:00
date
2017-05-08 20:37:50 +03:00
2018-03-22 18:36:33 +03:00
prepare_tmpdir /var/tmp
2017-05-08 20:37:50 +03:00
trap _tmpdir_cleanup EXIT
# Take the host's ostree, and make it archive
mkdir repo
ostree --repo= repo init --mode= archive
echo -e '[archive]\nzlib-level=1\n' >> repo/config
host_nonremoteref = $( echo ${ host_refspec } | sed 's,[^:]*:,,' )
2018-03-22 23:40:35 +03:00
log_timestamps( ) {
date
" $@ "
date
}
log_timestamps ostree --repo= repo pull-local /ostree/repo ${ host_commit }
2017-05-08 20:37:50 +03:00
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)
2018-03-22 23:40:35 +03:00
log_timestamps ostree --repo= bare-repo pull --disable-static-deltas origin ${ host_nonremoteref }
2017-09-20 06:09:11 +03:00
2018-04-06 16:39:43 +03:00
echo "ok pull"
# fsck marks commits partial
# https://github.com/ostreedev/ostree/pull/1533
for d in $( find bare-repo/objects/ -maxdepth 1 -type d) ; do
2018-04-18 21:36:19 +03:00
( find ${ d } -name '*.file' || true ) | head -20 | xargs rm -f
2018-04-06 16:39:43 +03:00
done
2018-04-20 21:17:20 +03:00
date
2018-04-18 21:36:19 +03:00
if ostree --repo= bare-repo fsck | & tee fsck.txt; then
2018-04-06 16:39:43 +03:00
fatal "fsck unexpectedly succeeded"
fi
2018-04-20 21:17:20 +03:00
date
2018-04-18 21:36:19 +03:00
assert_streq $( grep -cE -e 'Marking commit as partial' fsck.txt) "1"
2018-04-20 21:17:20 +03:00
log_timestamps ostree --repo= bare-repo pull origin ${ host_nonremoteref }
2018-04-06 16:39:43 +03:00
# Don't need a full fsck here
ostree --repo= bare-repo ls origin:${ host_nonremoteref } >/dev/null
2017-09-20 06:09:11 +03:00
rm bare-repo repo -rf
# Try copying the host's repo across a mountpoint for direct
# imports.
cd ${ test_tmpdir }
mkdir tmpfs mnt
mount --bind tmpfs mnt
cd mnt
ostree --repo= repo init --mode= bare
2018-03-22 23:40:35 +03:00
log_timestamps ostree --repo= repo pull-local /ostree/repo ${ host_commit }
log_timestamps ostree --repo= repo fsck
2017-09-20 06:09:11 +03:00
cd ..
2018-09-24 20:37:29 +03:00
# Also, we shouldn't copy xattrs on metadata objects
commit_path = objects/${ host_commit : 0 : 2 } /${ host_commit : 2 } .commit
ostree --repo= testarchive init --mode= archive
ostree --repo= testarchive pull-local --commit-metadata-only /ostree/repo ${ host_commit }
setfattr -n user.ostreetesting -v hello testarchive/${ commit_path }
ostree --repo= mnt/testarchive2 init --mode= archive
ostree --repo= mnt/testarchive2 pull-local --commit-metadata-only testarchive ${ host_commit }
if getfattr -m user.ostreetesting mnt/testarchive2/${ commit_path } 2>/dev/null; then
fatal "copied metadata xattr"
fi
echo "ok no metadata xattr copy"
2017-09-20 06:09:11 +03:00
umount mnt
2018-03-22 23:40:35 +03:00
2018-04-06 16:39:43 +03:00
# Cleanup
2018-03-22 23:40:35 +03:00
kill -TERM $( cat ${ test_tmpdir } /httpd-pid)
echo "ok"
date