Skip to content

Commit a5de3b9

Browse files
committed
net, tests, stuntime: Implement remaining L2 bridge scenarios
Implement the remaining stuntime measurement tests for Linux bridge live migration, covering all client/server migration directions with IPv4/IPv6. Follows the same pattern as the localnet stuntime PR — Single parametrized class with class-level l2_bridge_ip_family parametrize to group all scenarios per IP family before moving to the next. VMs depend on l2_bridge_ip_family so they're recreated per group, giving each IP family fresh VMs with clean network state. Tests run incrementally within each group, each migration building on the VM positions left by the previous scenario. Signed-off-by: Anat Wax <awax@redhat.com> Assisted-by: Claude <noreply@anthropic.com>
1 parent 36eae7a commit a5de3b9

2 files changed

Lines changed: 55 additions & 21 deletions

File tree

tests/network/l2_bridge/migration_stuntime/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from libs.vm.affinity import new_pod_affinity
1313
from libs.vm.vm import BaseVirtualMachine
1414
from tests.network.l2_bridge.libl2bridge import secondary_network_vm
15-
from tests.network.libs.stuntime import SERVER_VM_LABEL, ContinuousPing
15+
from tests.network.libs.stuntime import CLIENT_VM_LABEL, SERVER_VM_LABEL, ContinuousPing
1616

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

@@ -79,6 +79,7 @@ def stuntime_client_vm(
7979
f"{random_ipv6_address(net_seed=0, host_address=2)}/64",
8080
],
8181
affinity=new_pod_affinity(label=SERVER_VM_LABEL),
82+
labels=dict([CLIENT_VM_LABEL]),
8283
) as client_vm:
8384
client_vm.start(wait=True)
8485
client_vm.wait_for_agent_connected()

tests/network/l2_bridge/migration_stuntime/test_migration_stuntime.py

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
import pytest
2020

21-
from libs.vm.affinity import new_pod_anti_affinity
22-
from tests.network.libs.stuntime import SERVER_VM_LABEL, STUNTIME_THRESHOLD_SECONDS, measure_stuntime
21+
from libs.vm.affinity import new_pod_affinity, new_pod_anti_affinity
22+
from tests.network.libs.stuntime import CLIENT_VM_LABEL, SERVER_VM_LABEL, STUNTIME_THRESHOLD_SECONDS, measure_stuntime
2323
from utilities.virt import migrate_vm_and_verify
2424

