From a47df093d3b222c802a7b733cd6df636980d83cd Mon Sep 17 00:00:00 2001 From: Damien Thenot Date: Wed, 18 Dec 2024 13:38:48 +0100 Subject: [PATCH] Added tests for modifying userdevice higher than 3 on ISO VBD Signed-off-by: Damien Thenot --- tests/storage/userdevice/__init__.py | 0 tests/storage/userdevice/test_userdevice.py | 36 +++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/storage/userdevice/__init__.py create mode 100644 tests/storage/userdevice/test_userdevice.py diff --git a/tests/storage/userdevice/__init__.py b/tests/storage/userdevice/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/storage/userdevice/test_userdevice.py b/tests/storage/userdevice/test_userdevice.py new file mode 100644 index 000000000..906dfd09c --- /dev/null +++ b/tests/storage/userdevice/test_userdevice.py @@ -0,0 +1,36 @@ +import pytest +import logging + +# Requirements: +# - one XCP-ng host + +class TestUserDevice: + def _check_iso(self, vm): + return vm.ssh_with_result(["test", "-e", "/sys/class/block/sr0"]).returncode == 0 + + def _get_vbd_iso(self, vm): + return vm.host.xe("vbd-list", {"vm-uuid": vm.uuid, "device": "xvdd"}, minimal=True) + + def _set_userdevice(self, vm, vbd_uuid, userdevice): + logging.info("Setting userdevice for VBD {} of VM {} to {}".format(vbd_uuid, vm.uuid, userdevice)) + vm.host.xe("vbd-param-set", {"userdevice": str(userdevice), "uuid": vbd_uuid}) + + @pytest.mark.small_vm + def test_sr0_exist(self, imported_vm): + vm = imported_vm + vm.start() + vm.wait_for_os_booted() + assert self._check_iso(vm) + vm.shutdown(verify=True) + + @pytest.mark.small_vm + def test_change_userdevice(self, started_vm): + vm = started_vm + + vbd_uuid = self._get_vbd_iso(vm) + vm.shutdown(verify=True) + self._set_userdevice(vm, vbd_uuid, 4) + vm.start() + vm.wait_for_os_booted() + + assert self._check_iso(vm)