Skip to content
Permalink
Browse files

test: Adds storage quota tests

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
  • Loading branch information...
tomponline committed Sep 5, 2019
1 parent 72d8921 commit 74d695c9752a181e17c61462af0940dcb3afb7ba
Showing with 41 additions and 0 deletions.
  1. +41 −0 test/suites/storage.sh
@@ -761,18 +761,37 @@ test_storage() {

# Test applying quota
QUOTA1="10GB"
rootMinKB1="9767000"
rootMaxKB1="9999999"

QUOTA2="11GB"
rootMinKB2="10744000"
rootMaxKB2="10744999"

if [ "$lxd_backend" = "lvm" ]; then
QUOTA1="20MB"
rootMinKB1="17000"
rootMaxKB1="20000"
QUOTA2="21MB"
rootMinKB2="21000"
rootMaxKB2="23000"
fi

if [ "$lxd_backend" != "dir" ] && [ "$lxd_backend" != "ceph" ]; then
lxc launch testimage quota1
rootOrigSizeKB=$(lxc exec quota1 -- df -P / | tail -n1 | awk '{print $2}')
lxc profile device set default root size "${QUOTA1}"
lxc stop -f quota1
lxc start quota1

if [ "$lxd_backend" != "btrfs" ]; then
rootSizeKB=$(lxc exec quota1 -- df -P / | tail -n1 | awk '{print $2}')
if [ "$rootSizeKB" -gt "$rootMaxKB1" ] || [ "$rootSizeKB" -lt "$rootMinKB1" ] ; then
echo "root size not within quota range"
false
fi
fi

lxc launch testimage quota2
lxc stop -f quota2
lxc start quota2
@@ -787,13 +806,35 @@ test_storage() {

lxc stop -f quota2
lxc start quota2
if [ "$lxd_backend" != "btrfs" ]; then
rootSizeKB=$(lxc exec quota2 -- df -P / | tail -n1 | awk '{print $2}')
if [ "$rootSizeKB" -gt "$rootMaxKB2" ] || [ "$rootSizeKB" -lt "$rootMinKB2" ] ; then
echo "root size not within quota range"
false
fi
fi

lxc stop -f quota3
lxc start quota3

lxc profile device unset default root size
if [ "$lxd_backend" == "zfs" ]; then
rootSizeKB=$(lxc exec quota1 -- df -P / | tail -n1 | awk '{print $2}')
if [ "$rootSizeKB" -ne "$rootOrigSizeKB" ] ; then
echo "original root size not restored"
false
fi
fi

lxc stop -f quota1
lxc start quota1
if [ "$lxd_backend" == "zfs" ]; then
rootSizeKB=$(lxc exec quota1 -- df -P / | tail -n1 | awk '{print $2}')
if [ "$rootSizeKB" -ne "$rootOrigSizeKB" ] ; then
echo "original root size not restored"
false
fi
fi

lxc stop -f quota2
lxc start quota2

0 comments on commit 74d695c

Please sign in to comment.
You can’t perform that action at this time.