Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions tests/infrastructure/instance_types/supported_os/test_rhel_os.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from __future__ import annotations
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment thread
vsibirsk marked this conversation as resolved.
Comment thread
vsibirsk marked this conversation as resolved.

from typing import TYPE_CHECKING

import pytest

from tests.infrastructure.instance_types.supported_os.constants import (
Expand All @@ -24,6 +28,11 @@
wait_for_console,
)

if TYPE_CHECKING:
from kubernetes.dynamic import DynamicClient

from utilities.virt import VirtualMachineForTests

Comment thread
coderabbitai[bot] marked this conversation as resolved.
pytestmark = [pytest.mark.post_upgrade]

TESTS_MODULE_IDENTIFIER = "TestCommonInstancetypeRhel"
Expand Down Expand Up @@ -133,8 +142,14 @@ class TestVMMigrationAndState:
name=f"{TESTS_MODULE_IDENTIFIER}::{TESTS_MIGRATE_VM}",
depends=[f"{TESTS_MODULE_IDENTIFIER}::{TEST_START_VM_TEST_NAME}"],
)
def test_migrate_vm(self, admin_client, golden_image_rhel_vm_with_instance_type):
migrate_vm_and_verify(vm=golden_image_rhel_vm_with_instance_type, check_ssh_connectivity=True)
def test_migrate_vm(
self,
admin_client: DynamicClient,
golden_image_rhel_vm_with_instance_type: VirtualMachineForTests,
):
migrate_vm_and_verify(
vm=golden_image_rhel_vm_with_instance_type, client=admin_client, check_ssh_connectivity=True
)
validate_libvirt_persistent_domain(vm=golden_image_rhel_vm_with_instance_type, admin_client=admin_client)

@pytest.mark.polarion("CNV-11836")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import pytest
from kubernetes.dynamic.exceptions import UnprocessibleEntityError
from ocp_resources.datavolume import DataVolume
Expand Down Expand Up @@ -27,6 +31,9 @@
running_vm,
)

if TYPE_CHECKING:
from kubernetes.dynamic import DynamicClient

pytestmark = [pytest.mark.usefixtures("skip_if_no_common_modern_cpu")]

