-
Notifications
You must be signed in to change notification settings - Fork 10
quicktest: split tests into SR specific and common ones #665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gthvn1
wants to merge
1
commit into
master
Choose a base branch
from
gtn-split-quicktest
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+63
−3
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,12 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
|
|
||
| import enum | ||
| import functools | ||
| import logging | ||
| import re | ||
| import shlex | ||
| import time | ||
|
|
||
| import lib.commands as commands | ||
|
|
@@ -26,6 +32,36 @@ | |
| from lib.host import Host | ||
| from lib.pool import Pool | ||
|
|
||
| QUICKTEST_BIN = "/opt/xensource/debug/quicktest" | ||
|
|
||
| QUICKTEST_SR_SUITES = ( | ||
| "cbt,copy,SR tests,Quicktest_vdi,Quicktest_async_calls," | ||
| "Quicktest_vm_import_export,Quicktest_vm_lifecycle,Quicktest_vm_snapshot," | ||
| "Quicktest_vdi_ops_data_integrity,Quicktest_max_vdi_size,Quicktest_static_vdis" | ||
| ) | ||
|
|
||
| QUICKTEST_COMMON_SUITES = ( | ||
| "Quicktest_example,Quicktest_message,xenstore,event,import_raw_vdi," | ||
| "Quicktest_date,Quicktest_crypt_r,http,unixext,Timer" | ||
| ) | ||
|
|
||
| class QuicktestScoping(enum.Enum): | ||
| WITH_TAG_PARAM = enum.auto() | ||
| RUN_ONLY_PARAM = enum.auto() | ||
| NO_PARAM = enum.auto() | ||
|
|
||
| @functools.lru_cache(maxsize=None) | ||
| def _quicktest_scoping(hostname_or_ip: str) -> QuicktestScoping: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: the host can be passed directly as a parameter and used as |
||
| tags_output = commands.ssh_with_result(hostname_or_ip, f"{QUICKTEST_BIN} -list-tags") | ||
| if tags_output.returncode == 0 and re.search(r"^sr:", tags_output.stdout, re.MULTILINE): | ||
| return QuicktestScoping.WITH_TAG_PARAM | ||
|
|
||
| help_output = commands.ssh(hostname_or_ip, f"{QUICKTEST_BIN} -help", check=False) | ||
| if "-run-only" in help_output: | ||
| return QuicktestScoping.RUN_ONLY_PARAM | ||
|
|
||
| return QuicktestScoping.NO_PARAM | ||
|
|
||
| class SR: | ||
| xe_prefix = 'sr' | ||
|
|
||
|
|
@@ -230,14 +266,29 @@ def create_vdi( | |
| vdi_uuid = self.pool.master.xe('vdi-create', args) | ||
| return VDI(vdi_uuid, sr=self) | ||
|
|
||
| def run_quicktest(self) -> None: | ||
| logging.info(f"Run quicktest on SR {self.uuid}") | ||
| def run_quicktest(self, sr_specific: bool = True) -> None: | ||
| scoping = _quicktest_scoping(self.pool.master.hostname_or_ip) | ||
| cmd = f"{QUICKTEST_BIN} -sr {self.uuid}" | ||
|
|
||
| if scoping is QuicktestScoping.WITH_TAG_PARAM: | ||
| cmd += " -with-tag sr" if sr_specific else " -without-tag sr" | ||
| elif scoping is QuicktestScoping.RUN_ONLY_PARAM: | ||
| suites = QUICKTEST_SR_SUITES if sr_specific else QUICKTEST_COMMON_SUITES | ||
| cmd += f" -run-only {shlex.quote(suites)}" | ||
| elif not sr_specific: | ||
| # QuicktestScoping.NO_PARAM: no way to select just the common suites, and every | ||
| # per-SR pass on this host is already unfiltered, so this run adds nothing. | ||
| pytest.skip("quicktest has no scoping support on this host; " | ||
| "common suites are already covered by the per-SR runs.") | ||
|
|
||
| logging.info(f"Run quicktest on SR {self.uuid}: {cmd}") | ||
|
|
||
| # Always display the output of quicktest, failed or not. | ||
| # This will duplicate the output in some cases, but it ensures we always have it for failure analysis, | ||
| # even when quicktest leaves SRs in a state which makes teardown fail (in this case, pytest often doesn't | ||
| # manage to display the details of the failed command, for a reason unknown - no usable reproducer found) | ||
| try: | ||
| output = self.pool.master.ssh(f'/opt/xensource/debug/quicktest -sr {self.uuid}') | ||
| output = self.pool.master.ssh(cmd) | ||
| logging.info(f"Quicktest output: {output}") | ||
| except commands.SSHCommandFailed as e: | ||
| logging.error(f"Quicktest output: {e.stdout}") | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
|
|
||
| from lib.sr import SR | ||
|
|
||
| @pytest.mark.quicktest | ||
| def test_common_quicktest(local_sr_on_hostA1: SR) -> None: | ||
| local_sr_on_hostA1.run_quicktest(sr_specific=False) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.