|
1 | 1 | import pytest |
2 | 2 |
|
| 3 | +from lib import config |
3 | 4 | from lib.host import Host |
4 | 5 | from lib.sr import SR |
| 6 | +from lib.vdi import ImageFormat |
5 | 7 | from lib.vm import VM |
6 | 8 | from tests.storage import cold_migration_then_come_back, live_storage_migration_then_come_back |
7 | 9 |
|
| 10 | +from typing import Generator |
| 11 | + |
8 | 12 | # Requirements: |
9 | 13 | # From --hosts parameter: |
10 | 14 | # - host(A1): first XCP-ng host >= 8.2 with an additional unused disk for the SR. |
|
14 | 18 | # And: |
15 | 19 | # - access to XCP-ng RPM repository from hostA1 |
16 | 20 |
|
| 21 | +@pytest.fixture(scope='package') |
| 22 | +def nfs_sr(host: Host, image_format: ImageFormat) -> Generator[SR, None, None]: |
| 23 | + """ |
| 24 | + A NFS SR on first host. |
| 25 | +
|
| 26 | + Note: this fixture is already present in `tests/storage/nfs`, but it's scoped to the `nfs` package |
| 27 | + """ |
| 28 | + nfs_device_config = config.sr_device_config("NFS_DEVICE_CONFIG") | {'preferred-image-formats': image_format} |
| 29 | + sr = host.sr_create('nfs', "NFS-SR-test", nfs_device_config, shared=True) |
| 30 | + yield sr |
| 31 | + sr.destroy() |
| 32 | + |
17 | 33 | @pytest.mark.small_vm # run with a small VM to test the features |
18 | 34 | @pytest.mark.big_vm # and ideally with a big VM to test it scales |
19 | 35 | class Test: |
20 | 36 | def test_live_intrapool_shared_migration(self, host: Host, hostA2: Host, vm_on_linstor_sr: VM) -> None: |
21 | 37 | sr = vm_on_linstor_sr.get_sr() |
22 | 38 | live_storage_migration_then_come_back(vm_on_linstor_sr, host, hostA2, sr) |
23 | 39 |
|
24 | | - def test_cold_intrapool_migration( |
25 | | - self, host: Host, hostA2: Host, vm_on_linstor_sr: VM, xfs_sr_on_hostA2: SR |
26 | | - ) -> None: |
27 | | - cold_migration_then_come_back(vm_on_linstor_sr, host, hostA2, xfs_sr_on_hostA2) |
| 40 | + def test_cold_intrapool_migration(self, host: Host, hostA2: Host, vm_on_linstor_sr: VM, nfs_sr: SR) -> None: |
| 41 | + cold_migration_then_come_back(vm_on_linstor_sr, host, hostA2, nfs_sr) |
28 | 42 |
|
29 | | - def test_live_intrapool_migration( |
30 | | - self, host: Host, hostA2: Host, vm_on_linstor_sr: VM, xfs_sr_on_hostA2: SR |
31 | | - ) -> None: |
32 | | - live_storage_migration_then_come_back(vm_on_linstor_sr, host, hostA2, xfs_sr_on_hostA2) |
| 43 | + def test_live_intrapool_migration(self, host: Host, hostA2: Host, vm_on_linstor_sr: VM, nfs_sr: SR) -> None: |
| 44 | + live_storage_migration_then_come_back(vm_on_linstor_sr, host, hostA2, nfs_sr) |
0 commit comments