Loading src/tests/ofc25/tests/Fixtures.py +19 −1 Original line number Diff line number Diff line Loading @@ -15,13 +15,14 @@ import re from dataclasses import dataclass from pathlib import Path from typing import Dict, Mapping from typing import Dict, Mapping, Optional import pytest from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from service.client.ServiceClient import ServiceClient from vnt_manager.client.VNTManagerClient import VNTManagerClient PROFILE_OPT = 'opt' PROFILE_IP = 'ip' Loading Loading @@ -49,6 +50,7 @@ class TfsProfile: context: ServiceEndpoint device: ServiceEndpoint service: ServiceEndpoint vnt_manager: Optional[ServiceEndpoint] @dataclass(frozen=True) Loading @@ -56,6 +58,7 @@ class TfsClientBundle: context: ContextClient device: DeviceClient service: ServiceClient vnt_manager: Optional[VNTManagerClient] env_vars: Mapping[str, str] Loading Loading @@ -89,6 +92,14 @@ def _read_service_endpoint(env_vars: Mapping[str, str], service_name: str) -> Se return ServiceEndpoint(host=env_vars[host_key], port=int(env_vars[port_key])) def _read_optional_service_endpoint(env_vars: Mapping[str, str], service_name: str) -> Optional[ServiceEndpoint]: host_key = '{:s}_SERVICE_HOST'.format(service_name) port_key = '{:s}_SERVICE_PORT_GRPC'.format(service_name) if host_key not in env_vars or port_key not in env_vars: return None return ServiceEndpoint(host=env_vars[host_key], port=int(env_vars[port_key])) def _load_tfs_profile(profile_name: str) -> TfsProfile: filepath = RUNTIME_ENV_DIR / PROFILE_FILENAMES[profile_name] if not filepath.exists(): Loading @@ -101,6 +112,7 @@ def _load_tfs_profile(profile_name: str) -> TfsProfile: context=_read_service_endpoint(env_vars, 'CONTEXTSERVICE'), device=_read_service_endpoint(env_vars, 'DEVICESERVICE'), service=_read_service_endpoint(env_vars, 'SERVICESERVICE'), vnt_manager=_read_optional_service_endpoint(env_vars, 'VNT_MANAGERSERVICE'), ) Loading @@ -125,6 +137,10 @@ def tfs_clients(tfs_profiles: Dict[str, TfsProfile]) -> Dict[str, TfsClientBundl context=ContextClient(profile.context.host, profile.context.port), device=DeviceClient(profile.device.host, profile.device.port), service=ServiceClient(profile.service.host, profile.service.port), vnt_manager=( VNTManagerClient(profile.vnt_manager.host, profile.vnt_manager.port) if profile.vnt_manager is not None else None ), env_vars=profile.env_vars, ) Loading @@ -134,3 +150,5 @@ def tfs_clients(tfs_profiles: Dict[str, TfsProfile]) -> Dict[str, TfsClientBundl bundle.context.close() bundle.device.close() bundle.service.close() if bundle.vnt_manager is not None: bundle.vnt_manager.close() src/tests/ofc25/tests/test_functional_create_vlinks.py +4 −0 Original line number Diff line number Diff line Loading @@ -30,9 +30,12 @@ def test_create_virtual_link( ) -> None: ip_context_client = tfs_clients[PROFILE_IP].context ip_device_client = tfs_clients[PROFILE_IP].device ip_vnt_manager_client = tfs_clients[PROFILE_IP].vnt_manager e2e_context_client = tfs_clients[PROFILE_E2E].context opt_context_client = tfs_clients[PROFILE_OPT].context assert ip_vnt_manager_client is not None # Initial state: no services in any TFS and no virtual links in IP. wait_for_state_or_raise( ip_context_client=ip_context_client, Loading @@ -50,6 +53,7 @@ def test_create_virtual_link( descriptors_file=descriptor_file, context_client=ip_context_client, device_client=ip_device_client, vntm_client=ip_vnt_manager_client, ) results = descriptor_loader.process() check_descriptor_load_results(results, descriptor_loader) Loading src/tests/ofc25/tests/test_functional_delete_vlinks.py +4 −0 Original line number Diff line number Diff line Loading @@ -30,9 +30,12 @@ def test_delete_virtual_links( ) -> None: ip_context_client = tfs_clients[PROFILE_IP].context ip_device_client = tfs_clients[PROFILE_IP].device ip_vnt_manager_client = tfs_clients[PROFILE_IP].vnt_manager e2e_context_client = tfs_clients[PROFILE_E2E].context opt_context_client = tfs_clients[PROFILE_OPT].context assert ip_vnt_manager_client is not None expected_virtual_link_ids = {link_id for _, link_id in VIRTUAL_LINK_DESCRIPTORS} wait_for_state_or_raise( ip_context_client=ip_context_client, Loading @@ -51,6 +54,7 @@ def test_delete_virtual_links( descriptors_file=descriptor_file, context_client=ip_context_client, device_client=ip_device_client, vntm_client=ip_vnt_manager_client, ) descriptor_loader.unload() Loading Loading
src/tests/ofc25/tests/Fixtures.py +19 −1 Original line number Diff line number Diff line Loading @@ -15,13 +15,14 @@ import re from dataclasses import dataclass from pathlib import Path from typing import Dict, Mapping from typing import Dict, Mapping, Optional import pytest from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from service.client.ServiceClient import ServiceClient from vnt_manager.client.VNTManagerClient import VNTManagerClient PROFILE_OPT = 'opt' PROFILE_IP = 'ip' Loading Loading @@ -49,6 +50,7 @@ class TfsProfile: context: ServiceEndpoint device: ServiceEndpoint service: ServiceEndpoint vnt_manager: Optional[ServiceEndpoint] @dataclass(frozen=True) Loading @@ -56,6 +58,7 @@ class TfsClientBundle: context: ContextClient device: DeviceClient service: ServiceClient vnt_manager: Optional[VNTManagerClient] env_vars: Mapping[str, str] Loading Loading @@ -89,6 +92,14 @@ def _read_service_endpoint(env_vars: Mapping[str, str], service_name: str) -> Se return ServiceEndpoint(host=env_vars[host_key], port=int(env_vars[port_key])) def _read_optional_service_endpoint(env_vars: Mapping[str, str], service_name: str) -> Optional[ServiceEndpoint]: host_key = '{:s}_SERVICE_HOST'.format(service_name) port_key = '{:s}_SERVICE_PORT_GRPC'.format(service_name) if host_key not in env_vars or port_key not in env_vars: return None return ServiceEndpoint(host=env_vars[host_key], port=int(env_vars[port_key])) def _load_tfs_profile(profile_name: str) -> TfsProfile: filepath = RUNTIME_ENV_DIR / PROFILE_FILENAMES[profile_name] if not filepath.exists(): Loading @@ -101,6 +112,7 @@ def _load_tfs_profile(profile_name: str) -> TfsProfile: context=_read_service_endpoint(env_vars, 'CONTEXTSERVICE'), device=_read_service_endpoint(env_vars, 'DEVICESERVICE'), service=_read_service_endpoint(env_vars, 'SERVICESERVICE'), vnt_manager=_read_optional_service_endpoint(env_vars, 'VNT_MANAGERSERVICE'), ) Loading @@ -125,6 +137,10 @@ def tfs_clients(tfs_profiles: Dict[str, TfsProfile]) -> Dict[str, TfsClientBundl context=ContextClient(profile.context.host, profile.context.port), device=DeviceClient(profile.device.host, profile.device.port), service=ServiceClient(profile.service.host, profile.service.port), vnt_manager=( VNTManagerClient(profile.vnt_manager.host, profile.vnt_manager.port) if profile.vnt_manager is not None else None ), env_vars=profile.env_vars, ) Loading @@ -134,3 +150,5 @@ def tfs_clients(tfs_profiles: Dict[str, TfsProfile]) -> Dict[str, TfsClientBundl bundle.context.close() bundle.device.close() bundle.service.close() if bundle.vnt_manager is not None: bundle.vnt_manager.close()
src/tests/ofc25/tests/test_functional_create_vlinks.py +4 −0 Original line number Diff line number Diff line Loading @@ -30,9 +30,12 @@ def test_create_virtual_link( ) -> None: ip_context_client = tfs_clients[PROFILE_IP].context ip_device_client = tfs_clients[PROFILE_IP].device ip_vnt_manager_client = tfs_clients[PROFILE_IP].vnt_manager e2e_context_client = tfs_clients[PROFILE_E2E].context opt_context_client = tfs_clients[PROFILE_OPT].context assert ip_vnt_manager_client is not None # Initial state: no services in any TFS and no virtual links in IP. wait_for_state_or_raise( ip_context_client=ip_context_client, Loading @@ -50,6 +53,7 @@ def test_create_virtual_link( descriptors_file=descriptor_file, context_client=ip_context_client, device_client=ip_device_client, vntm_client=ip_vnt_manager_client, ) results = descriptor_loader.process() check_descriptor_load_results(results, descriptor_loader) Loading
src/tests/ofc25/tests/test_functional_delete_vlinks.py +4 −0 Original line number Diff line number Diff line Loading @@ -30,9 +30,12 @@ def test_delete_virtual_links( ) -> None: ip_context_client = tfs_clients[PROFILE_IP].context ip_device_client = tfs_clients[PROFILE_IP].device ip_vnt_manager_client = tfs_clients[PROFILE_IP].vnt_manager e2e_context_client = tfs_clients[PROFILE_E2E].context opt_context_client = tfs_clients[PROFILE_OPT].context assert ip_vnt_manager_client is not None expected_virtual_link_ids = {link_id for _, link_id in VIRTUAL_LINK_DESCRIPTORS} wait_for_state_or_raise( ip_context_client=ip_context_client, Loading @@ -51,6 +54,7 @@ def test_delete_virtual_links( descriptors_file=descriptor_file, context_client=ip_context_client, device_client=ip_device_client, vntm_client=ip_vnt_manager_client, ) descriptor_loader.unload() Loading