Skip to content

Fix Cloud Hypervisor live migration nextest filtering#4563

Open
vyadavmsft wants to merge 7 commits into
mainfrom
ch_52
Open

Fix Cloud Hypervisor live migration nextest filtering#4563
vyadavmsft wants to merge 7 commits into
mainfrom
ch_52

Conversation

@vyadavmsft

Copy link
Copy Markdown
Collaborator

Run Cloud Hypervisor live migration tests through the CLI path and construct the nextest filter as a shell-safe expression. Preserve the base test filter while excluding the serial-only live migration test from the parallel run.

Description

Related Issue

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring
  • Documentation update

Checklist

  • Description is filled in above
  • No credentials, secrets, or internal details are included
  • Peer review requested (if not, add required peer reviewers after raising PR)
  • Tests executed and results posted below

Test Validation

Key Test Cases:

Impacted LISA Features:

Tested Azure Marketplace Images:

Test Results

Image VM Size Result
PASSED / FAILED / SKIPPED

Copilot AI review requested due to automatic review settings June 26, 2026 20:35
@github-actions

Copy link
Copy Markdown

🤖 AI Test Selection

No test cases were selected for this PR.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Cloud Hypervisor test harness to run live migration tests through the CLI path and to build a shell-safe nextest filter expression while preserving the base filter behavior.

Changes:

  • Route live migration execution through the integration CLI test type and apply a nextest --filterset-based filter.
  • Add helper logic to construct a combined nextest filterset (base substring + include + exclude).
  • Adjust subtest listing and run orchestration to support cli_test_type / cli_test_filter overrides.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lisa/microsoft/testsuites/cloud_hypervisor/ch_tests.py Switch live migration run to the CLI integration path and pass only/skip plus CLI filtering parameters.
lisa/microsoft/testsuites/cloud_hypervisor/ch_tests_tool.py Add nextest filterset construction and CLI-path execution for filtered runs, plus supporting subtest prep parameters.

Comment thread lisa/microsoft/testsuites/cloud_hypervisor/ch_tests_tool.py Outdated
Run Cloud Hypervisor live migration tests through the CLI path and construct the nextest filter as a shell-safe expression. Preserve the base test filter while excluding the serial-only live migration test from the parallel run.
@github-actions

Copy link
Copy Markdown

🤖 AI Test Selection

No test cases were selected for this PR.

LiliDeng
LiliDeng previously approved these changes Jun 29, 2026
Comment thread lisa/microsoft/testsuites/cloud_hypervisor/ch_tests_tool.py Outdated
Comment thread lisa/microsoft/testsuites/cloud_hypervisor/ch_tests_tool.py Outdated
Replace the custom bash argument quoting helper with shlex.quote and quote the generated bash script as a whole before passing it to bash -lc.

Remove the redundant cli_test_type override by running live migration through the integration test type and selecting live migration cases with the nextest filter.
Copilot AI review requested due to automatic review settings June 29, 2026 19:44
@github-actions

Copy link
Copy Markdown

🤖 AI Test Selection

No test cases were selected for this PR.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread lisa/microsoft/testsuites/cloud_hypervisor/ch_tests_tool.py
Derive the expected subtest set when running Cloud Hypervisor tests with a nextest CLI filter instead of passing an empty set into result processing.

Fail fast if the filter and include/exclude lists select no subtests so a zero-test run cannot pass silently.
@github-actions

Copy link
Copy Markdown

🤖 AI Test Selection

No test cases were selected for this PR.

ref: str = "",
only: Optional[List[str]] = None,
skip: Optional[List[str]] = None,
only_test_prefixes: Optional[List[str]] = None,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this unused? I don't see any caller passing this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This was leftover from an earlier live-migration filtering approach. The current [cli_test_filter] path now derives the filtered subtest set directly, and no caller passes only_test_prefixes, so I removed it.

Drop the only_test_prefixes parameter from the Cloud Hypervisor test runner because no caller supplies it.

Remove the corresponding private prefix-filter branches so the run_tests signature only exposes supported include, exclude, and CLI substring filters.
Copilot AI review requested due to automatic review settings July 1, 2026 19:03
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🤖 AI Test Selection

No test cases were selected for this PR.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment on lines +501 to +505
test_script_args = f"--test-filter {shlex.quote(nextest_filter)}"
cmd_args = (
f"tests --hypervisor {hypervisor} --{test_type} -- "
f"{test_script_args}"
)
@vyadavmsft vyadavmsft requested a review from anirudhrb July 6, 2026 00:19
CH integration tests run under cargo-nextest, which rejects the libtest '-- -- --list' flag ('failed to parse test binary arguments --list: arguments are unsupported', exit 96). _list_subtests therefore returned an empty list and _prepare_filtered_subtests failed with 'No Cloud Hypervisor integration subtests matched filter', even though the tests exist and the nextest run path works.