TESTS_CLASS_NAME = "TestCPUHotPlugInstancetype"
Expand Down Expand Up @@ -132,8 +139,11 @@ def test_hotplug_cpu_instance_type(self, instance_type_hotplug_vm, hotplugged_si

@pytest.mark.dependency(depends=[f"{TESTS_CLASS_NAME}::hotplug_cpu_instance_type"])
@pytest.mark.polarion("CNV-11402")
def test_migrate_snapshot_hotplugged_vm(self, hotplug_vm_snapshot_instance_type, instance_type_hotplug_vm):
migrate_vm_and_verify(vm=instance_type_hotplug_vm, check_ssh_connectivity=True)
@pytest.mark.usefixtures("hotplug_vm_snapshot_instance_type")
def test_migrate_snapshot_hotplugged_vm(
self, admin_client: DynamicClient, instance_type_hotplug_vm: VirtualMachineForTests
):
migrate_vm_and_verify(vm=instance_type_hotplug_vm, client=admin_client, check_ssh_connectivity=True)
Comment thread
coderabbitai[bot] marked this conversation as resolved.

@pytest.mark.dependency(
name=f"{TESTS_CLASS_NAME}::decrease_cpu_value", depends=[f"{TESTS_CLASS_NAME}::hotplug_cpu_instance_type"]
Expand Down
14 changes: 11 additions & 3 deletions tests/infrastructure/numa/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import pytest
from ocp_resources.data_source import DataSource
from ocp_resources.resource import Resource
Expand All @@ -9,6 +13,9 @@
from utilities.storage import data_volume_template_with_source_ref_dict
from utilities.virt import VirtualMachineForTests, migrate_vm_and_verify, running_vm

if TYPE_CHECKING:
from kubernetes.dynamic import DynamicClient

CX1_CLUSTER_INSTANCETYPE_MEMORY_SIZES = [2, 4, 8, 16, 32, 64] # provided cluster cx1 instancetype sizes (Gi)


Expand Down Expand Up @@ -67,6 +74,7 @@ def created_vm_cx1_instancetype(

@pytest.fixture()
def migrated_numa_cx1_vm(
created_vm_cx1_instancetype,
):
migrate_vm_and_verify(vm=created_vm_cx1_instancetype, check_ssh_connectivity=True)
admin_client: DynamicClient, created_vm_cx1_instancetype: VirtualMachineForTests
) -> VirtualMachineForTests:
migrate_vm_and_verify(vm=created_vm_cx1_instancetype, client=admin_client, check_ssh_connectivity=True)
return created_vm_cx1_instancetype
30 changes: 22 additions & 8 deletions tests/network/bgp/evpn/test_evpn_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
- Running connectivity reference VM with a primary EVPN-enabled CUDN.
"""

from __future__ import annotations

import ipaddress
from typing import TYPE_CHECKING

import pytest

Expand All @@ -32,9 +35,18 @@
)
from utilities.virt import migrate_vm_and_verify

if TYPE_CHECKING:
from kubernetes.dynamic import DynamicClient

from libs.net.traffic_generator import TcpServer
from libs.vm.vm import BaseVirtualMachine
from tests.network.bgp.evpn.libevpn import EndpointTcpClient


_L2_ENDPOINT_IPV4: str = f"{random_ipv4_address(net_seed=EVPN_CUDN_NET_SEED, host_address=249)}/24"
_L2_ENDPOINT_IPV6: str = f"{random_ipv6_address(net_seed=EVPN_CUDN_NET_SEED, host_address=249)}/64"


pytestmark = [
pytest.mark.bgp,
pytest.mark.ipv4,
Expand Down Expand Up @@ -86,9 +98,10 @@ def test_stretched_l2_connectivity_udn_vm_and_external_provider(external_l2_endp

@pytest.mark.polarion("CNV-15229")
def test_stretched_l2_connectivity_is_preserved_over_live_migration(
evpn_stretched_l2_active_connections,
vm_evpn_target,
subtests,
admin_client: DynamicClient,
evpn_stretched_l2_active_connections: list[tuple[EndpointTcpClient, TcpServer]],
vm_evpn_target: BaseVirtualMachine,
subtests: pytest.Subtests,
):
"""
Preconditions:
Expand All @@ -102,7 +115,7 @@ def test_stretched_l2_connectivity_is_preserved_over_live_migration(
Expected:
- The initial TCP connection is preserved (no disconnection).
"""
migrate_vm_and_verify(vm=vm_evpn_target)
migrate_vm_and_verify(vm=vm_evpn_target, client=admin_client)
for client, server in evpn_stretched_l2_active_connections:
with subtests.test(f"IPv{ipaddress.ip_address(client.server_ip).version}"):
assert is_tcp_connection(server=server, client=client)
Expand All @@ -129,9 +142,10 @@ def test_routed_l3_connectivity_udn_vm_and_external_provider(external_l3_endpoin

@pytest.mark.polarion("CNV-15231")
def test_routed_l3_connectivity_is_preserved_over_live_migration(
evpn_routed_l3_active_connections,
vm_evpn_target,
subtests,
admin_client: DynamicClient,
evpn_routed_l3_active_connections: list[tuple[EndpointTcpClient, TcpServer]],
vm_evpn_target: BaseVirtualMachine,
subtests: pytest.Subtests,
):
"""
Preconditions:
Expand All @@ -145,7 +159,7 @@ def test_routed_l3_connectivity_is_preserved_over_live_migration(
Expected:
- The initial TCP connection is preserved (no disconnection).
"""
migrate_vm_and_verify(vm=vm_evpn_target)
migrate_vm_and_verify(vm=vm_evpn_target, client=admin_client)
for client, server in evpn_routed_l3_active_connections:
with subtests.test(f"IPv{ipaddress.ip_address(client.server_ip).version}"):
assert is_tcp_connection(server=server, client=client)
Expand Down
16 changes: 13 additions & 3 deletions tests/network/bgp/test_bgp_connectivity.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import pytest

from libs.net.traffic_generator import is_tcp_connection
from utilities.virt import migrate_vm_and_verify

if TYPE_CHECKING:
from kubernetes.dynamic import DynamicClient

from libs.net.traffic_generator import PodTcpClient, TcpServer

pytestmark = [
pytest.mark.bgp,
pytest.mark.ipv4,
Expand All @@ -17,8 +26,9 @@ def test_connectivity_cudn_vm_and_external_network(tcp_server_cudn_vm, tcp_clien

@pytest.mark.polarion("CNV-12281")
def test_connectivity_is_preserved_during_cudn_vm_migration(
tcp_server_cudn_vm,
tcp_client_external_network,
admin_client: DynamicClient,
tcp_server_cudn_vm: TcpServer,
tcp_client_external_network: PodTcpClient,
):
migrate_vm_and_verify(vm=tcp_server_cudn_vm.vm)
migrate_vm_and_verify(vm=tcp_server_cudn_vm.vm, client=admin_client)
assert is_tcp_connection(server=tcp_server_cudn_vm, client=tcp_client_external_network)
15 changes: 13 additions & 2 deletions tests/network/flat_overlay/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import annotations

import logging
import random
from typing import TYPE_CHECKING

import pytest
from ocp_resources.cluster_operator import ClusterOperator
Expand Down Expand Up @@ -27,6 +30,11 @@
from utilities.network import assert_ping_successful, network_nad
from utilities.virt import migrate_vm_and_verify

if TYPE_CHECKING:
Comment thread
vsibirsk marked this conversation as resolved.
Comment thread
vsibirsk marked this conversation as resolved.
from kubernetes.dynamic import DynamicClient

from utilities.virt import VirtualMachineForTests

LOGGER = logging.getLogger(__name__)


Expand Down Expand Up @@ -286,8 +294,11 @@ def ping_before_migration(vmd_flat_overlay, vmc_flat_overlay_ip_address):


@pytest.fixture()
def migrated_vmc_flat_overlay(vmc_flat_overlay):
migrate_vm_and_verify(vm=vmc_flat_overlay, check_ssh_connectivity=True)
def migrated_vmc_flat_overlay(
admin_client: DynamicClient, vmc_flat_overlay: VirtualMachineForTests
) -> VirtualMachineForTests:
migrate_vm_and_verify(vm=vmc_flat_overlay, client=admin_client, check_ssh_connectivity=True)
return vmc_flat_overlay


@pytest.fixture(scope="class")
Expand Down
27 changes: 19 additions & 8 deletions tests/network/l2_bridge/rhel9_rhel10_cluster/test_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
- mixed_os_nodes
"""

from __future__ import annotations

import ipaddress
from typing import TYPE_CHECKING

import pytest

Expand All @@ -17,6 +20,12 @@
from tests.network.l2_bridge.libl2bridge import RHCOS9_WORKER_LABEL
from utilities.virt import migrate_vm_and_verify

if TYPE_CHECKING:
from kubernetes.dynamic import DynamicClient

from libs.net.traffic_generator import TcpServer, VMTcpClient
from libs.vm.vm import BaseVirtualMachine


@pytest.mark.mixed_os_nodes
@pytest.mark.incremental
Expand All @@ -31,9 +40,10 @@ class TestConnectivity:
@pytest.mark.polarion("CNV-15949")
def test_linux_bridge_connectivity_preserved_during_server_migration_to_rhcos10(
self,
subtests,
bridge_running_vms,
bridge_active_tcp_connections,
admin_client: DynamicClient,
subtests: pytest.Subtests,
bridge_running_vms: tuple[BaseVirtualMachine, BaseVirtualMachine],
bridge_active_tcp_connections: list[tuple[VMTcpClient, TcpServer]],
):
"""
Test that an active TCP connection over a secondary Linux bridge network
Expand All @@ -52,7 +62,7 @@ def test_linux_bridge_connectivity_preserved_during_server_migration_to_rhcos10(
"""
server_vm, _ = bridge_running_vms
server_vm.set_template_affinity(affinity=new_node_affinity(key=RHCOS9_WORKER_LABEL, exists=False))
migrate_vm_and_verify(vm=server_vm)
migrate_vm_and_verify(vm=server_vm, client=admin_client)
for client, server in bridge_active_tcp_connections:
with subtests.test(msg=f"IPv{ipaddress.ip_address(client.server_ip).version} after migration to RHCOS 10"):
assert is_tcp_connection(server=server, client=client), (
Expand All @@ -62,9 +72,10 @@ def test_linux_bridge_connectivity_preserved_during_server_migration_to_rhcos10(
@pytest.mark.polarion("CNV-15964")
def test_linux_bridge_connectivity_preserved_during_server_migration_to_rhcos9(
self,
subtests,
bridge_running_vms,
bridge_active_tcp_connections,
admin_client: DynamicClient,
subtests: pytest.Subtests,
bridge_running_vms: tuple[BaseVirtualMachine, BaseVirtualMachine],
bridge_active_tcp_connections: list[tuple[VMTcpClient, TcpServer]],
):
"""
Test that an active TCP connection over a secondary Linux bridge network
Expand All @@ -83,7 +94,7 @@ def test_linux_bridge_connectivity_preserved_during_server_migration_to_rhcos9(
"""
server_vm, _ = bridge_running_vms
server_vm.set_template_affinity(affinity=new_node_affinity(key=RHCOS9_WORKER_LABEL, exists=True))
migrate_vm_and_verify(vm=server_vm)
migrate_vm_and_verify(vm=server_vm, client=admin_client)
for client, server in bridge_active_tcp_connections:
with subtests.test(
msg=f"IPv{ipaddress.ip_address(client.server_ip).version} after migration back to RHCOS 9"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from typing import Final
from __future__ import annotations

from typing import TYPE_CHECKING, Final

import pytest

Expand All @@ -9,6 +11,11 @@
)
from utilities.virt import migrate_vm_and_verify

if TYPE_CHECKING:
from kubernetes.dynamic import DynamicClient

from libs.vm.vm import BaseVirtualMachine

STABILITY_PERIOD_IN_SECONDS: Final[int] = 300


Expand All @@ -21,8 +28,13 @@ def test_interfaces_stability(self, running_linux_bridge_vm, stable_ips):
assert_interfaces_stable(stable_ips=stable_ips, vmi=vmi_obj, expected_num_ifaces=len(stable_ips))

@pytest.mark.polarion("CNV-14340")
def test_interfaces_stability_after_migration(self, running_linux_bridge_vm, stable_ips):
migrate_vm_and_verify(vm=running_linux_bridge_vm)
def test_interfaces_stability_after_migration(
self,
admin_client: DynamicClient,
running_linux_bridge_vm: BaseVirtualMachine,
stable_ips: dict[str, str],
):
migrate_vm_and_verify(vm=running_linux_bridge_vm, client=admin_client)
primary_network = lookup_primary_network(vm=running_linux_bridge_vm)
primary_iface = lookup_iface_status(
vm=running_linux_bridge_vm,
Expand Down
2 changes: 1 addition & 1 deletion tests/network/libs/stuntime.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ContinuousPing:

Example:
>>> with ContinuousPing(source_vm=client_vm, destination_ip=server_ip) as ping:
... migrate_vm_and_verify(vm=client_vm)
... migrate_vm_and_verify(vm=client_vm, client=admin_client)
... ping.stop()
... transmitted, received, lost = ping.report()
"""
Expand Down
6 changes: 4 additions & 2 deletions tests/network/localnet/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,11 @@ def localnet_active_connections(


@pytest.fixture()
def migrated_localnet_vm(localnet_running_vms: tuple[BaseVirtualMachine, BaseVirtualMachine]) -> BaseVirtualMachine:
def migrated_localnet_vm(
admin_client: DynamicClient, localnet_running_vms: tuple[BaseVirtualMachine, BaseVirtualMachine]
) -> BaseVirtualMachine:
vm, _ = localnet_running_vms
migrate_vm_and_verify(vm=vm)
migrate_vm_and_verify(vm=vm, client=admin_client)
return vm


Expand Down
Loading
Loading