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
11 changes: 9 additions & 2 deletions tests/network/l2_bridge/migration_stuntime/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from libs.vm.affinity import new_pod_affinity
from libs.vm.vm import BaseVirtualMachine
from tests.network.l2_bridge.libl2bridge import secondary_network_vm
from tests.network.libs.stuntime import SERVER_VM_LABEL, ContinuousPing
from tests.network.libs.stuntime import CLIENT_VM_LABEL, SERVER_VM_LABEL, ContinuousPing

STUNTIME_BRIDGE_IFACE_NAME: Final[str] = "stuntime-bridge"

Expand All @@ -24,9 +24,15 @@ def l2_bridge_stuntime_nad(
bridge_nncp: libnncp.NodeNetworkConfigurationPolicy,
) -> Generator[libnad.NetworkAttachmentDefinition]:
nad_name = "l2-bridge-nad"
bridge_name = bridge_nncp.desired_state_spec.interfaces[0].name # type: ignore[index]
config = libnad.NetConfig(
name=nad_name,
plugins=[libnad.CNIPluginBridgeConfig(bridge=bridge_nncp.desired_state_spec.interfaces[0].name)], # type: ignore[index]
plugins=[
libnad.CNIPluginBridgeConfig(
bridge=bridge_name,
disableContainerInterface=True,
)
],
)
with libnad.NetworkAttachmentDefinition(
name=nad_name,
Expand Down Expand Up @@ -79,6 +85,7 @@ def stuntime_client_vm(
f"{random_ipv6_address(net_seed=0, host_address=2)}/64",
],
affinity=new_pod_affinity(label=SERVER_VM_LABEL),
labels=dict([CLIENT_VM_LABEL]),
) as client_vm:
client_vm.start(wait=True)
client_vm.wait_for_agent_connected()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import pytest

from libs.vm.affinity import new_pod_anti_affinity
from tests.network.libs.stuntime import SERVER_VM_LABEL, STUNTIME_THRESHOLD_SECONDS, measure_stuntime
from libs.vm.affinity import new_pod_affinity, new_pod_anti_affinity
from tests.network.libs.stuntime import CLIENT_VM_LABEL, SERVER_VM_LABEL, STUNTIME_THRESHOLD_SECONDS, measure_stuntime
from utilities.virt import migrate_vm_and_verify

pytestmark = [pytest.mark.tier3]
Expand All @@ -31,7 +31,7 @@
- ipv6 [Markers: ipv6]

Preconditions:
- Shared under-test server VM on Linux bridge secondary network, for the IP family from ip_family parametrization.
- Shared under-test server VM on Linux bridge secondary network, for the parametrized IP family.
- Shared under-test client VM on Linux bridge secondary network, for that same IP family,
initially running on the same node as the server VM.
"""
Expand All @@ -56,7 +56,7 @@ def test_client_migrates_off_server_node(
VM migrates from the node hosting the server VM into a different node.

Preconditions:
- Under-test server VM on Linux bridge secondary network, for the IP family from ip_family parametrization.
- Under-test server VM on Linux bridge secondary network, for the parametrized IP family.
- Under-test client VM on Linux bridge secondary network, for that same IP family,
running on the same node as the server VM.
- Ping initiated from the client to the server.
Expand All @@ -78,13 +78,15 @@ def test_client_migrates_off_server_node(
)

@pytest.mark.polarion("CNV-15253")
def test_client_migrates_between_non_server_nodes(self):
def test_client_migrates_between_non_server_nodes(
self, admin_client, l2_bridge_ip_family, stuntime_client_vm, l2_bridge_active_ping
):
"""
Test that measured stuntime does not exceed the global threshold when the client VM migrates between nodes
while the client and server VMs remain on different nodes.

Preconditions:
- Under-test server VM on Linux bridge secondary network, for the IP family from ip_family parametrization.
- Under-test server VM on Linux bridge secondary network, for the parametrized IP family.
- Under-test client VM on Linux bridge secondary network, for that same IP family,
running on a worker node other than the node hosting the server VM.
- Ping initiated from the client to the server.
Expand All @@ -98,15 +100,22 @@ def test_client_migrates_between_non_server_nodes(self):
Expected:
- Measured stuntime does not exceed the global threshold.
"""
migrate_vm_and_verify(vm=stuntime_client_vm, client=admin_client)
measured_stuntime = measure_stuntime(active_ping=l2_bridge_active_ping)
assert measured_stuntime <= STUNTIME_THRESHOLD_SECONDS, (
f"Stuntime {measured_stuntime}s exceeds threshold ({STUNTIME_THRESHOLD_SECONDS}s)"
)

@pytest.mark.polarion("CNV-15254")
def test_client_migrates_to_server_node(self):
def test_client_migrates_to_server_node(
self, admin_client, l2_bridge_ip_family, stuntime_client_vm, l2_bridge_active_ping
):
"""
Test that measured stuntime does not exceed the global threshold when the client VM migrates
from a node other than the node hosting the server VM onto the node hosting the server VM.

