Skip to content

Commit ab5e8e6

Browse files
Introduced provisioning_type and storage_pool_name fixtures to dynamically configure storage provisioning (thin or thick).
Refactored Linstor SR test cases to use the new fixtures, improving test coverage across provisioning types. Signed-off-by: Rushikesh Jadhav <[email protected]>
1 parent 8741367 commit ab5e8e6

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

tests/storage/linstor/conftest.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ def lvm_disks(host, sr_disks_for_all_hosts, provisioning_type):
4141
for device in devices:
4242
host.ssh(['pvremove', device])
4343

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
51+
4452
@pytest.fixture(scope='package')
4553
def pool_with_linstor(hostA2, lvm_disks, pool_with_saved_yum_state):
4654
import concurrent.futures
@@ -79,11 +87,11 @@ def remove_linstor(host):
7987
executor.map(remove_linstor, pool.hosts)
8088

8189
@pytest.fixture(scope='package')
82-
def linstor_sr(pool_with_linstor):
90+
def linstor_sr(pool_with_linstor, provisioning_type, storage_pool_name):
8391
sr = pool_with_linstor.master.sr_create('linstor', 'LINSTOR-SR-test', {
84-
'group-name': STORAGE_POOL_NAME,
92+
'group-name': storage_pool_name,
8593
'redundancy': str(min(len(pool_with_linstor.hosts), 3)),
86-
'provisioning': 'thin'
94+
'provisioning': provisioning_type
8795
}, shared=True)
8896
yield sr
8997
sr.destroy()

tests/storage/linstor/test_linstor_sr.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import pytest
33
import time
44

5-
from .conftest import STORAGE_POOL_NAME, LINSTOR_PACKAGE
5+
from .conftest import LINSTOR_PACKAGE
66
from lib.commands import SSHCommandFailed
77
from lib.common import wait_for, vm_image
88
from tests.storage import vdi_is_open
99

1010
# Requirements:
11-
# - one XCP-ng host >= 8.2 with an additional unused disk for the SR
11+
# - two or more XCP-ng hosts >= 8.2 with additional unused disk(s) for the SR
1212
# - access to XCP-ng RPM repository from the host
1313

1414
class TestLinstorSRCreateDestroy:
@@ -18,15 +18,15 @@ class TestLinstorSRCreateDestroy:
1818
and VM import.
1919
"""
2020

21-
def test_create_sr_without_linstor(self, host, lvm_disk):
21+
def test_create_sr_without_linstor(self, host, lvm_disks, provisioning_type, storage_pool_name):
2222
# This test must be the first in the series in this module
2323
assert not host.is_package_installed('python-linstor'), \
2424
"linstor must not be installed on the host at the beginning of the tests"
2525
try:
2626
sr = host.sr_create('linstor', 'LINSTOR-SR-test', {
27-
'group-name': STORAGE_POOL_NAME,
27+
'group-name': storage_pool_name,
2828
'redundancy': '1',
29-
'provisioning': 'thin'
29+
'provisioning': provisioning_type
3030
}, shared=True)
3131
try:
3232
sr.destroy()
@@ -36,13 +36,13 @@ def test_create_sr_without_linstor(self, host, lvm_disk):
3636
except SSHCommandFailed as e:
3737
logging.info("SR creation failed, as expected: {}".format(e))
3838

39-
def test_create_and_destroy_sr(self, pool_with_linstor):
39+
def test_create_and_destroy_sr(self, pool_with_linstor, provisioning_type, storage_pool_name):
4040
# Create and destroy tested in the same test to leave the host as unchanged as possible
4141
master = pool_with_linstor.master
4242
sr = master.sr_create('linstor', 'LINSTOR-SR-test', {
43-
'group-name': STORAGE_POOL_NAME,
43+
'group-name': storage_pool_name,
4444
'redundancy': '1',
45-
'provisioning': 'thin'
45+
'provisioning': provisioning_type
4646
}, shared=True)
4747
# import a VM in order to detect vm import issues here rather than in the vm_on_linstor_sr fixture used in
4848
# the next tests, because errors in fixtures break teardown
@@ -147,7 +147,7 @@ def _ensure_resource_remain_diskless(host, controller_option, volume_name, diskl
147147

148148
class TestLinstorDisklessResource:
149149
@pytest.mark.small_vm
150-
def test_diskless_kept(self, host, linstor_sr, vm_on_linstor_sr):
150+
def test_diskless_kept(self, host, linstor_sr, vm_on_linstor_sr, storage_pool_name):
151151
vm = vm_on_linstor_sr
152152
vdi_uuids = vm.vdi_uuids(sr_uuid=linstor_sr.uuid)
153153
vdi_uuid = vdi_uuids[0]
@@ -157,10 +157,12 @@ def test_diskless_kept(self, host, linstor_sr, vm_on_linstor_sr):
157157
for member in host.pool.hosts:
158158
controller_option += f"{member.hostname_or_ip},"
159159

160+
sr_group_name = "xcp-sr-" + storage_pool_name.replace("/", "_")
161+
160162
# Get volume name from VDI uuid
161163
# "xcp/volume/{vdi_uuid}/volume-name": "{volume_name}"
162164
output = host.ssh([
163-
"linstor-kv-tool", "--dump-volumes", "-g", "xcp-sr-linstor_group_thin_device",
165+
"linstor-kv-tool", "--dump-volumes", "-g", sr_group_name,
164166
"|", "grep", "volume-name", "|", "grep", vdi_uuid
165167
])
166168
volume_name = output.split(': ')[1].split('"')[1]

0 commit comments

Comments
 (0)