|
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 | + device_list = " ".join(devices) |
| 34 | + host.ssh(['vgcreate', GROUP_NAME] + devices) |
| 35 | + if provisioning_type == 'thin': |
| 36 | + host.ssh(['lvcreate', '-l', '100%FREE', '-T', STORAGE_POOL_NAME]) |
34 | 37 |
|
35 |
| - yield device |
| 38 | + yield devices |
36 | 39 |
|
37 | 40 | for host in hosts:
|
38 | 41 | host.ssh(['vgremove', '-f', GROUP_NAME])
|
39 |
| - host.ssh(['pvremove', device]) |
| 42 | + for device in devices: |
| 43 | + host.ssh(['pvremove', device]) |
| 44 | + |
| 45 | +@pytest.fixture(scope="package") |
| 46 | +def storage_pool_name(provisioning_type): |
| 47 | + return GROUP_NAME if provisioning_type == "thick" else STORAGE_POOL_NAME |
| 48 | + |
| 49 | +@pytest.fixture(params=["thin", "thick"], scope="session") |
| 50 | +def provisioning_type(request): |
| 51 | + return request.param |
40 | 52 |
|
41 | 53 | @pytest.fixture(scope='package')
|
42 |
| -def pool_with_linstor(hostA2, lvm_disk, pool_with_saved_yum_state): |
| 54 | +def pool_with_linstor(hostA2, lvm_disks, pool_with_saved_yum_state): |
| 55 | + import concurrent.futures |
43 | 56 | pool = pool_with_saved_yum_state
|
44 |
| - for host in pool.hosts: |
| 57 | + |
| 58 | + def is_linstor_installed(host): |
45 | 59 | if host.is_package_installed(LINSTOR_PACKAGE):
|
46 | 60 | raise Exception(
|
47 | 61 | f'{LINSTOR_PACKAGE} is already installed on host {host}. This should not be the case.'
|
48 | 62 | )
|
49 | 63 |
|
50 |
| - for host in pool.hosts: |
| 64 | + with concurrent.futures.ThreadPoolExecutor() as executor: |
| 65 | + executor.map(is_linstor_installed, pool.hosts) |
| 66 | + |
| 67 | + def install_linstor(host): |
| 68 | + logging.info(f"Installing {LINSTOR_PACKAGE} on host {host}...") |
51 | 69 | host.yum_install([LINSTOR_RELEASE_PACKAGE])
|
52 | 70 | host.yum_install([LINSTOR_PACKAGE], enablerepo="xcp-ng-linstor-testing")
|
53 | 71 | # Needed because the linstor driver is not in the xapi sm-plugins list
|
54 | 72 | # before installing the LINSTOR packages.
|
55 | 73 | host.ssh(["systemctl", "restart", "multipathd"])
|
56 | 74 | host.restart_toolstack(verify=True)
|
57 | 75 |
|
| 76 | + with concurrent.futures.ThreadPoolExecutor() as executor: |
| 77 | + executor.map(install_linstor, pool.hosts) |
| 78 | + |
58 | 79 | yield pool
|
59 | 80 |
|
| 81 | + def remove_linstor(host): |
| 82 | + logging.info(f"Cleaning up {LINSTOR_PACKAGE} from host {host}...") |
| 83 | + host.yum_remove([LINSTOR_PACKAGE]) |
| 84 | + |
| 85 | + with concurrent.futures.ThreadPoolExecutor() as executor: |
| 86 | + executor.map(remove_linstor, pool.hosts) |
| 87 | + |
60 | 88 | @pytest.fixture(scope='package')
|
61 |
| -def linstor_sr(pool_with_linstor): |
| 89 | +def linstor_sr(pool_with_linstor, provisioning_type, storage_pool_name): |
62 | 90 | sr = pool_with_linstor.master.sr_create('linstor', 'LINSTOR-SR-test', {
|
63 |
| - 'group-name': STORAGE_POOL_NAME, |
| 91 | + 'group-name': storage_pool_name, |
64 | 92 | 'redundancy': str(min(len(pool_with_linstor.hosts), 3)),
|
65 |
| - 'provisioning': 'thin' |
| 93 | + 'provisioning': provisioning_type |
66 | 94 | }, shared=True)
|
67 | 95 | yield sr
|
68 | 96 | sr.destroy()
|
|
0 commit comments