-
Notifications
You must be signed in to change notification settings - Fork 72
net, tests, stuntime: Add L2 bridge client migration stuntime scenario #4867
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
Merged
rnetser
merged 3 commits into
RedHatQE:main
from
Anatw:stuntime_l2_bridge_first_scenario
May 28, 2026
Merged
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
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,110 @@ | ||
| from collections.abc import Generator | ||
| from typing import Final | ||
|
|
||
| import pytest | ||
| from kubernetes.dynamic import DynamicClient | ||
| from ocp_resources.namespace import Namespace | ||
|
|
||
| import tests.network.libs.nodenetworkconfigurationpolicy as libnncp | ||
| from libs.net import netattachdef as libnad | ||
| from libs.net.ip import random_ipv4_address, random_ipv6_address | ||
| from libs.net.vmspec import lookup_iface_status_ip | ||
| 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 | ||
|
|
||
| STUNTIME_BRIDGE_IFACE_NAME: Final[str] = "stuntime-bridge" | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def l2_bridge_stuntime_nad( | ||
| admin_client: DynamicClient, | ||
| namespace: Namespace, | ||
| bridge_nncp: libnncp.NodeNetworkConfigurationPolicy, | ||
| ) -> Generator[libnad.NetworkAttachmentDefinition]: | ||
| nad_name = "l2-bridge-nad" | ||
| config = libnad.NetConfig( | ||
| name=nad_name, | ||
|
Anatw marked this conversation as resolved.
|
||
| plugins=[libnad.CNIPluginBridgeConfig(bridge=bridge_nncp.desired_state_spec.interfaces[0].name)], # type: ignore[index] | ||
| ) | ||
| with libnad.NetworkAttachmentDefinition( | ||
| name=nad_name, | ||
| namespace=namespace.name, | ||
| config=config, | ||
| client=admin_client, | ||
| ) as nad: | ||
| yield nad | ||
|
|
||
|
|
||
| @pytest.fixture(scope="class") | ||
| def stuntime_server_vm( | ||
| unprivileged_client: DynamicClient, | ||
| namespace: Namespace, | ||
| l2_bridge_ip_family: int, | ||
| l2_bridge_stuntime_nad: libnad.NetworkAttachmentDefinition, | ||
| ) -> Generator[BaseVirtualMachine]: | ||
| with secondary_network_vm( | ||
| namespace=namespace.name, | ||
| name="l2bridge-stuntime-server", | ||
| client=unprivileged_client, | ||
| nad_name=l2_bridge_stuntime_nad.name, | ||
| secondary_iface_name=STUNTIME_BRIDGE_IFACE_NAME, | ||
| secondary_iface_addresses=[ | ||
| f"{random_ipv4_address(net_seed=0, host_address=1)}/24", | ||
| f"{random_ipv6_address(net_seed=0, host_address=1)}/64", | ||
| ], | ||
| labels=dict([SERVER_VM_LABEL]), | ||
| ) as server_vm: | ||
| server_vm.start(wait=True) | ||
| server_vm.wait_for_agent_connected() | ||
| yield server_vm | ||
|
|
||
|
|
||
| @pytest.fixture(scope="class") | ||
| def stuntime_client_vm( | ||
| unprivileged_client: DynamicClient, | ||
| namespace: Namespace, | ||
| l2_bridge_stuntime_nad: libnad.NetworkAttachmentDefinition, | ||
| stuntime_server_vm: BaseVirtualMachine, | ||
| ) -> Generator[BaseVirtualMachine]: | ||
| with secondary_network_vm( | ||
| namespace=namespace.name, | ||
| name="l2bridge-stuntime-client", | ||
| client=unprivileged_client, | ||
| nad_name=l2_bridge_stuntime_nad.name, | ||
| secondary_iface_name=STUNTIME_BRIDGE_IFACE_NAME, | ||
| secondary_iface_addresses=[ | ||
| f"{random_ipv4_address(net_seed=0, host_address=2)}/24", | ||
| f"{random_ipv6_address(net_seed=0, host_address=2)}/64", | ||
| ], | ||
| affinity=new_pod_affinity(label=SERVER_VM_LABEL), | ||
| ) as client_vm: | ||
| client_vm.start(wait=True) | ||
| client_vm.wait_for_agent_connected() | ||
| yield client_vm | ||
|
|
||
|
|
||
| @pytest.fixture(scope="class") | ||
| def l2_bridge_ip_family(request: pytest.FixtureRequest) -> int: | ||
| """IP family for stuntime measurement, activated by per-test parametrize.""" | ||
| return request.param | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def l2_bridge_active_ping( | ||
| l2_bridge_ip_family: int, | ||
| stuntime_server_vm: BaseVirtualMachine, | ||
| stuntime_client_vm: BaseVirtualMachine, | ||
| ) -> Generator[ContinuousPing]: | ||
| """Continuous ping session from client to server for stuntime measurement.""" | ||
| server_ip = str( | ||
| lookup_iface_status_ip( | ||
| vm=stuntime_server_vm, | ||
| iface_name=STUNTIME_BRIDGE_IFACE_NAME, | ||
| ip_family=l2_bridge_ip_family, | ||
| ) | ||
| ) | ||
|
|
||
| with ContinuousPing(source_vm=stuntime_client_vm, destination_ip=server_ip) as ping: | ||
| yield ping | ||
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
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.