Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VM disk size tests #367

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,22 @@ jobs:
src_track="$(echo "${dst_track}" | cut -d/ -f1)/stable"
EXTRA_ARGS="${EXTRA_ARGS:-3} ${src_track} ${{ matrix.track }}"
fi
sudo --preserve-env=GITHUB_ACTIONS,GITHUB_STEP_SUMMARY,TEST_IMG ./bin/local-run "tests/${TEST_SCRIPT}" ${{ matrix.track }} ${EXTRA_ARGS:-}

git clone https://github.com/hamistao/lxd
cd lxd
git checkout disk_size_fixes
sudo apt update
sudo apt install acl attr autoconf automake dnsmasq-base git libacl1-dev libcap-dev liblxc1 liblxc-dev libsqlite3-dev libtool libudev-dev liblz4-dev libuv1-dev make pkg-config rsync squashfs-tools tar tcl xz-utils ebtables
command -v snap >/dev/null || sudo apt-get install snapd
sudo snap install --classic go
make deps
export CGO_CFLAGS="-I/home/runner/go/deps/dqlite/include/"
export CGO_LDFLAGS="-L/home/runner/go/deps/dqlite/.libs/"
export LD_LIBRARY_PATH="/home/runner/go/deps/dqlite/.libs/"
export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
make
cd ..
sudo LXD_SIDELOAD_PATH=/home/runner/go/bin/lxd --preserve-env=GITHUB_ACTIONS,GITHUB_STEP_SUMMARY,TEST_IMG ./bin/local-run "tests/${TEST_SCRIPT}" ${{ matrix.track }} ${EXTRA_ARGS:-}

# always update cache as we have our own logic of
# cache invalidation and updates in addition to a date check
Expand Down
47 changes: 47 additions & 0 deletions tests/storage-vm
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,53 @@ for poolDriver in $poolDriverList; do
[ "$(($(lxc exec v1 -- blockdev --getsize64 /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_lxd_root) / GiB))" -eq "16" ]
fi

lxc stop -f v1
# Set 'volume.size' and create new VM
lxc storage set "${poolName}" volume.size="7GiB"
lxc init -s "${poolName}" testimage v3

# Get instance root disk sizes
[ "$(lxc info v1 | awk '/Disk total:/ {found=1} found && /root:/ {print $2; exit}')" = "10GiB" ]
[ "$(lxc info v3 | awk '/Disk total:/ {found=1} found && /root:/ {print $2; exit}')" = "7GiB" ]

# Check volume 'size' and volume state also show correct total size.
[ "$(lxc storage volume get virtual-machine/v1 size)" = "10GiB" ]
[ "$(lxc storage volume info virtual-machine/v1 | grep "Total:")" = "10GiB" ]
[ "$(lxc storage volume get virtual-machine/v3 size)" = "7GiB" ]
[ "$(lxc storage volume info virtual-machine/v3 | grep "Total:")" = "7GiB" ]
Comment on lines +612 to +615
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick drive-by observation. All those lxc storage volume are seemingly missing the pool name.


# Shrinking v1 is not allowed, grow v1 and v3.
# Device size should override default size and 'volume.size'.
lxc start v1
lxc start v3
! lxc config device set v1 root size="7GiB" || false
! lxc storage volume set virtual-machine/v1 size="11GiB" || false
lxc config device set v1 root size="11GiB"
lxc config device set v3 root size="10GiB"

# Resizing does not apply while instance is running.
[ "$(lxc info v1 | awk '/Disk total:/ {found=1} found && /root:/ {print $2; exit}')" = "10GiB" ]
[ "$(lxc info v3 | awk '/Disk total:/ {found=1} found && /root:/ {print $2; exit}')" = "7GiB" ]

# While instance is stopped, show new instance root disk size even though
# The volume itself only gets resized on instance start.
lxc stop -f v1 v3
[ "$(lxc info v1 | awk '/Disk total:/ {found=1} found && /root:/ {print $2; exit}')" = "11GiB" ]
[ "$(lxc storage volume get virtual-machine/v1 volatile.rootfs.size)" = "10GiB" ]
[ "$(lxc storage volume info virtual-machine/v1 | grep "Total:")" = "10GiB" ]

[ "$(lxc info v3 | awk '/Disk total:/ {found=1} found && /root:/ {print $2; exit}')" = "10GiB" ]
[ "$(lxc storage volume get virtual-machine/v3 volatile.rootfs.size)" = "7GiB" ]
[ "$(lxc storage volume info virtual-machine/v3 | grep "Total:")" = "7GiB" ]

# Volume gets resized on start,
lxc start v1
[ "$(lxc storage volume get virtual-machine/v1 volatile.rootfs.size)" = "11GiB" ]
[ "$(lxc storage volume info virtual-machine/v1 | grep "Total:")" = "11GiB" ]

[ "$(lxc storage volume get virtual-machine/v3 volatile.rootfs.size)" = "10GiB" ]
[ "$(lxc storage volume info virtual-machine/v3 | grep "Total:")" = "10GiB" ]

echo "===> Renaming VM"
lxc stop -f v1
lxc rename v1 v1renamed
Expand Down
Loading