-
Notifications
You must be signed in to change notification settings - Fork 75
[VIRT] Add PCI topology stability tests #5721
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
SamAlber
wants to merge
3
commits into
RedHatQE:main
Choose a base branch
from
SamAlber:pci-topology-stability-tests
base: main
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.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| """ | ||
| PCI Topology Stability Tests | ||
|
|
||
| STP: https://github.com/RedHatQE/openshift-virtualization-tests-design-docs/blob/main/stps/sig-virt/pci-topology-stability.md | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| import pytest | ||
| from ocp_resources.template import Template | ||
| from ocp_resources.virtual_machine_restore import VirtualMachineRestore | ||
| from ocp_resources.virtual_machine_snapshot import VirtualMachineSnapshot | ||
|
|
||
| from tests.os_params import RHEL_LATEST, RHEL_LATEST_LABELS | ||
| from tests.virt.utils import get_pci_addresses | ||
| from utilities.virt import ( | ||
| VirtualMachineForTestsFromTemplate, | ||
| migrate_vm_and_verify, | ||
| restart_vm_wait_for_running_vm, | ||
| running_vm, | ||
| ) | ||
|
|
||
| if TYPE_CHECKING: | ||
| from utilities.virt import VirtualMachineForTests | ||
|
|
||
| LOGGER = logging.getLogger(__name__) | ||
|
|
||
| pytestmark = [pytest.mark.rwx_default_storage, pytest.mark.data_collector_scope(scope="module")] | ||
|
coderabbitai[bot] marked this conversation as resolved.
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
|
|
||
| @pytest.fixture(scope="class") | ||
| def pci_topology_vm( | ||
| request, | ||
| namespace, | ||
| unprivileged_client, | ||
| golden_image_data_volume_template_for_test_scope_class, | ||
| modern_cpu_for_migration, | ||
| ): | ||
| with VirtualMachineForTestsFromTemplate( | ||
| name=request.param["vm_name"], | ||
| labels=Template.generate_template_labels(**request.param["template_labels"]), | ||
| namespace=namespace.name, | ||
| client=unprivileged_client, | ||
| data_volume_template=golden_image_data_volume_template_for_test_scope_class, | ||
| cpu_model=modern_cpu_for_migration, | ||
| ) as vm: | ||
| running_vm(vm=vm) | ||
| yield vm | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def initial_pci_addresses(pci_topology_vm): | ||
| return get_pci_addresses(vm=pci_topology_vm) | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def restarted_pci_topology_vm(pci_topology_vm, initial_pci_addresses): | ||
| restart_vm_wait_for_running_vm(vm=pci_topology_vm) | ||
| return pci_topology_vm | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def migrated_pci_topology_vm(admin_client, pci_topology_vm, initial_pci_addresses): | ||
| migrate_vm_and_verify(vm=pci_topology_vm, client=admin_client, check_ssh_connectivity=True) | ||
| return pci_topology_vm | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def snapshot_restored_pci_topology_vm(admin_client, pci_topology_vm, initial_pci_addresses): | ||
| with VirtualMachineSnapshot( | ||
| name=f"{pci_topology_vm.name}-snapshot", | ||
| namespace=pci_topology_vm.namespace, | ||
| vm_name=pci_topology_vm.name, | ||
| ) as snapshot: | ||
| snapshot.wait_snapshot_done() | ||
| pci_topology_vm.stop(wait=True) | ||
| LOGGER.info(f"Restoring VM {pci_topology_vm.name} from snapshot {snapshot.name}") | ||
| with VirtualMachineRestore( | ||
| client=admin_client, | ||
| name=f"{pci_topology_vm.name}-restore", | ||
| namespace=pci_topology_vm.namespace, | ||
| vm_name=pci_topology_vm.name, | ||
| snapshot_name=snapshot.name, | ||
| ) as restore: | ||
| restore.wait_restore_done() | ||
| running_vm(vm=pci_topology_vm) | ||
| return pci_topology_vm | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "golden_image_data_source_for_test_scope_class, pci_topology_vm", | ||
| [ | ||
| pytest.param( | ||
| {"os_dict": RHEL_LATEST}, | ||
| {"template_labels": RHEL_LATEST_LABELS, "vm_name": "pci-topology-vm"}, | ||
| ), | ||
| ], | ||
| indirect=True, | ||
| ) | ||
| @pytest.mark.arm64 | ||
| class TestPCITopologyStability: | ||
|
coderabbitai[bot] marked this conversation as resolved.
SamAlber marked this conversation as resolved.
|
||
| """ | ||
| Verify PCI device addresses remain stable across VM lifecycle operations. | ||
|
|
||
| Preconditions: | ||
| - RHEL VM created from latest template with a modern CPU model for migration, | ||
| started and running with SSH access | ||
| - Sorted PCI BDF address list captured before each operation | ||
| """ | ||
|
|
||
| @pytest.mark.polarion("CNV-16326") | ||
| def test_pci_address_stability_on_restart( | ||
| self, | ||
| initial_pci_addresses: list[str], | ||
| restarted_pci_topology_vm: VirtualMachineForTests, | ||
| ): | ||
| """ | ||
| Steps: | ||
| 1. Restart the VM and wait until it is running with SSH access | ||
| 2. Capture PCI addresses from the guest | ||
|
|
||
| Expected: | ||
| - Address lists match (PCI topology unchanged) | ||
| """ | ||
| addresses_after = get_pci_addresses(vm=restarted_pci_topology_vm) | ||
| assert addresses_after == initial_pci_addresses, ( | ||
| f"PCI topology changed after restart:\n before: {initial_pci_addresses}\n after: {addresses_after}" | ||
| ) | ||
|
|
||
| @pytest.mark.polarion("CNV-16327") | ||
| def test_pci_address_stability_on_migration( | ||
| self, | ||
| initial_pci_addresses: list[str], | ||
| migrated_pci_topology_vm: VirtualMachineForTests, | ||
| ): | ||
| """ | ||
| Steps: | ||
| 1. Live-migrate the VM and verify SSH connectivity | ||
| 2. Capture PCI addresses from the guest | ||
|
|
||
| Expected: | ||
| - Address lists match (PCI topology unchanged) | ||
| """ | ||
| addresses_after = get_pci_addresses(vm=migrated_pci_topology_vm) | ||
| assert addresses_after == initial_pci_addresses, ( | ||
| f"PCI topology changed after migration:\n before: {initial_pci_addresses}\n after: {addresses_after}" | ||
| ) | ||
|
|
||
| @pytest.mark.polarion("CNV-16328") | ||
| @pytest.mark.usefixtures("skip_if_no_storage_class_for_snapshot") | ||
| def test_pci_address_stability_on_snapshot_restore( | ||
| self, | ||
| initial_pci_addresses: list[str], | ||
| snapshot_restored_pci_topology_vm: VirtualMachineForTests, | ||
| ): | ||
| """ | ||
| Preconditions: | ||
| - Storage class supports snapshots | ||
|
|
||
| Steps: | ||
| 1. Create a VM snapshot and wait until it completes | ||
| 2. Stop the VM | ||
| 3. Restore the VM from the snapshot | ||
| 4. Start the VM and wait until it is running with SSH access | ||
| 5. Capture PCI addresses from the guest | ||
|
|
||
| Expected: | ||
| - Address lists match (PCI topology unchanged) | ||
| """ | ||
| addresses_after = get_pci_addresses(vm=snapshot_restored_pci_topology_vm) | ||
| assert addresses_after == initial_pci_addresses, ( | ||
| f"PCI topology changed after snapshot restore:\n before: {initial_pci_addresses}\n after: {addresses_after}" | ||
| ) | ||
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
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
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
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.