|
1 | 1 | import logging |
| 2 | +import re |
2 | 3 | import shlex |
3 | 4 |
|
4 | 5 | import bitmath |
|
10 | 11 | from ocp_resources.storage_class import StorageClass |
11 | 12 | from ocp_resources.virtual_machine import VirtualMachine |
12 | 13 | from ocp_resources.virtual_machine_instance_migration import VirtualMachineInstanceMigration |
| 14 | +from pyhelper_utils.shell import run_ssh_commands |
13 | 15 | from pytest_testconfig import py_config |
14 | 16 | from timeout_sampler import TimeoutExpiredError, TimeoutSampler |
15 | 17 |
|
|
37 | 39 | from tests.utils import create_vms |
38 | 40 | from utilities import console |
39 | 41 | from utilities.constants import ( |
| 42 | + CENTOS_STREAM10_PREFERENCE, |
| 43 | + DATA_SOURCE_NAME, |
40 | 44 | IPV4_STR, |
41 | 45 | KUBEVIRT_VMI_MEMORY_PGMAJFAULT_TOTAL, |
42 | 46 | KUBEVIRT_VMI_MEMORY_PGMINFAULT_TOTAL, |
|
58 | 62 | TWO_CPU_THREADS, |
59 | 63 | VIRT_TEMPLATE_VALIDATOR, |
60 | 64 | Images, |
| 65 | + StorageClassNames, |
61 | 66 | ) |
62 | 67 | from utilities.hco import ResourceEditorValidateHCOReconcile, enabled_aaq_in_hco |
63 | 68 | from utilities.infra import ( |
|
69 | 74 | ) |
70 | 75 | from utilities.monitoring import get_metrics_value |
71 | 76 | from utilities.network import assert_ping_successful, get_ip_from_vm_or_virt_handler_pod, ping |
| 77 | +from utilities.os_utils import generate_linux_instance_type_os_matrix |
72 | 78 | from utilities.ssp import verify_ssp_pod_is_running |
73 | 79 | from utilities.storage import ( |
74 | 80 | data_volume_template_with_source_ref_dict, |
@@ -619,3 +625,63 @@ def aaq_resource_hard_limit_and_used(application_aware_resource_quota): |
619 | 625 | for key, value in resource_used.items() |
620 | 626 | } |
621 | 627 | return formatted_hard_limit, formatted_used_value |
| 628 | + |
| 629 | + |
| 630 | +@pytest.fixture(scope="class") |
| 631 | +def centos_stream_10_vm( |
| 632 | + unprivileged_client, |
| 633 | + namespace, |
| 634 | + golden_images_namespace, |
| 635 | + modern_cpu_for_migration, |
| 636 | +): |
| 637 | + instance_type_centos_os_matrix = generate_linux_instance_type_os_matrix( |
| 638 | + os_name="centos.stream", preferences=[CENTOS_STREAM10_PREFERENCE] |
| 639 | + )[0] |
| 640 | + os_name = next(iter(instance_type_centos_os_matrix)) |
| 641 | + data_source_name = instance_type_centos_os_matrix[os_name][DATA_SOURCE_NAME] |
| 642 | + with VirtualMachineForTests( |
| 643 | + client=unprivileged_client, |
| 644 | + name=f"{data_source_name}-vm-with-instance-type", |
| 645 | + namespace=namespace.name, |
| 646 | + vm_instance_type_infer=True, |
| 647 | + vm_preference_infer=True, |
| 648 | + data_volume_template=data_volume_template_with_source_ref_dict( |
| 649 | + data_source=DataSource( |
| 650 | + name=data_source_name, |
| 651 | + namespace=golden_images_namespace.name, |
| 652 | + ), |
| 653 | + storage_class=StorageClassNames.CEPH_RBD_VIRTUALIZATION, |
| 654 | + ), |
| 655 | + cpu_model=modern_cpu_for_migration, |
| 656 | + ) as vm: |
| 657 | + running_vm(vm=vm) |
| 658 | + yield vm |
| 659 | + |
| 660 | + |
| 661 | +@pytest.fixture(scope="class") |
| 662 | +def qemu_guest_agent_version_updated_centos(centos_stream_10_vm): |
| 663 | + LOGGER.info(f"Checking qemu-guest-agent package on VM: {centos_stream_10_vm.name}") |
| 664 | + output = run_ssh_commands( |
| 665 | + host=centos_stream_10_vm.ssh_exec, |
| 666 | + commands=shlex.split("rpm -q qemu-guest-agent"), |
| 667 | + ) |
| 668 | + agent_version = output[0].strip() if output else "" |
| 669 | + LOGGER.info(f"qemu-guest-agent version: {agent_version}") |
| 670 | + |
| 671 | + # Parse version to ensure it's at least 9.6 |
| 672 | + version_match = re.search(r"qemu-guest-agent-(\d+)\.(\d+)", agent_version) |
| 673 | + if version_match: |
| 674 | + version_num = float(f"{version_match.group(1)}.{version_match.group(2)}") |
| 675 | + |
| 676 | + LOGGER.info(f"Parsed qemu-guest-agent version: {version_num}") |
| 677 | + if version_num >= 9.6: |
| 678 | + return |
| 679 | + raise ValueError(f"qemu-guest-agent version {version_num} is less than required 9.6") |
| 680 | + |
| 681 | + |
| 682 | +@pytest.fixture(scope="class") |
| 683 | +def stressed_vm_cpu_centos(centos_stream_10_vm): |
| 684 | + run_ssh_commands( |
| 685 | + host=centos_stream_10_vm.ssh_exec, |
| 686 | + commands=shlex.split("sudo dnf install stress-ng -y; stress-ng --cpu $(nproc) --timeout 60s"), |
| 687 | + ) |
0 commit comments