2017-06-29 23:51:56 +03:00
#!/bin/bash
# Test min-free-space-percent using loopback devices
set -xeuo pipefail
dn = $( dirname $0 )
2018-03-22 23:40:35 +03:00
. ${ dn } /../libinsttest.sh
date
2017-06-29 23:51:56 +03:00
2018-03-22 18:36:33 +03:00
prepare_tmpdir
2017-06-29 23:51:56 +03:00
trap _tmpdir_cleanup EXIT
cd ${ test_tmpdir }
2018-03-22 23:40:35 +03:00
truncate -s 20MB testblk.img
2017-06-29 23:51:56 +03:00
blkdev = $( losetup --find --show $( pwd ) /testblk.img)
mkfs.xfs ${ blkdev }
mkdir mnt
mount ${ blkdev } mnt
2018-06-12 00:06:31 +03:00
# first test min-free-space-percent
2017-06-29 23:51:56 +03:00
ostree --repo= mnt/repo init --mode= bare-user
2018-03-22 23:40:35 +03:00
echo 'fsync=false' >> mnt/repo/config
2017-06-29 23:51:56 +03:00
if ostree --repo= mnt/repo pull-local /ostree/repo ${ host_commit } 2>err.txt; then
fatal "succeeded in doing a pull with no free space"
fi
assert_file_has_content err.txt "min-free-space-percent"
2018-06-12 00:06:31 +03:00
echo "ok min-free-space-percent"
# now test min-free-space-size
rm -rf mnt/repo
ostree --repo= mnt/repo init --mode= bare-user
echo 'fsync=false' >> mnt/repo/config
echo 'min-free-space-size=10MB' >> mnt/repo/config
if ostree --repo= mnt/repo pull-local /ostree/repo ${ host_commit } 2>err.txt; then
fatal "succeeded in doing a pull with no free space"
fi
assert_file_has_content err.txt "min-free-space-size"
2018-06-18 18:11:21 +03:00
echo "ok min-free-space-size (error)"
2018-06-12 00:06:31 +03:00
2017-06-29 23:51:56 +03:00
umount mnt
losetup -d ${ blkdev }
2018-06-18 18:11:21 +03:00
rm testblk.img
# min-free-space-size success
ostree --repo= repo init --mode= bare-user
echo 'fsync=false' >> repo/config
echo 'min-free-space-size=1MB' >> repo/config
ostree --repo= repo pull-local /ostree/repo ${ host_commit }
echo "ok min-free-space-size (success)"
2018-03-22 23:40:35 +03:00
date