mirror of https://github.com/nmasse-itix/zvirt.git
Compare commits
13 Commits
d8b16c5ba5
...
c972dd2d62
| Author | SHA1 | Date |
|---|---|---|
|
|
c972dd2d62 | 2 weeks ago |
|
|
b06bdbe2db | 2 weeks ago |
|
|
7dae9155b7 | 2 weeks ago |
|
|
3fd2efc39f | 2 weeks ago |
|
|
69d96abadf | 2 weeks ago |
|
|
386e1478af | 2 weeks ago |
|
|
c1d3f9177f | 2 weeks ago |
|
|
b15a39c040 | 2 weeks ago |
|
|
8b7d14a72c | 2 weeks ago |
|
|
073ae1a027 | 2 weeks ago |
|
|
62adeb2008 | 2 weeks ago |
|
|
2c08663a3a | 2 weeks ago |
|
|
138c27e4aa | 2 weeks ago |
12 changed files with 1536 additions and 91 deletions
@ -0,0 +1 @@ |
|||||
|
build/ |
||||
@ -1,17 +1,94 @@ |
|||||
.PHONY: all test unit-test syntax-test integration-test lint clean |
PREFIX ?= /usr/local |
||||
|
.PHONY: all test unit-test syntax-test e2e-test lint clean prerequisites install uninstall release tarball install-tarball srpm rpm copr-build copr-whoami git-tag |
||||
|
VERSION := $(shell git describe --tags --abbrev=0) |
||||
|
|
||||
all: syntax-test unit-test lint |
all: syntax-test lint unit-test e2e-test release |
||||
|
|
||||
syntax-test: |
syntax-test: |
||||
@echo "Running syntax tests..." |
@echo "Running syntax tests..." |
||||
@/bin/bash -nv src/zvirt |
@/bin/bash -nv src/bin/zvirt |
||||
@/bin/bash -nv src/lib/core.sh |
@/bin/bash -nv src/lib/zvirt/core.sh |
||||
|
|
||||
unit-test: |
prerequisites: |
||||
|
@echo "Installing prerequisites..." |
||||
|
@/bin/bash -Eeuo pipefail -c 'if ! bats --version &>/dev/null; then dnf install -y bats; fi' |
||||
|
@/bin/bash -Eeuo pipefail -c 'if ! yq --version &>/dev/null; then dnf install -y yq; fi' |
||||
|
@/bin/bash -Eeuo pipefail -c 'if ! shellcheck --version &>/dev/null; then dnf install -y shellcheck; fi' |
||||
|
@/bin/bash -Eeuo pipefail -c 'if ! gh --version &>/dev/null; then dnf install -y gh; fi' |
||||
|
@/bin/bash -Eeuo pipefail -c 'if ! rpmbuild --version &>/dev/null; then dnf install -y rpm-build; fi' |
||||
|
@/bin/bash -Eeuo pipefail -c 'if ! copr-cli --version &>/dev/null; then dnf install -y copr-cli; fi' |
||||
|
@/bin/bash -Eeuo pipefail -c 'if ! git --version &>/dev/null; then dnf install -y git; fi' |
||||
|
|
||||
|
unit-test: prerequisites |
||||
@echo "Running unit tests..." |
@echo "Running unit tests..." |
||||
@LANG=LC_ALL=C BATS_LIB_PATH=$(PWD)/test/test_helper bats test/unit |
@LANG=C LC_ALL=C BATS_LIB_PATH=$(PWD)/test/test_helper bats test/unit |
||||
|
|
||||
|
e2e-test: prerequisites |
||||
|
@echo "Running end-to-end tests..." |
||||
|
@LANG=C LC_ALL=C BATS_LIB_PATH=$(PWD)/test/test_helper bats test/e2e |
||||
|
|
||||
|
install: |
||||
|
@echo "Installing zvirt..." |
||||
|
@install -d $(PREFIX)/lib/zvirt $(PREFIX)/bin |
||||
|
@install -m 755 src/bin/zvirt $(PREFIX)/bin/zvirt |
||||
|
@install -m 644 src/lib/zvirt/core.sh $(PREFIX)/lib/zvirt/core.sh |
||||
|
|
||||
|
uninstall: |
||||
|
@echo "Uninstalling zvirt..." |
||||
|
@rm -f $(PREFIX)/bin/zvirt |
||||
|
@rm -rf $(PREFIX)/lib/zvirt |
||||
|
|
||||
|
tarball: |
||||
|
@echo "Creating release tarball..." |
||||
|
@mkdir -p build |
||||
|
@tar --exclude-vcs --exclude='*.swp' -czf build/zvirt-$(VERSION).tar.gz --transform "s|^src|zvirt-$(VERSION)|" src |
||||
|
|
||||
|
install-tarball: tarball |
||||
|
@echo "Installing zvirt from release tarball..." |
||||
|
@tar -xvzf build/zvirt-$(VERSION).tar.gz --strip-components=1 -C $(PREFIX) |
||||
|
|
||||
|
srpm: prerequisites |
||||
|
@echo "Creating SRPM..." |
||||
|
@sed -i "s/^Version: .*/Version: $(VERSION)/" packaging/zvirt.spec |
||||
|
@git ls-files | sed 's|^|./|' > build/filelist.txt |
||||
|
@mkdir -p build/zvirt-$(VERSION)/SOURCES |
||||
|
@tar --verbatim-files-from --files-from=build/filelist.txt -cvzf build/zvirt-$(VERSION)/SOURCES/zvirt-$(VERSION).tar.gz --transform "s|^./|zvirt-$(VERSION)/|" |
||||
|
@rpmbuild --define "_topdir $$(pwd)/build/zvirt-$(VERSION)" --define "dist %{nil}" -bs packaging/zvirt.spec |
||||
|
|
||||
|
rpm: prerequisites srpm |
||||
|
@echo "Creating RPM..." |
||||
|
@rpmbuild --define "_topdir $$(pwd)/build/zvirt-$(VERSION)" -bb packaging/zvirt.spec |
||||
|
|
||||
|
# https://copr.fedorainfracloud.org/api/
|
||||
|
copr-whoami: prerequisites |
||||
|
@echo "Checking COPR identity..." |
||||
|
@copr-cli whoami |
||||
|
|
||||
|
copr-build: copr-whoami srpm |
||||
|
@echo "Building RPM in COPR..." |
||||
|
@copr-cli build --nowait nmasse-itix/zvirt build/zvirt-$(VERSION)/SRPMS/zvirt-$(VERSION)-*.src.rpm |
||||
|
|
||||
|
git-tag: prerequisites |
||||
|
@if [ -n "$$(git status --porcelain)" ]; then echo "Git working directory is dirty. Please commit or stash changes before tagging."; exit 1; fi |
||||
|
@echo "Tagging Git repository..." |
||||
|
@read -p "Enter version to tag [current: $(VERSION)]: " NEW_VERSION; \
|
||||
|
sed -i "s/^Version: .*/Version: $${NEW_VERSION}/" packaging/zvirt.spec; \
|
||||
|
git add packaging/zvirt.spec; \
|
||||
|
git commit -m "Bump version to $${NEW_VERSION}" ; \
|
||||
|
git tag -a "$${NEW_VERSION}" -m "Release v$${NEW_VERSION} of zvirt." ; \
|
||||
|
$(MAKE) -C . VERSION=$${NEW_VERSION} release |
||||
|
|
||||
|
release: prerequisites tarball srpm rpm copr-build |
||||
|
@echo "Pushing changes for version $(VERSION) to Git repository..." |
||||
|
@git push origin $$(git rev-parse --abbrev-ref HEAD) |
||||
|
@git push origin "$(VERSION)" |
||||
|
@echo "Creating GitHub release $(VERSION)..." |
||||
|
@gh release create $(VERSION) build/zvirt-$(VERSION).tar.gz build/zvirt-$(VERSION)/SRPMS/zvirt-$(VERSION)-*.rpm --draft --title "v$(VERSION)" --notes "Release v$(VERSION) of zvirt. RPMs are in COPR [nmasse-itix/zvirt](https://copr.fedorainfracloud.org/coprs/nmasse-itix/zvirt/)." |
||||
|
|
||||
clean: |
clean: |
||||
lint: |
@echo "Cleaning up..." |
||||
|
@rm -rf build/zvirt-* |
||||
|
|
||||
|
lint: prerequisites |
||||
@echo "Linting..." |
@echo "Linting..." |
||||
@shellcheck src/zvirt src/lib/*.sh |
@cd src && shellcheck --severity=error bin/zvirt lib/zvirt/*.sh |
||||
|
|||||
@ -0,0 +1,45 @@ |
|||||
|
Name: zvirt |
||||
|
Version: 0.0.5 |
||||
|
%if %{defined dist} |
||||
|
Release: 1%{?dist} |
||||
|
%else |
||||
|
Release: 1 |
||||
|
%endif |
||||
|
Summary: Libvirt ZFS snapshots utility |
||||
|
|
||||
|
License: MIT |
||||
|
URL: https://github.com/nmasse-itix/zvirt |
||||
|
Source0: %{name}-%{version}.tar.gz |
||||
|
|
||||
|
BuildArch: noarch |
||||
|
|
||||
|
Requires: bash |
||||
|
Requires: libvirt |
||||
|
Requires: zfs |
||||
|
BuildRequires: make |
||||
|
|
||||
|
%description |
||||
|
Zvirt takes snapshots of Libvirt domains using ZFS. |
||||
|
It supports both crash-consistent and live snapshots. |
||||
|
|
||||
|
At the end, all components of a domain (Domain definition, TPM, NVRAM, |
||||
|
VirtioFS, ZFS snapshots of the underlying storage volumes) are captured |
||||
|
as a set of consistent ZFS snapshots. |
||||
|
|
||||
|
%prep |
||||
|
%setup -q |
||||
|
|
||||
|
%build |
||||
|
# Nothing to build for a shell script |
||||
|
|
||||
|
%install |
||||
|
make PREFIX=%{buildroot}%{_prefix} install |
||||
|
|
||||
|
%files |
||||
|
%{_bindir}/zvirt |
||||
|
%{_prefix}/lib/zvirt/core.sh |
||||
|
%dir %{_prefix}/lib/zvirt |
||||
|
|
||||
|
%changelog |
||||
|
* Mon Nov 24 2025 Nicolas Massé <nicolas.masse@itix.fr> - 0.0.1-1 |
||||
|
- Initial package release |
||||
@ -0,0 +1,16 @@ |
|||||
|
#cloud-config |
||||
|
|
||||
|
bootcmd: |
||||
|
- setsebool -P virt_qemu_ga_run_unconfined on |
||||
|
- setsebool -P virt_qemu_ga_read_nonsecurity_files on |
||||
|
- setsebool -P virt_rw_qemu_ga_data on |
||||
|
- install -o root -g root -m 0777 --context=system_u:object_r:virt_qemu_ga_data_t:s0 -d /test/rootfs |
||||
|
|
||||
|
users: |
||||
|
- name: e2e |
||||
|
gecos: End-to-End Test User |
||||
|
sudo: ALL=(ALL) NOPASSWD:ALL |
||||
|
groups: wheel |
||||
|
lock_passwd: false |
||||
|
# echo -n test | mkpasswd -m bcrypt -s |
||||
|
passwd: $2b$05$Oh13XsRSrGrL/iSvV0Rax.w7rQMx/6lyBTCuaEVXrdh/qiagci9bS |
||||
@ -0,0 +1,19 @@ |
|||||
|
#cloud-config |
||||
|
|
||||
|
mounts: |
||||
|
- [ data, /test/virtiofs, virtiofs, "defaults,context=system_u:object_r:virt_qemu_ga_data_t:s0", "0", "0" ] |
||||
|
|
||||
|
bootcmd: |
||||
|
- setsebool -P virt_qemu_ga_run_unconfined on |
||||
|
- setsebool -P virt_qemu_ga_read_nonsecurity_files on |
||||
|
- setsebool -P virt_rw_qemu_ga_data on |
||||
|
- install -o root -g root -d /test/virtiofs |
||||
|
|
||||
|
users: |
||||
|
- name: e2e |
||||
|
gecos: End-to-End Test User |
||||
|
sudo: ALL=(ALL) NOPASSWD:ALL |
||||
|
groups: wheel |
||||
|
lock_passwd: false |
||||
|
# echo -n test | mkpasswd -m bcrypt -s |
||||
|
passwd: $2b$05$Oh13XsRSrGrL/iSvV0Rax.w7rQMx/6lyBTCuaEVXrdh/qiagci9bS |
||||
@ -0,0 +1,31 @@ |
|||||
|
#cloud-config |
||||
|
|
||||
|
disk_setup: |
||||
|
/dev/vdb: |
||||
|
table_type: gpt |
||||
|
layout: true |
||||
|
overwrite: true |
||||
|
|
||||
|
fs_setup: |
||||
|
- label: zvol |
||||
|
filesystem: xfs |
||||
|
device: /dev/vdb |
||||
|
partition: auto |
||||
|
|
||||
|
mounts: |
||||
|
- [ LABEL=zvol, /test/zvol, xfs, "defaults,context=system_u:object_r:virt_qemu_ga_data_t:s0", "0", "2" ] |
||||
|
|
||||
|
bootcmd: |
||||
|
- setsebool -P virt_qemu_ga_run_unconfined on |
||||
|
- setsebool -P virt_qemu_ga_read_nonsecurity_files on |
||||
|
- setsebool -P virt_rw_qemu_ga_data on |
||||
|
- mkdir -p /test/zvol |
||||
|
|
||||
|
users: |
||||
|
- name: e2e |
||||
|
gecos: End-to-End Test User |
||||
|
sudo: ALL=(ALL) NOPASSWD:ALL |
||||
|
groups: wheel |
||||
|
lock_passwd: false |
||||
|
# echo -n test | mkpasswd -m bcrypt -s |
||||
|
passwd: $2b$05$Oh13XsRSrGrL/iSvV0Rax.w7rQMx/6lyBTCuaEVXrdh/qiagci9bS |
||||
@ -0,0 +1,836 @@ |
|||||
|
#!/usr/bin/env bats |
||||
|
|
||||
|
setup() { |
||||
|
bats_load_library 'bats-support' |
||||
|
bats_load_library 'bats-assert' |
||||
|
|
||||
|
set -Eeuo pipefail |
||||
|
export LANG=C LC_ALL=C |
||||
|
|
||||
|
zvirt () { |
||||
|
"${BATS_TEST_DIRNAME}/../../src/bin/zvirt" "$@" |
||||
|
} |
||||
|
|
||||
|
declare -g e2e_test_enable_debug=1 |
||||
|
e2e_test_debug_log(){ |
||||
|
if [ "$e2e_test_enable_debug" -eq 1 ]; then |
||||
|
echo "$@" >&3 |
||||
|
fi |
||||
|
} |
||||
|
|
||||
|
qemu_exec() { |
||||
|
domain="$1" |
||||
|
shift || true |
||||
|
local json_args="" |
||||
|
for arg in "${@:2}"; do |
||||
|
if [ -n "$json_args" ]; then |
||||
|
json_args+=", " |
||||
|
fi |
||||
|
json_args+="\"$arg\"" |
||||
|
done |
||||
|
local command="{\"execute\": \"guest-exec\", \"arguments\": {\"path\": \"$1\", \"arg\": [ $json_args ], \"capture-output\": true }}" |
||||
|
output="$(virsh qemu-agent-command "$domain" "$command")" |
||||
|
#e2e_test_debug_log "qemu_exec: command output: $output" |
||||
|
pid="$(echo "$output" | jq -r '.return.pid')" |
||||
|
if [ -z "$pid" ] || [ "$pid" == "null" ]; then |
||||
|
e2e_test_debug_log "qemu_exec: failed to get pid from command output" |
||||
|
return 1 |
||||
|
fi |
||||
|
sleep .25 |
||||
|
while true; do |
||||
|
local status_command="{\"execute\": \"guest-exec-status\", \"arguments\": {\"pid\": $pid}}" |
||||
|
status_output="$(virsh qemu-agent-command "$domain" "$status_command")" |
||||
|
#e2e_test_debug_log "qemu_exec: status output: $status_output" |
||||
|
exited="$(echo "$status_output" | jq -r '.return.exited')" |
||||
|
if [ "$exited" == "true" ]; then |
||||
|
stdout_base64="$(echo "$status_output" | jq -r '.return["out-data"]')" |
||||
|
if [ "$stdout_base64" != "null" ]; then |
||||
|
echo "$stdout_base64" | base64 --decode |
||||
|
fi |
||||
|
stderr_base64="$(echo "$status_output" | jq -r '.return["err-data"]')" |
||||
|
if [ "$stderr_base64" != "null" ]; then |
||||
|
echo "$stderr_base64" | base64 --decode >&2 |
||||
|
fi |
||||
|
exit_code="$(echo "$status_output" | jq -r '.return.exitcode')" |
||||
|
return $exit_code |
||||
|
fi |
||||
|
sleep 1 |
||||
|
done |
||||
|
} |
||||
|
|
||||
|
create_cloud_init_iso () { |
||||
|
local domain="$1" |
||||
|
local iso_path="/var/lib/libvirt/images/${domain}/cloud-init.iso" |
||||
|
local user_data_path="/var/lib/libvirt/images/${domain}/cloud-init/user-data" |
||||
|
local meta_data_path="/var/lib/libvirt/images/${domain}/cloud-init/meta-data" |
||||
|
|
||||
|
# Create cloud-init user-data and meta-data files |
||||
|
mkdir -p "/var/lib/libvirt/images/${domain}/cloud-init" |
||||
|
cp "${BATS_TEST_DIRNAME}/cloud-init/${domain}-user-data" "$user_data_path" |
||||
|
cat > "$meta_data_path" <<EOF |
||||
|
instance-id: ${domain} |
||||
|
local-hostname: ${domain} |
||||
|
EOF |
||||
|
|
||||
|
# Create ISO image |
||||
|
genisoimage -output "$iso_path" -volid cidata -joliet -rock "$user_data_path" "$meta_data_path" |
||||
|
} |
||||
|
|
||||
|
convert_cloud_image() { |
||||
|
local src="$1" |
||||
|
local dest="$2" |
||||
|
|
||||
|
# Convert qcow2 to raw and resize to 20G |
||||
|
qemu-img convert -f qcow2 -O raw "$src" "$dest" |
||||
|
qemu-img resize -f raw "$dest" 20G |
||||
|
} |
||||
|
|
||||
|
cleanup() { |
||||
|
e2e_test_debug_log "teardown: Cleaning up created domains and images..." |
||||
|
for domain in standard with-fs with-zvol; do |
||||
|
state="$(virsh domstate "$domain" 2>/dev/null || true)" |
||||
|
if [[ -n "$state" && "$state" != "shut off" ]]; then |
||||
|
virsh destroy "$domain" |
||||
|
fi |
||||
|
if virsh dominfo "$domain" &>/dev/null; then |
||||
|
virsh undefine "$domain" --nvram |
||||
|
fi |
||||
|
done |
||||
|
sleep 1 |
||||
|
sync |
||||
|
sleep 1 |
||||
|
for domain in standard with-fs with-zvol; do |
||||
|
if zfs list data/domains/"$domain" &>/dev/null; then |
||||
|
zfs destroy -rR data/domains/"$domain" |
||||
|
fi |
||||
|
sleep .2 |
||||
|
rm -rf "/var/lib/libvirt/images/${domain}" |
||||
|
done |
||||
|
} |
||||
|
|
||||
|
create_domains() { |
||||
|
# Create the standard VM |
||||
|
e2e_test_debug_log "setup: Creating the standard VM..." |
||||
|
mkdir -p /var/lib/libvirt/images/standard |
||||
|
zfs create -p data/domains/standard -o mountpoint=/var/lib/libvirt/images/standard |
||||
|
convert_cloud_image "$fedora_img" "/var/lib/libvirt/images/standard/root.img" |
||||
|
create_cloud_init_iso "standard" |
||||
|
virt-install --noautoconsole \ |
||||
|
--name=standard \ |
||||
|
--cpu=host-passthrough \ |
||||
|
--vcpus=1 \ |
||||
|
--ram=4096 \ |
||||
|
--os-variant=fedora-rawhide \ |
||||
|
--disk=path=/var/lib/libvirt/images/standard/root.img,target.dev=vda,bus=virtio,driver.discard=unmap,driver.io=io_uring,format=raw,sparse=True,blockio.logical_block_size=512,blockio.physical_block_size=512,serial=root,format=raw \ |
||||
|
--network=none \ |
||||
|
--console=pty,target.type=virtio \ |
||||
|
--serial=pty \ |
||||
|
--disk=path=/var/lib/libvirt/images/standard/cloud-init.iso,readonly=True \ |
||||
|
--import \ |
||||
|
--sysinfo=system.serial=ds=nocloud \ |
||||
|
--boot=uefi |
||||
|
|
||||
|
# Create the with-fs VM |
||||
|
e2e_test_debug_log "setup: Creating the with-fs VM..." |
||||
|
mkdir -p /var/lib/libvirt/images/with-fs /srv/with-fs |
||||
|
chmod 0777 /srv/with-fs |
||||
|
zfs create -p data/domains/with-fs -o mountpoint=/var/lib/libvirt/images/with-fs |
||||
|
zfs create -p data/domains/with-fs/virtiofs -o mountpoint=/srv/with-fs |
||||
|
convert_cloud_image "$fedora_img" "/var/lib/libvirt/images/with-fs/root.img" |
||||
|
create_cloud_init_iso "with-fs" |
||||
|
virt-install --noautoconsole \ |
||||
|
--name=with-fs \ |
||||
|
--cpu=host-passthrough \ |
||||
|
--vcpus=1 \ |
||||
|
--ram=4096 \ |
||||
|
--os-variant=fedora-rawhide \ |
||||
|
--disk=path=/var/lib/libvirt/images/with-fs/root.img,target.dev=vda,bus=virtio,driver.discard=unmap,driver.io=io_uring,format=raw,sparse=True,blockio.logical_block_size=512,blockio.physical_block_size=512,serial=root,format=raw \ |
||||
|
--network=none \ |
||||
|
--console=pty,target.type=virtio \ |
||||
|
--serial=pty \ |
||||
|
--disk=path=/var/lib/libvirt/images/with-fs/cloud-init.iso,readonly=True \ |
||||
|
--import \ |
||||
|
--sysinfo=system.serial=ds=nocloud \ |
||||
|
--boot=uefi \ |
||||
|
--memorybacking=access.mode=shared,source.type=memfd \ |
||||
|
--filesystem=type=mount,accessmode=passthrough,driver.type=virtiofs,driver.queue=1024,source.dir=/srv/with-fs,target.dir=data |
||||
|
|
||||
|
# Create the with-zvol VM |
||||
|
e2e_test_debug_log "setup: Creating the with-zvol VM..." |
||||
|
mkdir -p /var/lib/libvirt/images/with-zvol |
||||
|
zfs create -p data/domains/with-zvol -o mountpoint=/var/lib/libvirt/images/with-zvol |
||||
|
zfs create -V 10G data/domains/with-zvol/data |
||||
|
convert_cloud_image "$fedora_img" "/var/lib/libvirt/images/with-zvol/root.img" |
||||
|
create_cloud_init_iso "with-zvol" |
||||
|
virt-install --noautoconsole \ |
||||
|
--name=with-zvol \ |
||||
|
--cpu=host-passthrough \ |
||||
|
--vcpus=1 \ |
||||
|
--ram=4096 \ |
||||
|
--os-variant=fedora-rawhide \ |
||||
|
--disk=path=/var/lib/libvirt/images/with-zvol/root.img,target.dev=vda,bus=virtio,driver.discard=unmap,driver.io=io_uring,format=raw,sparse=True,blockio.logical_block_size=512,blockio.physical_block_size=512,serial=root,format=raw \ |
||||
|
--disk=path=/dev/zvol/data/domains/with-zvol/data,target.dev=vdb,bus=virtio,cache=directsync,blockio.logical_block_size=4096,blockio.physical_block_size=4096,driver.discard=unmap,driver.io=io_uring,serial=zvol \ |
||||
|
--network=none \ |
||||
|
--console=pty,target.type=virtio \ |
||||
|
--serial=pty \ |
||||
|
--disk=path=/var/lib/libvirt/images/with-zvol/cloud-init.iso,readonly=True \ |
||||
|
--import \ |
||||
|
--sysinfo=system.serial=ds=nocloud \ |
||||
|
--boot=uefi |
||||
|
} |
||||
|
|
||||
|
readiness_wait() { |
||||
|
e2e_test_debug_log "setup: Waiting for VMs to become ready..." |
||||
|
for domain in standard with-fs with-zvol; do |
||||
|
e2e_test_debug_log "setup: Waiting for qemu guest agent to be running in domain '$domain'..." |
||||
|
until virsh qemu-agent-command "$domain" '{"execute":"guest-ping"}' &>/dev/null; do |
||||
|
sleep 2 |
||||
|
done |
||||
|
done |
||||
|
e2e_test_debug_log "setup: all VMs started successfully" |
||||
|
for domain in standard with-fs with-zvol; do |
||||
|
e2e_test_debug_log "setup: Waiting for cloud-init to complete in domain '$domain'..." |
||||
|
until qemu_exec "$domain" test -f /var/lib/cloud/instance/boot-finished; do |
||||
|
sleep 2 |
||||
|
done |
||||
|
done |
||||
|
if ! qemu_exec with-fs grep -q /test/virtiofs /proc/mounts; then |
||||
|
e2e_test_debug_log "setup: virtiofs not mounted in 'with-fs' domain" |
||||
|
return 1 |
||||
|
fi |
||||
|
if ! qemu_exec with-zvol grep -q /test/zvol /proc/mounts; then |
||||
|
e2e_test_debug_log "setup: zvol not mounted in 'with-zvol' domain" |
||||
|
return 1 |
||||
|
fi |
||||
|
e2e_test_debug_log "setup: VMs are ready" |
||||
|
} |
||||
|
|
||||
|
local fedora_url="https://download.fedoraproject.org/pub/fedora/linux/releases/42/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-42-1.1.x86_64.qcow2" |
||||
|
local fedora_img="/var/lib/libvirt/images/$(basename "$fedora_url")" |
||||
|
if [ ! -f "$fedora_img" ]; then |
||||
|
e2e_test_debug_log "setup: downloading Fedora Cloud image to $fedora_img" |
||||
|
mkdir -p /var/lib/libvirt/images/library |
||||
|
curl -sSfL -o "$fedora_img" "$fedora_url" |
||||
|
fi |
||||
|
e2e_test_debug_log "setup: Fedora Cloud image is at $fedora_img" |
||||
|
|
||||
|
# Cleanup any leftover artifacts from previous runs |
||||
|
cleanup |
||||
|
create_domains |
||||
|
readiness_wait |
||||
|
} |
||||
|
|
||||
|
teardown() { |
||||
|
cleanup |
||||
|
} |
||||
|
|
||||
|
@test "zvirt: setup selftest" { |
||||
|
e2e_test_debug_log "setup: provisioning completed" |
||||
|
} |
||||
|
|
||||
|
@test "zvirt: prune snapshots" { |
||||
|
# Take five snapshots in a row, each time creating and deleting a witness file |
||||
|
for snap in s1 s2 s3 s4 s5; do |
||||
|
# Create witness files in all three domains before taking snapshots |
||||
|
qemu_exec standard touch /test/rootfs/witness-file.$snap |
||||
|
qemu_exec with-fs touch /test/virtiofs/witness-file.$snap |
||||
|
qemu_exec with-zvol touch /test/zvol/witness-file.$snap |
||||
|
|
||||
|
# Verify that the witness files exist in the virtiofs host mount |
||||
|
run test -f /srv/with-fs/witness-file.$snap |
||||
|
assert_success |
||||
|
|
||||
|
# Take crash-consistent snapshots for all three domains |
||||
|
run zvirt snapshot -d standard -d with-zvol -d with-fs -s $snap |
||||
|
assert_success |
||||
|
|
||||
|
# Verify that the domains are still running |
||||
|
run virsh domstate standard |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
run virsh domstate with-fs |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
run virsh domstate with-zvol |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
|
||||
|
# Assert that the files created before the snapshot exist |
||||
|
run qemu_exec standard ls -1 /test/rootfs |
||||
|
assert_success |
||||
|
assert_output "witness-file.$snap" |
||||
|
run qemu_exec with-fs ls -1 /test/virtiofs |
||||
|
assert_success |
||||
|
assert_output "witness-file.$snap" |
||||
|
run qemu_exec with-zvol ls -1 /test/zvol |
||||
|
assert_success |
||||
|
assert_output "witness-file.$snap" |
||||
|
|
||||
|
# Delete the witness files |
||||
|
run qemu_exec standard rm /test/rootfs/witness-file.$snap |
||||
|
assert_success |
||||
|
run qemu_exec with-fs rm /test/virtiofs/witness-file.$snap |
||||
|
assert_success |
||||
|
run qemu_exec with-zvol rm /test/zvol/witness-file.$snap |
||||
|
assert_success |
||||
|
|
||||
|
# Sync all filesystems |
||||
|
run qemu_exec standard sync |
||||
|
assert_success |
||||
|
run qemu_exec with-fs sync |
||||
|
assert_success |
||||
|
run qemu_exec with-zvol sync |
||||
|
assert_success |
||||
|
|
||||
|
# Wait a moment to ensure all writes are flushed |
||||
|
sleep 2 |
||||
|
|
||||
|
# Verify that the witness files have been deleted in the virtiofs host mount |
||||
|
run test -f /srv/with-fs/witness-file.$snap |
||||
|
assert_failure |
||||
|
done |
||||
|
|
||||
|
# List snapshots and verify their existence |
||||
|
run zvirt list -d standard -d with-zvol -d with-fs |
||||
|
assert_success |
||||
|
assert_output "Snapshots for domain 'standard': |
||||
|
- s1 |
||||
|
- s2 |
||||
|
- s3 |
||||
|
- s4 |
||||
|
- s5 |
||||
|
Snapshots for domain 'with-zvol': |
||||
|
- s1 |
||||
|
- s2 |
||||
|
- s3 |
||||
|
- s4 |
||||
|
- s5 |
||||
|
Snapshots for domain 'with-fs': |
||||
|
- s1 |
||||
|
- s2 |
||||
|
- s3 |
||||
|
- s4 |
||||
|
- s5" |
||||
|
|
||||
|
# Prune snapshots to keep only the latest two |
||||
|
run zvirt prune -k 2 -d standard -d with-zvol -d with-fs |
||||
|
assert_success |
||||
|
|
||||
|
# List snapshots and verify their existence |
||||
|
run zvirt list -d standard -d with-zvol -d with-fs |
||||
|
assert_success |
||||
|
assert_output "Snapshots for domain 'standard': |
||||
|
- s4 |
||||
|
- s5 |
||||
|
Snapshots for domain 'with-zvol': |
||||
|
- s4 |
||||
|
- s5 |
||||
|
Snapshots for domain 'with-fs': |
||||
|
- s4 |
||||
|
- s5" |
||||
|
|
||||
|
# Stop all domains |
||||
|
run virsh destroy standard |
||||
|
assert_success |
||||
|
run virsh destroy with-fs |
||||
|
assert_success |
||||
|
run virsh destroy with-zvol |
||||
|
assert_success |
||||
|
|
||||
|
# Revert snapshots in batch mode |
||||
|
run zvirt revert -d standard -d with-zvol -d with-fs -s s4 |
||||
|
assert_success |
||||
|
|
||||
|
# Check all domains have been shut off |
||||
|
run virsh domstate standard |
||||
|
assert_success |
||||
|
assert_output "shut off" |
||||
|
run virsh domstate with-fs |
||||
|
assert_success |
||||
|
assert_output "shut off" |
||||
|
run virsh domstate with-zvol |
||||
|
assert_success |
||||
|
assert_output "shut off" |
||||
|
|
||||
|
# Start all domains |
||||
|
run virsh start standard |
||||
|
assert_success |
||||
|
run virsh start with-fs |
||||
|
assert_success |
||||
|
run virsh start with-zvol |
||||
|
assert_success |
||||
|
|
||||
|
# Wait for all domains to be fully ready |
||||
|
readiness_wait |
||||
|
|
||||
|
# Verify that the witness files still exist after revert |
||||
|
run qemu_exec standard ls -1 /test/rootfs |
||||
|
assert_success |
||||
|
assert_output "witness-file.s4" |
||||
|
run qemu_exec with-fs ls -1 /test/virtiofs |
||||
|
assert_success |
||||
|
assert_output "witness-file.s4" |
||||
|
run qemu_exec with-zvol ls -1 /test/zvol |
||||
|
assert_success |
||||
|
assert_output "witness-file.s4" |
||||
|
} |
||||
|
|
||||
|
@test "zvirt: take live snapshot in batch mode" { |
||||
|
# Create witness files in all three domains before taking snapshots |
||||
|
qemu_exec standard touch /test/rootfs/witness-file |
||||
|
qemu_exec with-fs touch /test/virtiofs/witness-file |
||||
|
qemu_exec with-zvol touch /test/zvol/witness-file |
||||
|
|
||||
|
# Verify that the witness files exist in the virtiofs host mount |
||||
|
run test -f /srv/with-fs/witness-file |
||||
|
assert_success |
||||
|
|
||||
|
# Take live snapshots for all three domains |
||||
|
run zvirt snapshot -b -d standard -d with-zvol -d with-fs -s backup1 -l |
||||
|
assert_success |
||||
|
|
||||
|
# Verify that the domains are still running |
||||
|
run virsh domstate standard |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
run virsh domstate with-fs |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
run virsh domstate with-zvol |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
|
||||
|
# Assert that the files created before the snapshot exist |
||||
|
run qemu_exec standard ls -1 /test/rootfs |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
run qemu_exec with-fs ls -1 /test/virtiofs |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
run qemu_exec with-zvol ls -1 /test/zvol |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
|
||||
|
# List snapshots and verify their existence |
||||
|
run zvirt list -d standard -d with-zvol -d with-fs |
||||
|
assert_success |
||||
|
assert_output "Snapshots for domain 'standard': |
||||
|
- backup1 |
||||
|
Snapshots for domain 'with-zvol': |
||||
|
- backup1 |
||||
|
Snapshots for domain 'with-fs': |
||||
|
- backup1" |
||||
|
|
||||
|
# Attempt to take the same snapshot again and expect failure |
||||
|
run zvirt snapshot -b -d standard -d with-zvol -d with-fs -s backup1 -l |
||||
|
assert_failure |
||||
|
assert_output --partial "Snapshot 'backup1' already exists." |
||||
|
assert_output --partial "standard:" |
||||
|
assert_output --partial "with-zvol:" |
||||
|
assert_output --partial "with-fs:" |
||||
|
assert_output --partial "Pre-flight checks failed." |
||||
|
|
||||
|
# Delete the witness files |
||||
|
run qemu_exec standard rm /test/rootfs/witness-file |
||||
|
assert_success |
||||
|
run qemu_exec with-fs rm /test/virtiofs/witness-file |
||||
|
assert_success |
||||
|
run qemu_exec with-zvol rm /test/zvol/witness-file |
||||
|
assert_success |
||||
|
|
||||
|
# Sync all filesystems |
||||
|
run qemu_exec standard sync |
||||
|
assert_success |
||||
|
run qemu_exec with-fs sync |
||||
|
assert_success |
||||
|
run qemu_exec with-zvol sync |
||||
|
assert_success |
||||
|
|
||||
|
# Verify that the witness files have been deleted in the virtiofs host mount |
||||
|
run test -f /srv/with-fs/witness-file |
||||
|
assert_failure |
||||
|
|
||||
|
# Stop all domains |
||||
|
run virsh destroy standard |
||||
|
assert_success |
||||
|
run virsh destroy with-fs |
||||
|
assert_success |
||||
|
run virsh destroy with-zvol |
||||
|
assert_success |
||||
|
|
||||
|
# Revert snapshots in batch mode |
||||
|
run zvirt revert -b -d standard -d with-zvol -d with-fs -s backup1 |
||||
|
assert_success |
||||
|
|
||||
|
# Check all domains are running again |
||||
|
run virsh domstate standard |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
run virsh domstate with-fs |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
run virsh domstate with-zvol |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
|
||||
|
# Verify that the witness files still exist after revert |
||||
|
run qemu_exec standard ls -1 /test/rootfs |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
run qemu_exec with-fs ls -1 /test/virtiofs |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
run qemu_exec with-zvol ls -1 /test/zvol |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
} |
||||
|
|
||||
|
@test "zvirt: take live snapshot without batch mode" { |
||||
|
# Create witness files in all three domains before taking snapshots |
||||
|
qemu_exec standard touch /test/rootfs/witness-file |
||||
|
qemu_exec with-fs touch /test/virtiofs/witness-file |
||||
|
qemu_exec with-zvol touch /test/zvol/witness-file |
||||
|
|
||||
|
# Verify that the witness files exist in the virtiofs host mount |
||||
|
run test -f /srv/with-fs/witness-file |
||||
|
assert_success |
||||
|
|
||||
|
# Take live snapshots for all three domains |
||||
|
run zvirt snapshot -d standard -d with-zvol -d with-fs -s backup1 -l |
||||
|
assert_success |
||||
|
|
||||
|
# Verify that the domains are still running |
||||
|
run virsh domstate standard |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
run virsh domstate with-fs |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
run virsh domstate with-zvol |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
|
||||
|
# Assert that the files created before the snapshot exist |
||||
|
run qemu_exec standard ls -1 /test/rootfs |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
run qemu_exec with-fs ls -1 /test/virtiofs |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
run qemu_exec with-zvol ls -1 /test/zvol |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
|
||||
|
# List snapshots and verify their existence |
||||
|
run zvirt list -d standard -d with-zvol -d with-fs |
||||
|
assert_success |
||||
|
assert_output "Snapshots for domain 'standard': |
||||
|
- backup1 |
||||
|
Snapshots for domain 'with-zvol': |
||||
|
- backup1 |
||||
|
Snapshots for domain 'with-fs': |
||||
|
- backup1" |
||||
|
|
||||
|
# Attempt to take the same snapshot again and expect failure |
||||
|
run zvirt snapshot -d standard -d with-zvol -d with-fs -s backup1 -l |
||||
|
assert_failure |
||||
|
assert_output --partial "Snapshot 'backup1' already exists." |
||||
|
assert_output --partial "standard:" |
||||
|
assert_output --partial "with-zvol:" |
||||
|
assert_output --partial "with-fs:" |
||||
|
assert_output --partial "Pre-flight checks failed." |
||||
|
|
||||
|
# Delete the witness files |
||||
|
run qemu_exec standard rm /test/rootfs/witness-file |
||||
|
assert_success |
||||
|
run qemu_exec with-fs rm /test/virtiofs/witness-file |
||||
|
assert_success |
||||
|
run qemu_exec with-zvol rm /test/zvol/witness-file |
||||
|
assert_success |
||||
|
|
||||
|
# Sync all filesystems |
||||
|
run qemu_exec standard sync |
||||
|
assert_success |
||||
|
run qemu_exec with-fs sync |
||||
|
assert_success |
||||
|
run qemu_exec with-zvol sync |
||||
|
assert_success |
||||
|
|
||||
|
# Verify that the witness files have been deleted in the virtiofs host mount |
||||
|
run test -f /srv/with-fs/witness-file |
||||
|
assert_failure |
||||
|
|
||||
|
# Stop all domains |
||||
|
run virsh destroy standard |
||||
|
assert_success |
||||
|
run virsh destroy with-fs |
||||
|
assert_success |
||||
|
run virsh destroy with-zvol |
||||
|
assert_success |
||||
|
|
||||
|
# Revert snapshots in batch mode |
||||
|
run zvirt revert -d standard -d with-zvol -d with-fs -s backup1 |
||||
|
assert_success |
||||
|
|
||||
|
# Check all domains are running again |
||||
|
run virsh domstate standard |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
run virsh domstate with-fs |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
run virsh domstate with-zvol |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
|
||||
|
# Verify that the witness files still exist after revert |
||||
|
run qemu_exec standard ls -1 /test/rootfs |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
run qemu_exec with-fs ls -1 /test/virtiofs |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
run qemu_exec with-zvol ls -1 /test/zvol |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
} |
||||
|
|
||||
|
@test "zvirt: take crash-consistent snapshot without batch mode" { |
||||
|
# Create witness files in all three domains before taking snapshots |
||||
|
qemu_exec standard touch /test/rootfs/witness-file |
||||
|
qemu_exec with-fs touch /test/virtiofs/witness-file |
||||
|
qemu_exec with-zvol touch /test/zvol/witness-file |
||||
|
|
||||
|
# Verify that the witness files exist in the virtiofs host mount |
||||
|
run test -f /srv/with-fs/witness-file |
||||
|
assert_success |
||||
|
|
||||
|
# Take crash-consistent snapshots for all three domains |
||||
|
run zvirt snapshot -d standard -d with-zvol -d with-fs -s backup1 |
||||
|
assert_success |
||||
|
|
||||
|
# Verify that the domains are still running |
||||
|
run virsh domstate standard |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
run virsh domstate with-fs |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
run virsh domstate with-zvol |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
|
||||
|
# Assert that the files created before the snapshot exist |
||||
|
run qemu_exec standard ls -1 /test/rootfs |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
run qemu_exec with-fs ls -1 /test/virtiofs |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
run qemu_exec with-zvol ls -1 /test/zvol |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
|
||||
|
# List snapshots and verify their existence |
||||
|
run zvirt list -d standard -d with-zvol -d with-fs |
||||
|
assert_success |
||||
|
assert_output "Snapshots for domain 'standard': |
||||
|
- backup1 |
||||
|
Snapshots for domain 'with-zvol': |
||||
|
- backup1 |
||||
|
Snapshots for domain 'with-fs': |
||||
|
- backup1" |
||||
|
|
||||
|
# Attempt to take the same snapshot again and expect failure |
||||
|
run zvirt snapshot -d standard -d with-zvol -d with-fs -s backup1 |
||||
|
assert_failure |
||||
|
assert_output --partial "Snapshot 'backup1' already exists." |
||||
|
assert_output --partial "standard:" |
||||
|
assert_output --partial "with-zvol:" |
||||
|
assert_output --partial "with-fs:" |
||||
|
assert_output --partial "Pre-flight checks failed." |
||||
|
|
||||
|
# Delete the witness files |
||||
|
run qemu_exec standard rm /test/rootfs/witness-file |
||||
|
assert_success |
||||
|
run qemu_exec with-fs rm /test/virtiofs/witness-file |
||||
|
assert_success |
||||
|
run qemu_exec with-zvol rm /test/zvol/witness-file |
||||
|
assert_success |
||||
|
|
||||
|
# Sync all filesystems |
||||
|
run qemu_exec standard sync |
||||
|
assert_success |
||||
|
run qemu_exec with-fs sync |
||||
|
assert_success |
||||
|
run qemu_exec with-zvol sync |
||||
|
assert_success |
||||
|
|
||||
|
# Wait a moment to ensure all writes are flushed |
||||
|
sleep 2 |
||||
|
|
||||
|
# Verify that the witness files have been deleted in the virtiofs host mount |
||||
|
run test -f /srv/with-fs/witness-file |
||||
|
assert_failure |
||||
|
|
||||
|
# Stop all domains |
||||
|
run virsh destroy standard |
||||
|
assert_success |
||||
|
run virsh destroy with-fs |
||||
|
assert_success |
||||
|
run virsh destroy with-zvol |
||||
|
assert_success |
||||
|
|
||||
|
# Revert snapshots in batch mode |
||||
|
run zvirt revert -d standard -d with-zvol -d with-fs -s backup1 |
||||
|
assert_success |
||||
|
|
||||
|
# Check all domains have been shut off |
||||
|
run virsh domstate standard |
||||
|
assert_success |
||||
|
assert_output "shut off" |
||||
|
run virsh domstate with-fs |
||||
|
assert_success |
||||
|
assert_output "shut off" |
||||
|
run virsh domstate with-zvol |
||||
|
assert_success |
||||
|
assert_output "shut off" |
||||
|
|
||||
|
# Start all domains |
||||
|
run virsh start standard |
||||
|
assert_success |
||||
|
run virsh start with-fs |
||||
|
assert_success |
||||
|
run virsh start with-zvol |
||||
|
assert_success |
||||
|
|
||||
|
# Wait for all domains to be fully ready |
||||
|
readiness_wait |
||||
|
|
||||
|
# Verify that the witness files still exist after revert |
||||
|
run qemu_exec standard ls -1 /test/rootfs |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
run qemu_exec with-fs ls -1 /test/virtiofs |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
run qemu_exec with-zvol ls -1 /test/zvol |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
} |
||||
|
|
||||
|
@test "zvirt: take crash-consistent snapshot with batch mode" { |
||||
|
# Create witness files in all three domains before taking snapshots |
||||
|
qemu_exec standard touch /test/rootfs/witness-file |
||||
|
qemu_exec with-fs touch /test/virtiofs/witness-file |
||||
|
qemu_exec with-zvol touch /test/zvol/witness-file |
||||
|
|
||||
|
# Verify that the witness files exist in the virtiofs host mount |
||||
|
run test -f /srv/with-fs/witness-file |
||||
|
assert_success |
||||
|
|
||||
|
# Take crash-consistent snapshots for all three domains |
||||
|
run zvirt snapshot -b -d standard -d with-zvol -d with-fs -s backup1 |
||||
|
assert_success |
||||
|
|
||||
|
# Verify that the domains are still running |
||||
|
run virsh domstate standard |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
run virsh domstate with-fs |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
run virsh domstate with-zvol |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
|
||||
|
# Assert that the files created before the snapshot exist |
||||
|
run qemu_exec standard ls -1 /test/rootfs |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
run qemu_exec with-fs ls -1 /test/virtiofs |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
run qemu_exec with-zvol ls -1 /test/zvol |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
|
||||
|
# List snapshots and verify their existence |
||||
|
run zvirt list -d standard -d with-zvol -d with-fs |
||||
|
assert_success |
||||
|
assert_output "Snapshots for domain 'standard': |
||||
|
- backup1 |
||||
|
Snapshots for domain 'with-zvol': |
||||
|
- backup1 |
||||
|
Snapshots for domain 'with-fs': |
||||
|
- backup1" |
||||
|
|
||||
|
# Attempt to take the same snapshot again and expect failure |
||||
|
run zvirt snapshot -b -d standard -d with-zvol -d with-fs -s backup1 |
||||
|
assert_failure |
||||
|
assert_output --partial "Snapshot 'backup1' already exists." |
||||
|
assert_output --partial "standard:" |
||||
|
assert_output --partial "with-zvol:" |
||||
|
assert_output --partial "with-fs:" |
||||
|
assert_output --partial "Pre-flight checks failed." |
||||
|
|
||||
|
# Delete the witness files |
||||
|
run qemu_exec standard rm /test/rootfs/witness-file |
||||
|
assert_success |
||||
|
run qemu_exec with-fs rm /test/virtiofs/witness-file |
||||
|
assert_success |
||||
|
run qemu_exec with-zvol rm /test/zvol/witness-file |
||||
|
assert_success |
||||
|
|
||||
|
# Sync all filesystems |
||||
|
run qemu_exec standard sync |
||||
|
assert_success |
||||
|
run qemu_exec with-fs sync |
||||
|
assert_success |
||||
|
run qemu_exec with-zvol sync |
||||
|
assert_success |
||||
|
|
||||
|
# Wait a moment to ensure all writes are flushed |
||||
|
sleep 2 |
||||
|
|
||||
|
# Verify that the witness files have been deleted in the virtiofs host mount |
||||
|
run test -f /srv/with-fs/witness-file |
||||
|
assert_failure |
||||
|
|
||||
|
# Stop all domains |
||||
|
run virsh destroy standard |
||||
|
assert_success |
||||
|
run virsh destroy with-fs |
||||
|
assert_success |
||||
|
run virsh destroy with-zvol |
||||
|
assert_success |
||||
|
|
||||
|
# Revert snapshots in batch mode |
||||
|
run zvirt revert -b -d standard -d with-zvol -d with-fs -s backup1 |
||||
|
assert_success |
||||
|
|
||||
|
# Check all domains are running again |
||||
|
run virsh domstate standard |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
run virsh domstate with-fs |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
run virsh domstate with-zvol |
||||
|
assert_success |
||||
|
assert_output "running" |
||||
|
|
||||
|
# Wait for all domains to be fully ready |
||||
|
readiness_wait |
||||
|
|
||||
|
# Verify that the witness files still exist after revert |
||||
|
run qemu_exec standard ls -1 /test/rootfs |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
run qemu_exec with-fs ls -1 /test/virtiofs |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
run qemu_exec with-zvol ls -1 /test/zvol |
||||
|
assert_success |
||||
|
assert_output "witness-file" |
||||
|
} |
||||
Loading…
Reference in new issue