-
Notifications
You must be signed in to change notification settings - Fork 6
Implement storage nfs-on-slave test #341
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
import pytest | ||
|
||
from lib.commands import SSHCommandFailed | ||
from lib.common import vm_image, wait_for | ||
from lib.vdi import VDI | ||
from tests.storage import vdi_is_open | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from lib.vm import VM | ||
|
||
# Requirements: | ||
# - one XCP-ng host >= 8.0 with an additional unused disk for the SR | ||
|
||
|
@@ -30,6 +37,41 @@ def test_vdi_is_not_open(self, dispatch_nfs): | |
vdi = dispatch_nfs | ||
assert not vdi_is_open(vdi) | ||
|
||
@pytest.mark.small_vm | ||
@pytest.mark.usefixtures('hostA2') | ||
# Make sure this fixture is called before the parametrized one | ||
@pytest.mark.usefixtures('vm_ref') | ||
@pytest.mark.parametrize('dispatch_nfs', ['vm_on_nfs_sr'], indirect=True) | ||
def test_plugin_nfs_on_on_slave(self, dispatch_nfs: 'VM'): | ||
vm = dispatch_nfs | ||
vm.start() | ||
vm.wait_for_os_booted() | ||
host = vm.get_residence_host() | ||
|
||
vdi = VDI(vm.vdi_uuids()[0], host=host) | ||
|
||
# TODO: Use vdi.get_image_format() once available, instead of | ||
# hard-coded ".vhd". | ||
vdi_path = f"/run/sr-mount/{vdi.sr.uuid}/{vdi.uuid}.vhd" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On QCOW2 branch, you can look at There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good, I'll replace the comment with:
|
||
|
||
# nfs-on-slave returns an error when the VDI is open on the host. | ||
# Otherwise, it return "success", including in case "path" doesn't exist | ||
with pytest.raises(SSHCommandFailed) as excinfo: | ||
assert vm.is_running_on_host(host) | ||
host.call_plugin("nfs-on-slave", "check", {"path": vdi_path}) | ||
|
||
# The output of the host plugin would have "stdout: NfsCheckException" | ||
# and information about which process have the path open. | ||
assert "NfsCheckException" in excinfo.value.stdout | ||
|
||
for member in host.pool.hosts: | ||
# skip the host where the VM is running | ||
if member.uuid == host.uuid: | ||
continue | ||
member.call_plugin("nfs-on-slave", "check", {"path": vdi_path}) | ||
|
||
vm.shutdown(verify=True) | ||
|
||
@pytest.mark.small_vm # run with a small VM to test the features | ||
@pytest.mark.big_vm # and ideally with a big VM to test it scales | ||
# Make sure this fixture is called before the parametrized one | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually, we use the pool master for the VDI
host
parameter.But here I don't thing it's a problem.