From 1918de9c5db7b0f28b3de270625feb1ced7411d2 Mon Sep 17 00:00:00 2001
From: Ville Hallivuori <VHallivuori@infinera.com>
Date: Fri, 16 Dec 2022 16:47:56 +0200
Subject: [PATCH] Update XR Driver functional tests to work with newer TF
 baseline

---
 src/device/service/drivers/xr/README_XR.md               | 2 +-
 src/device/service/drivers/xr/setup_test_env.sh          | 9 +++++++++
 .../ofc22/tests/test_functional_create_service_xr.py     | 2 +-
 .../ofc22/tests/test_functional_delete_service_xr.py     | 2 +-
 4 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100755 src/device/service/drivers/xr/setup_test_env.sh

diff --git a/src/device/service/drivers/xr/README_XR.md b/src/device/service/drivers/xr/README_XR.md
index f7c2316ce..3bfdf5b01 100644
--- a/src/device/service/drivers/xr/README_XR.md
+++ b/src/device/service/drivers/xr/README_XR.md
@@ -110,7 +110,7 @@ Upload descriptors_emulatex_xr.json via WEB UI to setup fake topology.
 Setup service by following commands in src directory. Kubernetes endpoins change on every build, so setup script is mandatory.
 
 ```bash
-    source tests/ofc22/setup_test_env.sh 
+    source  device/service/drivers/xr/setup_test_env.sh
     python -m pytest --verbose tests/ofc22/tests/test_functional_create_service_xr.py 
 ```
 
diff --git a/src/device/service/drivers/xr/setup_test_env.sh b/src/device/service/drivers/xr/setup_test_env.sh
new file mode 100755
index 000000000..1f8b0a5a7
--- /dev/null
+++ b/src/device/service/drivers/xr/setup_test_env.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+export CONTEXTSERVICE_SERVICE_HOST=$(kubectl get service/contextservice --namespace tfs  --template '{{.spec.clusterIP}}')
+export CONTEXTSERVICE_SERVICE_PORT_GRPC=$(kubectl get service/contextservice --namespace tfs  -o jsonpath='{.spec.ports[?(@.name=="grpc")].port}')
+export COMPUTESERVICE_SERVICE_HOST=$(kubectl get service/computeservice --namespace tfs  --template '{{.spec.clusterIP}}')
+export COMPUTESERVICE_SERVICE_PORT_HTTP=$(kubectl get service/computeservice --namespace tfs  -o jsonpath='{.spec.ports[?(@.name=="http")].port}')
+echo "CONTEXTSERVICE_SERVICE_HOST=$CONTEXTSERVICE_SERVICE_HOST"
+echo "CONTEXTSERVICE_SERVICE_PORT_GRPC=$CONTEXTSERVICE_SERVICE_PORT_GRPC"
+echo "COMPUTESERVICE_SERVICE_HOST=$COMPUTESERVICE_SERVICE_HOST"
+echo "COMPUTESERVICE_SERVICE_PORT_HTTP=$COMPUTESERVICE_SERVICE_PORT_HTTP"
diff --git a/src/tests/ofc22/tests/test_functional_create_service_xr.py b/src/tests/ofc22/tests/test_functional_create_service_xr.py
index bb78abc1e..6008eaa10 100644
--- a/src/tests/ofc22/tests/test_functional_create_service_xr.py
+++ b/src/tests/ofc22/tests/test_functional_create_service_xr.py
@@ -20,7 +20,7 @@ from common.tools.object_factory.Connection import json_connection_id
 from common.tools.object_factory.Device import json_device_id
 from common.tools.object_factory.Service import json_service_id
 from common.tools.grpc.Tools import grpc_message_to_json_string
-from compute.tests.mock_osm.MockOSM import MockOSM
+from tests.tools.mock_osm.MockOSM import MockOSM
 from context.client.ContextClient import ContextClient
 from context.client.EventsCollector import EventsCollector
 from common.proto.context_pb2 import ContextId, Empty
diff --git a/src/tests/ofc22/tests/test_functional_delete_service_xr.py b/src/tests/ofc22/tests/test_functional_delete_service_xr.py
index f28828be0..546a8781b 100644
--- a/src/tests/ofc22/tests/test_functional_delete_service_xr.py
+++ b/src/tests/ofc22/tests/test_functional_delete_service_xr.py
@@ -20,7 +20,7 @@ from common.tools.object_factory.Connection import json_connection_id
 from common.tools.object_factory.Device import json_device_id
 from common.tools.object_factory.Service import json_service_id
 from common.tools.grpc.Tools import grpc_message_to_json_string
-from compute.tests.mock_osm.MockOSM import MockOSM
+from tests.tools.mock_osm.MockOSM import MockOSM
 from context.client.ContextClient import ContextClient
 from context.client.EventsCollector import EventsCollector
 from common.proto.context_pb2 import ContextId, Empty, ServiceTypeEnum
-- 
GitLab