|
12 | 12 | LINSTOR_PACKAGE = 'xcp-ng-linstor' |
13 | 13 |
|
14 | 14 | @pytest.fixture(scope='package') |
15 | | -def lvm_disk(host, sr_disk_for_all_hosts): |
16 | | - device = '/dev/' + sr_disk_for_all_hosts |
| 15 | +def lvm_disks(host, sr_disks_for_all_hosts, provisioning_type): |
| 16 | + devices = [f"/dev/{disk}" for disk in sr_disks_for_all_hosts] |
17 | 17 | hosts = host.pool.hosts |
18 | 18 |
|
19 | 19 | for host in hosts: |
20 | | - try: |
21 | | - host.ssh(['pvcreate', '-ff', '-y', device]) |
22 | | - except commands.SSHCommandFailed as e: |
23 | | - if e.stdout.endswith('Mounted filesystem?'): |
24 | | - host.ssh(['vgremove', '-f', GROUP_NAME, '-y']) |
| 20 | + for device in devices: |
| 21 | + try: |
25 | 22 | host.ssh(['pvcreate', '-ff', '-y', device]) |
26 | | - elif e.stdout.endswith('excluded by a filter.'): |
27 | | - host.ssh(['wipefs', '-a', device]) |
28 | | - host.ssh(['pvcreate', '-ff', '-y', device]) |
29 | | - else: |
30 | | - raise e |
| 23 | + except commands.SSHCommandFailed as e: |
| 24 | + if e.stdout.endswith('Mounted filesystem?'): |
| 25 | + host.ssh(['vgremove', '-f', GROUP_NAME, '-y']) |
| 26 | + host.ssh(['pvcreate', '-ff', '-y', device]) |
| 27 | + elif e.stdout.endswith('excluded by a filter.'): |
| 28 | + host.ssh(['wipefs', '-a', device]) |
| 29 | + host.ssh(['pvcreate', '-ff', '-y', device]) |
| 30 | + else: |
| 31 | + raise e |
31 | 32 |
|
32 | | - host.ssh(['vgcreate', GROUP_NAME, device]) |
33 | | - host.ssh(['lvcreate', '-l', '100%FREE', '-T', STORAGE_POOL_NAME]) |
| 33 | + host.ssh(['vgcreate', GROUP_NAME] + devices) |
| 34 | + if provisioning_type == 'thin': |
| 35 | + host.ssh(['lvcreate', '-l', '100%FREE', '-T', STORAGE_POOL_NAME]) |
34 | 36 |
|
35 | | - yield device |
| 37 | + yield devices |
36 | 38 |
|
37 | 39 | for host in hosts: |
38 | 40 | host.ssh(['vgremove', '-f', GROUP_NAME]) |
39 | | - host.ssh(['pvremove', device]) |
| 41 | + for device in devices: |
| 42 | + host.ssh(['pvremove', device]) |
| 43 | + |
| 44 | +@pytest.fixture(scope="package") |
| 45 | +def storage_pool_name(provisioning_type): |
| 46 | + return GROUP_NAME if provisioning_type == "thick" else STORAGE_POOL_NAME |
| 47 | + |
| 48 | +@pytest.fixture(params=["thin", "thick"], scope="session") |
| 49 | +def provisioning_type(request): |
| 50 | + return request.param |
40 | 51 |
|
41 | 52 | @pytest.fixture(scope='package') |
42 | | -def pool_with_linstor(hostA2, lvm_disk, pool_with_saved_yum_state): |
| 53 | +def pool_with_linstor(hostA2, lvm_disks, pool_with_saved_yum_state): |
| 54 | + import concurrent.futures |
43 | 55 | pool = pool_with_saved_yum_state |
44 | | - for host in pool.hosts: |
| 56 | + |
| 57 | + def check_linstor_installed(host): |
45 | 58 | if host.is_package_installed(LINSTOR_PACKAGE): |
46 | 59 | raise Exception( |
47 | 60 | f'{LINSTOR_PACKAGE} is already installed on host {host}. This should not be the case.' |
48 | 61 | ) |
49 | 62 |
|
50 | | - for host in pool.hosts: |
| 63 | + with concurrent.futures.ThreadPoolExecutor() as executor: |
| 64 | + executor.map(check_linstor_installed, pool.hosts) |
| 65 | + |
| 66 | + def install_linstor(host): |
| 67 | + logging.info(f"Installing {LINSTOR_PACKAGE} on host {host}...") |
51 | 68 | host.yum_install([LINSTOR_RELEASE_PACKAGE]) |
52 | 69 | host.yum_install([LINSTOR_PACKAGE], enablerepo="xcp-ng-linstor-testing") |
53 | 70 | # Needed because the linstor driver is not in the xapi sm-plugins list |
54 | 71 | # before installing the LINSTOR packages. |
55 | 72 | host.ssh(["systemctl", "restart", "multipathd"]) |
56 | 73 | host.restart_toolstack(verify=True) |
57 | 74 |
|
| 75 | + with concurrent.futures.ThreadPoolExecutor() as executor: |
| 76 | + executor.map(install_linstor, pool.hosts) |
| 77 | + |
58 | 78 | yield pool |
59 | 79 |
|
| 80 | + # Need to remove this package as we have separate run of `test_create_sr_without_linstor` |
| 81 | + # for `thin` and `thick` `provisioning_type`. |
| 82 | + def remove_linstor(host): |
| 83 | + logging.info(f"Cleaning up python-linstor from host {host}...") |
| 84 | + host.yum_remove(["python-linstor"]) |
| 85 | + |
| 86 | + with concurrent.futures.ThreadPoolExecutor() as executor: |
| 87 | + executor.map(remove_linstor, pool.hosts) |
| 88 | + |
60 | 89 | @pytest.fixture(scope='package') |
61 | | -def linstor_sr(pool_with_linstor): |
| 90 | +def linstor_sr(pool_with_linstor, provisioning_type, storage_pool_name): |
62 | 91 | sr = pool_with_linstor.master.sr_create('linstor', 'LINSTOR-SR-test', { |
63 | | - 'group-name': STORAGE_POOL_NAME, |
| 92 | + 'group-name': storage_pool_name, |
64 | 93 | 'redundancy': str(min(len(pool_with_linstor.hosts), 3)), |
65 | | - 'provisioning': 'thin' |
| 94 | + 'provisioning': provisioning_type |
66 | 95 | }, shared=True) |
67 | 96 | yield sr |
68 | 97 | sr.destroy() |
|
0 commit comments