2525
pytestmark = [pytest.mark.tier3]
@@ -31,7 +31,7 @@
3131
- ipv6 [Markers: ipv6]
3232
3333
Preconditions:
34-
- Shared under-test server VM on Linux bridge secondary network, for the IP family from ip_family parametrization.
34+
- Shared under-test server VM on Linux bridge secondary network, for the IP family from l2_bridge_ip_family parametrization.
3535
- Shared under-test client VM on Linux bridge secondary network, for that same IP family,
3636
initially running on the same node as the server VM.
3737
"""
@@ -56,7 +56,7 @@ def test_client_migrates_off_server_node(
5656
VM migrates from the node hosting the server VM into a different node.
5757
5858
Preconditions:
59-
- Under-test server VM on Linux bridge secondary network, for the IP family from ip_family parametrization.
59+
- Under-test server VM on Linux bridge secondary network, for the IP family from l2_bridge_ip_family parametrization.
6060
- Under-test client VM on Linux bridge secondary network, for that same IP family,
6161
running on the same node as the server VM.
6262
- Ping initiated from the client to the server.
@@ -78,13 +78,15 @@ def test_client_migrates_off_server_node(
7878
)
7979

8080
@pytest.mark.polarion("CNV-15253")
81-
def test_client_migrates_between_non_server_nodes(self):
81+
def test_client_migrates_between_non_server_nodes(
82+
self, admin_client, l2_bridge_ip_family, stuntime_client_vm, l2_bridge_active_ping
83+
):
8284
"""
8385
Test that measured stuntime does not exceed the global threshold when the client VM migrates between nodes
8486
while the client and server VMs remain on different nodes.
8587
8688
Preconditions:
87-
- Under-test server VM on Linux bridge secondary network, for the IP family from ip_family parametrization.
89+
- Under-test server VM on Linux bridge secondary network, for the IP family from l2_bridge_ip_family parametrization.
8890
- Under-test client VM on Linux bridge secondary network, for that same IP family,
8991
running on a worker node other than the node hosting the server VM.
9092
- Ping initiated from the client to the server.
@@ -98,15 +100,22 @@ def test_client_migrates_between_non_server_nodes(self):
98100
Expected:
99101
- Measured stuntime does not exceed the global threshold.
100102
"""
103+
migrate_vm_and_verify(vm=stuntime_client_vm, client=admin_client)
104+
measured_stuntime = measure_stuntime(active_ping=l2_bridge_active_ping)
105+
assert measured_stuntime <= STUNTIME_THRESHOLD_SECONDS, (
106+
f"Stuntime {measured_stuntime}s exceeds threshold ({STUNTIME_THRESHOLD_SECONDS}s)"
107+
)
101108

102109
@pytest.mark.polarion("CNV-15254")
103-
def test_client_migrates_to_server_node(self):
110+
def test_client_migrates_to_server_node(
111+
self, admin_client, l2_bridge_ip_family, stuntime_client_vm, l2_bridge_active_ping
112+
):
104113
"""
105114
Test that measured stuntime does not exceed the global threshold when the client VM migrates
106115
from a node other than the node hosting the server VM onto the node hosting the server VM.
107116
108117
Preconditions:
109-
- Under-test server VM on Linux bridge secondary network, for the IP family from ip_family parametrization.
118+
- Under-test server VM on Linux bridge secondary network, for the IP family from l2_bridge_ip_family parametrization.
110119
- Under-test client VM on Linux bridge secondary network, for that same IP family,
111120
running on a worker node other than the node hosting the server VM.
112121
- Ping initiated from the client to the server.
@@ -120,15 +129,23 @@ def test_client_migrates_to_server_node(self):
120129
Expected:
121130
- Measured stuntime does not exceed the global threshold.
122131
"""
132+
stuntime_client_vm.set_template_affinity(affinity=new_pod_affinity(label=SERVER_VM_LABEL))
133+
migrate_vm_and_verify(vm=stuntime_client_vm, client=admin_client)
134+
measured_stuntime = measure_stuntime(active_ping=l2_bridge_active_ping)
135+
assert measured_stuntime <= STUNTIME_THRESHOLD_SECONDS, (
136+
f"Stuntime {measured_stuntime}s exceeds threshold ({STUNTIME_THRESHOLD_SECONDS}s)"
137+
)
123138

124139
@pytest.mark.polarion("CNV-15255")
125-
def test_server_migrates_off_client_node(self):
140+
def test_server_migrates_off_client_node(
141+
self, admin_client, l2_bridge_ip_family, stuntime_server_vm, l2_bridge_active_ping
142+
):
126143
"""
127144
Test that measured stuntime does not exceed the global threshold when the server
128145
VM migrates from the node hosting the client VM into a different node.
129146
130147
Preconditions:
131-
- Under-test server VM on Linux bridge secondary network, for the IP family from ip_family parametrization.
148+
- Under-test server VM on Linux bridge secondary network, for the IP family from l2_bridge_ip_family parametrization.
132149
- Under-test client VM on Linux bridge secondary network, for that same IP family,
133150
running on the same node as the server VM.
134151
- Ping initiated from the client to the server.
@@ -142,15 +159,23 @@ def test_server_migrates_off_client_node(self):
142159
Expected:
143160
- Measured stuntime does not exceed the global threshold.
144161
"""
162+
stuntime_server_vm.set_template_affinity(affinity=new_pod_anti_affinity(label=CLIENT_VM_LABEL))
163+
migrate_vm_and_verify(vm=stuntime_server_vm, client=admin_client)
164+
measured_stuntime = measure_stuntime(active_ping=l2_bridge_active_ping)
165+
assert measured_stuntime <= STUNTIME_THRESHOLD_SECONDS, (
166+
f"Stuntime {measured_stuntime}s exceeds threshold ({STUNTIME_THRESHOLD_SECONDS}s)"
167+
)
145168

146169
@pytest.mark.polarion("CNV-15256")
147-
def test_server_migrates_between_non_client_nodes(self):
170+
def test_server_migrates_between_non_client_nodes(
171+
self, admin_client, l2_bridge_ip_family, stuntime_server_vm, l2_bridge_active_ping
172+
):
148173
"""
149174
Test that measured stuntime does not exceed the global threshold when the server VM migrates between nodes
150175
while the client and server VMs remain on different nodes.
151176
152177
Preconditions:
153-
- Under-test server VM on Linux bridge secondary network, for the IP family from ip_family parametrization.
178+
- Under-test server VM on Linux bridge secondary network, for the IP family from l2_bridge_ip_family parametrization.
154179
- Under-test client VM on Linux bridge secondary network, for that same IP family,
155180
running on a worker node other than the node hosting the server VM (before and after migration).
156181
- Ping initiated from the client to the server.
@@ -164,15 +189,23 @@ def test_server_migrates_between_non_client_nodes(self):
164189
Expected:
165190
- Measured stuntime does not exceed the global threshold.
166191
"""
192+
stuntime_server_vm.set_template_affinity(affinity=new_pod_anti_affinity(label=CLIENT_VM_LABEL))
193+
migrate_vm_and_verify(vm=stuntime_server_vm, client=admin_client)
194+
measured_stuntime = measure_stuntime(active_ping=l2_bridge_active_ping)
195+
assert measured_stuntime <= STUNTIME_THRESHOLD_SECONDS, (
196+
f"Stuntime {measured_stuntime}s exceeds threshold ({STUNTIME_THRESHOLD_SECONDS}s)"
197+
)
167198

168199
@pytest.mark.polarion("CNV-15257")
169-
def test_server_migrates_to_client_node(self):
200+
def test_server_migrates_to_client_node(
201+
self, admin_client, l2_bridge_ip_family, stuntime_server_vm, l2_bridge_active_ping
202+
):
170203
"""
171204
Test that measured stuntime does not exceed the global threshold when the server VM migrates from a node
172205
other than the node hosting the client VM onto the node hosting the client VM.
173206
174207
Preconditions:
175-
- Under-test server VM on Linux bridge secondary network, for the IP family from ip_family parametrization.
208+
- Under-test server VM on Linux bridge secondary network, for the IP family from l2_bridge_ip_family parametrization.
176209
- Under-test client VM on Linux bridge secondary network, for that same IP family,
177210
running on a worker node other than the node hosting the server VM.
178211
- Ping initiated from the client to the server.
@@ -186,9 +219,9 @@ def test_server_migrates_to_client_node(self):
186219
Expected:
187220
- Measured stuntime does not exceed the global threshold.
188221
"""
189-
190-
test_client_migrates_between_non_server_nodes.__test__ = False
191-
test_client_migrates_to_server_node.__test__ = False
192-
test_server_migrates_off_client_node.__test__ = False
193-
test_server_migrates_between_non_client_nodes.__test__ = False
194-
test_server_migrates_to_client_node.__test__ = False
222+
stuntime_server_vm.set_template_affinity(affinity=new_pod_affinity(label=CLIENT_VM_LABEL))
223+
migrate_vm_and_verify(vm=stuntime_server_vm, client=admin_client)
224+
measured_stuntime = measure_stuntime(active_ping=l2_bridge_active_ping)
225+
assert measured_stuntime <= STUNTIME_THRESHOLD_SECONDS, (
226+
f"Stuntime {measured_stuntime}s exceeds threshold ({STUNTIME_THRESHOLD_SECONDS}s)"
227+
)

0 commit comments

Comments
 (0)