Skip to content

Commit 8741367

Browse files
Optimized Linstor installation and cleanup using concurrent execution, reducing setup time.
Signed-off-by: Rushikesh Jadhav <[email protected]>
1 parent 35db2f4 commit 8741367

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

tests/storage/linstor/conftest.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,42 @@ def lvm_disks(host, sr_disks_for_all_hosts, provisioning_type):
4242
host.ssh(['pvremove', device])
4343

4444
@pytest.fixture(scope='package')
45-
def pool_with_linstor(hostA2, lvm_disk, pool_with_saved_yum_state):
45+
def pool_with_linstor(hostA2, lvm_disks, pool_with_saved_yum_state):
46+
import concurrent.futures
4647
pool = pool_with_saved_yum_state
47-
for host in pool.hosts:
48+
49+
def check_linstor_installed(host):
4850
if host.is_package_installed(LINSTOR_PACKAGE):
4951
raise Exception(
5052
f'{LINSTOR_PACKAGE} is already installed on host {host}. This should not be the case.'
5153
)
5254

53-
for host in pool.hosts:
55+
with concurrent.futures.ThreadPoolExecutor() as executor:
56+
executor.map(check_linstor_installed, pool.hosts)
57+
58+
def install_linstor(host):
59+
logging.info(f"Installing {LINSTOR_PACKAGE} on host {host}...")
5460
host.yum_install([LINSTOR_RELEASE_PACKAGE])
5561
host.yum_install([LINSTOR_PACKAGE], enablerepo="xcp-ng-linstor-testing")
5662
# Needed because the linstor driver is not in the xapi sm-plugins list
5763
# before installing the LINSTOR packages.
5864
host.ssh(["systemctl", "restart", "multipathd"])
5965
host.restart_toolstack(verify=True)
6066

67+
with concurrent.futures.ThreadPoolExecutor() as executor:
68+
executor.map(install_linstor, pool.hosts)
69+
6170
yield pool
6271

72+
# Need to remove this package as we have separate run of `test_create_sr_without_linstor`
73+
# for `thin` and `thick` `provisioning_type`.
74+
def remove_linstor(host):
75+
logging.info(f"Cleaning up python-linstor from host {host}...")
76+
host.yum_remove(["python-linstor"])
77+
78+
with concurrent.futures.ThreadPoolExecutor() as executor:
79+
executor.map(remove_linstor, pool.hosts)
80+
6381
@pytest.fixture(scope='package')
6482
def linstor_sr(pool_with_linstor):
6583
sr = pool_with_linstor.master.sr_create('linstor', 'LINSTOR-SR-test', {

0 commit comments

Comments
 (0)