Preconditions:
- Under-test server VM on Linux bridge secondary network, for the IP family from ip_family parametrization.
- Under-test server VM on Linux bridge secondary network, for the parametrized IP family.
- Under-test client VM on Linux bridge secondary network, for that same IP family,
running on a worker node other than the node hosting the server VM.
- Ping initiated from the client to the server.
Expand All @@ -120,15 +129,23 @@ def test_client_migrates_to_server_node(self):
Expected:
- Measured stuntime does not exceed the global threshold.
"""
stuntime_client_vm.set_template_affinity(affinity=new_pod_affinity(label=SERVER_VM_LABEL))
migrate_vm_and_verify(vm=stuntime_client_vm, client=admin_client)
measured_stuntime = measure_stuntime(active_ping=l2_bridge_active_ping)
assert measured_stuntime <= STUNTIME_THRESHOLD_SECONDS, (
f"Stuntime {measured_stuntime}s exceeds threshold ({STUNTIME_THRESHOLD_SECONDS}s)"
)

@pytest.mark.polarion("CNV-15255")
def test_server_migrates_off_client_node(self):
def test_server_migrates_off_client_node(
self, admin_client, l2_bridge_ip_family, stuntime_server_vm, l2_bridge_active_ping
):
"""
Test that measured stuntime does not exceed the global threshold when the server
VM migrates from the node hosting the client VM into a different node.

Preconditions:
- Under-test server VM on Linux bridge secondary network, for the IP family from ip_family parametrization.
- Under-test server VM on Linux bridge secondary network, for the parametrized IP family.
- Under-test client VM on Linux bridge secondary network, for that same IP family,
running on the same node as the server VM.
- Ping initiated from the client to the server.
Expand All @@ -142,15 +159,23 @@ def test_server_migrates_off_client_node(self):
Expected:
- Measured stuntime does not exceed the global threshold.
"""
stuntime_server_vm.set_template_affinity(affinity=new_pod_anti_affinity(label=CLIENT_VM_LABEL))
migrate_vm_and_verify(vm=stuntime_server_vm, client=admin_client)
measured_stuntime = measure_stuntime(active_ping=l2_bridge_active_ping)
assert measured_stuntime <= STUNTIME_THRESHOLD_SECONDS, (
f"Stuntime {measured_stuntime}s exceeds threshold ({STUNTIME_THRESHOLD_SECONDS}s)"
)

@pytest.mark.polarion("CNV-15256")
def test_server_migrates_between_non_client_nodes(self):
def test_server_migrates_between_non_client_nodes(
self, admin_client, l2_bridge_ip_family, stuntime_server_vm, l2_bridge_active_ping
):
"""
Test that measured stuntime does not exceed the global threshold when the server VM migrates between nodes
while the client and server VMs remain on different nodes.

Preconditions:
- Under-test server VM on Linux bridge secondary network, for the IP family from ip_family parametrization.
- Under-test server VM on Linux bridge secondary network, for the parametrized IP family.
- Under-test client VM on Linux bridge secondary network, for that same IP family,
running on a worker node other than the node hosting the server VM (before and after migration).
- Ping initiated from the client to the server.
Expand All @@ -164,15 +189,23 @@ def test_server_migrates_between_non_client_nodes(self):
Expected:
- Measured stuntime does not exceed the global threshold.
"""
stuntime_server_vm.set_template_affinity(affinity=new_pod_anti_affinity(label=CLIENT_VM_LABEL))
migrate_vm_and_verify(vm=stuntime_server_vm, client=admin_client)
measured_stuntime = measure_stuntime(active_ping=l2_bridge_active_ping)
assert measured_stuntime <= STUNTIME_THRESHOLD_SECONDS, (
f"Stuntime {measured_stuntime}s exceeds threshold ({STUNTIME_THRESHOLD_SECONDS}s)"
)

@pytest.mark.polarion("CNV-15257")
def test_server_migrates_to_client_node(self):
def test_server_migrates_to_client_node(
self, admin_client, l2_bridge_ip_family, stuntime_server_vm, l2_bridge_active_ping
):
"""
Test that measured stuntime does not exceed the global threshold when the server VM migrates from a node
other than the node hosting the client VM onto the node hosting the client VM.

Preconditions:
- Under-test server VM on Linux bridge secondary network, for the IP family from ip_family parametrization.
- Under-test server VM on Linux bridge secondary network, for the parametrized IP family.
- Under-test client VM on Linux bridge secondary network, for that same IP family,
running on a worker node other than the node hosting the server VM.
- Ping initiated from the client to the server.
Expand All @@ -186,9 +219,9 @@ def test_server_migrates_to_client_node(self):
Expected:
- Measured stuntime does not exceed the global threshold.
"""

test_client_migrates_between_non_server_nodes.__test__ = False
test_client_migrates_to_server_node.__test__ = False
test_server_migrates_off_client_node.__test__ = False
test_server_migrates_between_non_client_nodes.__test__ = False
test_server_migrates_to_client_node.__test__ = False
stuntime_server_vm.set_template_affinity(affinity=new_pod_affinity(label=CLIENT_VM_LABEL))
migrate_vm_and_verify(vm=stuntime_server_vm, client=admin_client)
measured_stuntime = measure_stuntime(active_ping=l2_bridge_active_ping)
assert measured_stuntime <= STUNTIME_THRESHOLD_SECONDS, (
f"Stuntime {measured_stuntime}s exceeds threshold ({STUNTIME_THRESHOLD_SECONDS}s)"
)