Loading src/tests/ofc25/tests/Fixtures.py +2 −145 Original line number Diff line number Diff line Loading @@ -12,149 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. import os import pytest from typing import Optional, Tuple from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from monitoring.client.MonitoringClient import MonitoringClient from e2e_orchestrator.client.E2EOrchestratorClient import E2EOrchestratorClient from service.client.ServiceClient import ServiceClient from vnt_manager.client.VNTManagerClient import VNTManagerClient # Service endpoints from kubectl get services -A # These are ClusterIP addresses - update if services are redeployed SERVICE_ENDPOINTS = { 'opt': { 'context': ('10.152.183.189', 1010), 'device': ('10.152.183.92', 2020), 'service': ('10.152.183.198', 3030), }, 'ip': { 'context': ('10.152.183.79', 1010), 'device': ('10.152.183.112', 2020), 'service': ('10.152.183.174', 3030), 'vnt_manager': ('10.152.183.23', 10080), }, 'e2e': { 'context': ('10.152.183.81', 1010), 'device': ('10.152.183.169', 2020), 'service': ('10.152.183.177', 3030), 'e2e_orchestrator': ('10.152.183.201', 10050), } } def _get_endpoint(layer: str, service_name: str) -> Tuple[str, int]: """Get service endpoint from environment variable or default mapping.""" env_host = os.getenv(f'TFS_{layer.upper()}_{service_name.upper()}_HOST') env_port = os.getenv(f'TFS_{layer.upper()}_{service_name.upper()}_PORT') if env_host and env_port: return (env_host, int(env_port)) endpoint = SERVICE_ENDPOINTS.get(layer, {}).get(service_name) if endpoint is None: raise ValueError(f"No endpoint found for layer='{layer}', service='{service_name}'") return endpoint # ========== Optical Layer Fixtures ========== @pytest.fixture(scope='session') def context_client_opt(): host, port = _get_endpoint('opt', 'context') _client = ContextClient(host=host, port=port) yield _client _client.close() @pytest.fixture(scope='session') def device_client_opt(): host, port = _get_endpoint('opt', 'device') _client = DeviceClient(host=host, port=port) yield _client _client.close() @pytest.fixture(scope='session') def service_client_opt(): host, port = _get_endpoint('opt', 'service') _client = ServiceClient(host=host, port=port) yield _client _client.close() # ========== IP Layer Fixtures ========== @pytest.fixture(scope='session') def context_client_ip(): host, port = _get_endpoint('ip', 'context') _client = ContextClient(host=host, port=port) yield _client _client.close() @pytest.fixture(scope='session') def device_client_ip(): host, port = _get_endpoint('ip', 'device') _client = DeviceClient(host=host, port=port) yield _client _client.close() @pytest.fixture(scope='session') def service_client_ip(): host, port = _get_endpoint('ip', 'service') _client = ServiceClient(host=host, port=port) yield _client _client.close() @pytest.fixture(scope='session') def vnt_manager_client_ip(): host, port = _get_endpoint('ip', 'vnt_manager') _client = VNTManagerClient(host=host, port=port) yield _client _client.close() # ========== E2E Layer Fixtures ========== @pytest.fixture(scope='session') def context_client_e2e(): host, port = _get_endpoint('e2e', 'context') _client = ContextClient(host=host, port=port) yield _client _client.close() @pytest.fixture(scope='session') def device_client_e2e(): host, port = _get_endpoint('e2e', 'device') _client = DeviceClient(host=host, port=port) yield _client _client.close() @pytest.fixture(scope='session') def service_client_e2e(): host, port = _get_endpoint('e2e', 'service') _client = ServiceClient(host=host, port=port) yield _client _client.close() @pytest.fixture(scope='session') def e2eorchestrator_client_e2e(): host, port = _get_endpoint('e2e', 'e2e_orchestrator') _client = E2EOrchestratorClient(host=host, port=port) yield _client _client.close() # ========== Legacy Fixtures (for backward compatibility) ========== # These use environment variables from tfs_runtime_env_vars.sh @pytest.fixture(scope='session') def service_client(): _client = ServiceClient() yield _client _client.close() @pytest.fixture(scope='session') def context_client(): _client = ContextClient() Loading @@ -168,13 +31,7 @@ def device_client(): _client.close() @pytest.fixture(scope='session') def monitoring_client(): _client = MonitoringClient() yield _client _client.close() @pytest.fixture(scope='session') def e2eorchestrator_client(): _client = E2EOrchestratorClient() def service_client(): _client = ServiceClient() yield _client _client.close() Loading
src/tests/ofc25/tests/Fixtures.py +2 −145 Original line number Diff line number Diff line Loading @@ -12,149 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. import os import pytest from typing import Optional, Tuple from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from monitoring.client.MonitoringClient import MonitoringClient from e2e_orchestrator.client.E2EOrchestratorClient import E2EOrchestratorClient from service.client.ServiceClient import ServiceClient from vnt_manager.client.VNTManagerClient import VNTManagerClient # Service endpoints from kubectl get services -A # These are ClusterIP addresses - update if services are redeployed SERVICE_ENDPOINTS = { 'opt': { 'context': ('10.152.183.189', 1010), 'device': ('10.152.183.92', 2020), 'service': ('10.152.183.198', 3030), }, 'ip': { 'context': ('10.152.183.79', 1010), 'device': ('10.152.183.112', 2020), 'service': ('10.152.183.174', 3030), 'vnt_manager': ('10.152.183.23', 10080), }, 'e2e': { 'context': ('10.152.183.81', 1010), 'device': ('10.152.183.169', 2020), 'service': ('10.152.183.177', 3030), 'e2e_orchestrator': ('10.152.183.201', 10050), } } def _get_endpoint(layer: str, service_name: str) -> Tuple[str, int]: """Get service endpoint from environment variable or default mapping.""" env_host = os.getenv(f'TFS_{layer.upper()}_{service_name.upper()}_HOST') env_port = os.getenv(f'TFS_{layer.upper()}_{service_name.upper()}_PORT') if env_host and env_port: return (env_host, int(env_port)) endpoint = SERVICE_ENDPOINTS.get(layer, {}).get(service_name) if endpoint is None: raise ValueError(f"No endpoint found for layer='{layer}', service='{service_name}'") return endpoint # ========== Optical Layer Fixtures ========== @pytest.fixture(scope='session') def context_client_opt(): host, port = _get_endpoint('opt', 'context') _client = ContextClient(host=host, port=port) yield _client _client.close() @pytest.fixture(scope='session') def device_client_opt(): host, port = _get_endpoint('opt', 'device') _client = DeviceClient(host=host, port=port) yield _client _client.close() @pytest.fixture(scope='session') def service_client_opt(): host, port = _get_endpoint('opt', 'service') _client = ServiceClient(host=host, port=port) yield _client _client.close() # ========== IP Layer Fixtures ========== @pytest.fixture(scope='session') def context_client_ip(): host, port = _get_endpoint('ip', 'context') _client = ContextClient(host=host, port=port) yield _client _client.close() @pytest.fixture(scope='session') def device_client_ip(): host, port = _get_endpoint('ip', 'device') _client = DeviceClient(host=host, port=port) yield _client _client.close() @pytest.fixture(scope='session') def service_client_ip(): host, port = _get_endpoint('ip', 'service') _client = ServiceClient(host=host, port=port) yield _client _client.close() @pytest.fixture(scope='session') def vnt_manager_client_ip(): host, port = _get_endpoint('ip', 'vnt_manager') _client = VNTManagerClient(host=host, port=port) yield _client _client.close() # ========== E2E Layer Fixtures ========== @pytest.fixture(scope='session') def context_client_e2e(): host, port = _get_endpoint('e2e', 'context') _client = ContextClient(host=host, port=port) yield _client _client.close() @pytest.fixture(scope='session') def device_client_e2e(): host, port = _get_endpoint('e2e', 'device') _client = DeviceClient(host=host, port=port) yield _client _client.close() @pytest.fixture(scope='session') def service_client_e2e(): host, port = _get_endpoint('e2e', 'service') _client = ServiceClient(host=host, port=port) yield _client _client.close() @pytest.fixture(scope='session') def e2eorchestrator_client_e2e(): host, port = _get_endpoint('e2e', 'e2e_orchestrator') _client = E2EOrchestratorClient(host=host, port=port) yield _client _client.close() # ========== Legacy Fixtures (for backward compatibility) ========== # These use environment variables from tfs_runtime_env_vars.sh @pytest.fixture(scope='session') def service_client(): _client = ServiceClient() yield _client _client.close() @pytest.fixture(scope='session') def context_client(): _client = ContextClient() Loading @@ -168,13 +31,7 @@ def device_client(): _client.close() @pytest.fixture(scope='session') def monitoring_client(): _client = MonitoringClient() yield _client _client.close() @pytest.fixture(scope='session') def e2eorchestrator_client(): _client = E2EOrchestratorClient() def service_client(): _client = ServiceClient() yield _client _client.close()