Skip to content

Conversation

tperard
Copy link
Member

@tperard tperard commented Jul 18, 2025

This new test ensures that the "nfs-on-slave" host-plugin does
check something, and return different result based on the environment.

  • TODO: Still need to figure out how to find the type of VDI, to have
    the extension for the path. It's currently hard-coded to .vhd.

@tperard tperard force-pushed the apd-nfs-on-slave branch from 6afd538 to d450bb2 Compare July 18, 2025 14:04
@tperard tperard force-pushed the apd-nfs-on-slave branch from d450bb2 to 81dd04c Compare July 18, 2025 14:57
@tperard tperard force-pushed the apd-nfs-on-slave branch from 81dd04c to b34c3f5 Compare July 25, 2025 15:35
@tperard tperard requested a review from Nambrok August 26, 2025 09:17
@tperard
Copy link
Member Author

tperard commented Sep 22, 2025

Just a rebase.

@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)
Copy link
Member

Choose a reason for hiding this comment

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

  • What is the objective behind using a parametrized fixture here?
  • A fixture that yields a VM usually has a name that starts with vm_
  • How to actually use the parametrized fixture in our job definitions in jobs.py and in Jenkins?

Copy link
Member Author

Choose a reason for hiding this comment

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

What is the objective behind using a parametrized fixture here?

Make it work.

I needed a VM with its disk on NFS SR, and every other test in test_nfs_sr.py uses this boilerplate.

Now I've read a bit more about pytest and fixtures and it looks like I can just remove this last line, replace dispatch_nfs by vm_on_nfs_sr, and it still works, like magic. I guess I can remove the vm_ref one as well.

Looks like I still have more to learn about pytest 😅

Copy link
Member

@stormi stormi Oct 1, 2025

Choose a reason for hiding this comment

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

I don't think you need to parametrize, here. It looks like you just want the vm_on_nfs_sr fixture. Unless you want the test to run with both NFS3 and NFS4+, in which case you need

    @pytest.mark.parametrize('dispatch_nfs', ['vm_on_nfs_sr', 'vm_on_nfs4_sr'], indirect=True)

Copy link
Member

Choose a reason for hiding this comment

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

CC @Nambrok who, IIRC, implemented this parametrization of the NFS tests.

Copy link
Member

Choose a reason for hiding this comment

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

@tperard This conversation was not resolved. I discussed with Damien and he said that it would make sense to run the test for both nfs and nfs4, as we do in the rest of the test file.

Comment on lines +44 to +47
vm.start()
vm.wait_for_os_booted()
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the start/shutdown be handled by a fixture? Looks like a test failure here would not shutdown that VM we started.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like this would break test_reboot which reboot the host before starting the guest.
Or do you mean adding a fixture that uses vm_on_nfs_sr?
But vm_on_nfs_sr does a vm.destroy(). Is that enough?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or do you mean adding a fixture that uses vm_on_nfs_sr?

Yes, that one.

But vm_on_nfs_sr does a vm.destroy(). Is that enough?

Looks so, then it can still be useful to clarify with a comment that the shutdown need not be in cleanup because of this.


@pytest.mark.small_vm
@pytest.mark.usefixtures('hostA2')
def test_plugin_nfs_on_on_slave(self, vm_on_nfs_sr: 'VM'):
Copy link
Contributor

Choose a reason for hiding this comment

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

A note on what we expect from this plugin would be nice.

Copy link
Member Author

Choose a reason for hiding this comment

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

There's a comment...

vm.wait_for_os_booted()
host = vm.get_residence_host()

vdi = VDI(vm.vdi_uuids()[0], host=host)
Copy link
Member

Choose a reason for hiding this comment

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

Can't it be just vdi = vm.vdis[0]?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know, vm.vdis looks like brand new code.

.. for functions that are going to be used by
test_plugin_nfs_on_on_slave().

Signed-off-by: Anthony PERARD <[email protected]>
This new test ensures that the "nfs-on-slave" host-plugin does
check something, and return different result based on the environment.

Signed-off-by: Anthony PERARD <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants