Skip to content

Commit ff851c8

Browse files
committed
quicktest: split QT into SR specific and common suites
Currently we are calling quicktest for all SRs. The problem is that it takes long time to run and some tests are not related to the type of the SR. This patch creates one new test that runs the common suites one, and we only run SR specific tests per SR. Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@vates.tech>
1 parent c6e1187 commit ff851c8

2 files changed

Lines changed: 59 additions & 3 deletions

File tree

lib/sr.py

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
from __future__ import annotations
22

3+
import pytest
4+
5+
import enum
6+
import functools
37
import logging
8+
import shlex
49
import time
510

611
import lib.commands as commands
@@ -26,6 +31,33 @@
2631
from lib.host import Host
2732
from lib.pool import Pool
2833

34+
QUICKTEST_BIN = "/opt/xensource/debug/quicktest"
35+
36+
QUICKTEST_SR_SUITES = (
37+
"cbt,copy,SR tests,Quicktest_vdi,Quicktest_async_calls,"
38+
"Quicktest_vm_import_export,Quicktest_vm_lifecycle,Quicktest_vm_snapshot,"
39+
"Quicktest_vdi_ops_data_integrity,Quicktest_max_vdi_size,Quicktest_static_vdis"
40+
)
41+
42+
QUICKTEST_COMMON_SUITES = (
43+
"Quicktest_example,Quicktest_message,xenstore,event,import_raw_vdi,"
44+
"Quicktest_date,Quicktest_crypt_r,http,unixext,Timer"
45+
)
46+
47+
class QuicktestScoping(enum.Enum):
48+
NO_PARAM = enum.auto()
49+
RUN_ONLY_PARAM = enum.auto()
50+
SR_ONLY_PARAM = enum.auto()
51+
52+
@functools.lru_cache(maxsize=None)
53+
def _quicktest_scoping(hostname_or_ip: str) -> QuicktestScoping:
54+
help_output = commands.ssh(hostname_or_ip, f"{QUICKTEST_BIN} --help", check=False)
55+
if "-sr-only" in help_output:
56+
return QuicktestScoping.SR_ONLY_PARAM
57+
if "-run-only" in help_output:
58+
return QuicktestScoping.RUN_ONLY_PARAM
59+
return QuicktestScoping.NO_PARAM
60+
2961
class SR:
3062
xe_prefix = 'sr'
3163

@@ -230,14 +262,29 @@ def create_vdi(
230262
vdi_uuid = self.pool.master.xe('vdi-create', args)
231263
return VDI(vdi_uuid, sr=self)
232264

233-
def run_quicktest(self) -> None:
234-
logging.info(f"Run quicktest on SR {self.uuid}")
265+
def run_quicktest(self, sr_specific: bool = True) -> None:
266+
scoping = _quicktest_scoping(self.pool.master.hostname_or_ip)
267+
cmd = f"{QUICKTEST_BIN} -sr {self.uuid}"
268+
269+
if scoping is QuicktestScoping.SR_ONLY_PARAM:
270+
cmd += " -sr-only" if sr_specific else " -common-only"
271+
elif scoping is QuicktestScoping.RUN_ONLY_PARAM:
272+
suites = QUICKTEST_SR_SUITES if sr_specific else QUICKTEST_COMMON_SUITES
273+
cmd += f" -run-only {shlex.quote(suites)}"
274+
elif not sr_specific:
275+
# QuicktestScoping.NO_PARAM: no way to select just the common suites, and every
276+
# per-SR pass on this host is already unfiltered, so this run adds nothing.
277+
pytest.skip("quicktest has no scoping support on this host; "
278+
"common suites are already covered by the per-SR runs.")
279+
280+
logging.info(f"Run quicktest on SR {self.uuid}: {cmd}")
281+
235282
# Always display the output of quicktest, failed or not.
236283
# This will duplicate the output in some cases, but it ensures we always have it for failure analysis,
237284
# even when quicktest leaves SRs in a state which makes teardown fail (in this case, pytest often doesn't
238285
# manage to display the details of the failed command, for a reason unknown - no usable reproducer found)
239286
try:
240-
output = self.pool.master.ssh(f'/opt/xensource/debug/quicktest -sr {self.uuid}')
287+
output = self.pool.master.ssh(cmd)
241288
logging.info(f"Quicktest output: {output}")
242289
except commands.SSHCommandFailed as e:
243290
logging.error(f"Quicktest output: {e.stdout}")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from __future__ import annotations
2+
3+
import pytest
4+
5+
from lib.sr import SR
6+
7+
@pytest.mark.quicktest
8+
def test_common_quicktest(local_sr_on_hostA1: SR) -> None:
9+
local_sr_on_hostA1.run_quicktest(sr_specific=False)

0 commit comments

Comments
 (0)