List subtests with 'cargo nextest list --message-format json' instead, run in the dev container via 'dev_cli.sh shell' and mirroring the integration build env (mshv feature, devcli_testenv cfg). The return value stays the same List[str] of '<module>::<test>' names, so the runbook-driven include/exclude (only/skip/cli_test_filter), the no-match validation, and per-subtest result tracking are unchanged.
Copilot AI review requested due to automatic review settings July 9, 2026 00:37
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

🤖 AI Test Selection

No test cases were selected for this PR.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment on lines +1512 to +1529
@staticmethod
def _parse_nextest_subtest_list(stdout: str) -> List[str]:
# "cargo nextest list --message-format json" prints a JSON document with
# a "rust-suites" map; each suite has a "testcases" map keyed by the test
# name (e.g. "live_migration::test_live_migration_local"). Build progress
# is written to stderr, so stdout starts at the first '{'. Return the
# test names to preserve the previous "<module>::<test>" list contract.
brace = stdout.find("{")
if brace == -1:
return []
try:
data = json.loads(stdout[brace:])
except json.JSONDecodeError:
return []
subtests: List[str] = []
for suite in data.get("rust-suites", {}).values():
subtests.extend(suite.get("testcases", {}).keys())
return subtests
The previous fix listed subtests via 'dev_cli.sh shell -- RUSTFLAGS=..(--cfg devcli_testenv).. cargo nextest list'. dev_cli.sh's shell command runs its arguments as 'bash -c \$*', which re-joins them on spaces and drops quoting, so the space inside the RUSTFLAGS value was split: bash set RUSTFLAGS=--cfg and then tried to run 'devcli_testenv' as a command (exit 127, 'devcli_testenv: command not found'). cargo never ran, the subtest list came back empty, and _prepare_filtered_subtests still failed with 'No subtests matched filter'.

Use the space-free 'RUSTFLAGS=--cfg=devcli_testenv' form so it survives the bash -c hand-off, and make the JSON parser scan each '{' for the nextest object with a 'rust-suites' map, since dev_cli.sh interleaves docker pull and cargo build output on the same stream.
Copilot AI review requested due to automatic review settings July 9, 2026 01:15
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

🤖 AI Test Selection

No test cases were selected for this PR.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment on lines 1471 to +1477
def _list_subtests(self, hypervisor: str, test_type: str) -> List[str]:
cmd_args = f"tests --hypervisor {hypervisor} --{test_type} -- -- --list"
# Cloud Hypervisor's integration tests run under cargo-nextest, which
# rejects the libtest "-- -- --list" flag ("failed to parse test binary
# arguments `--list`: arguments are unsupported"). Enumerate the subtests
# with "cargo nextest list" instead. The return value is still the same
# List[str] of "<module>::<test>" names, so the runbook-driven
# include/exclude (only/skip/cli_test_filter) and per-subtest result
… of failing

Cloud Hypervisor gates every live migration integration test behind
cfg(not(feature = "mshv")). The mshv integration build
(cargo nextest ... --features mshv) compiles them out, so _list_subtests
correctly returns no live_migration tests and the "live_migration"
substring filter matches nothing.

_prepare_filtered_subtests previously called fail() in that case, turning a
legitimately-empty selection into a hard AssertionError. This made
verify_cloud_hypervisor_live_migration_tests fail on mshv even though the
tests do not exist in that build (they had been silently passing before the
subtest-list assertion was added).

Raise SkippedException instead so an unavailable test family (live migration
on mshv, or an include/exclude filter that removes all matches) is reported
as a clean skip per LISA conventions. KVM builds (no mshv feature) still
compile these tests, so the filter matches and they run normally.
Copilot AI review requested due to automatic review settings July 9, 2026 06:16
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

🤖 AI Test Selection

No test cases were selected for this PR.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment on lines +158 to +171
filterset = f"test(~{self._escape_nextest_filter_matcher(base_filter)})"

if only:
included_tests = "|".join(
f"test(={self._escape_nextest_filter_matcher(test_name)})"
for test_name in only
)
filterset = f"({filterset}&({included_tests}))"

if skip:
for skipped_test in skip:
skipped_filter = self._escape_nextest_filter_matcher(skipped_test)
filterset = f"{filterset}-test(={skipped_filter})"

Comment on lines +211 to +221
filtered_subtests = [
subtest for subtest in subtests if cli_test_filter in subtest
]
if only is not None:
filtered_subtests = [
subtest for subtest in filtered_subtests if subtest in only
]
if skip is not None:
filtered_subtests = [
subtest for subtest in filtered_subtests if subtest not in skip
]
@@ -1380,7 +1480,27 @@ def _cache_vmm_version(self) -> None:
self._log.debug(f"Could not cache VMM version: {e}")

def _list_subtests(self, hypervisor: str, test_type: str) -> List[str]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants