From fc145563d595e29578089e5cbdefc3c441e48b69 Mon Sep 17 00:00:00 2001
From: Lluis Gifre <lluis.gifre@cttc.es>
Date: Mon, 1 Aug 2022 18:15:00 +0000
Subject: [PATCH] ECOC'22 functional test:

- arranged run_test scripts and objects
- deactivated unneeded components in the deployment
- arranged LoadDescriptors Python script
- improved Tutorial page for ECOC'22 demo
---
 src/tests/ecoc22/deploy_specs.sh                         | 2 +-
 src/tests/ecoc22/redeploy.sh                             | 4 ++++
 src/tests/ecoc22/run_test_01_bootstrap.sh                | 1 +
 src/tests/ecoc22/run_test_02_create_service.sh           | 1 +
 src/tests/ecoc22/run_test_03_delete_service.sh           | 1 +
 src/tests/ecoc22/run_test_04_cleanup.sh                  | 1 +
 src/tests/ecoc22/tests/LoadDescriptors.py                | 8 +++-----
 src/tests/ecoc22/tests/Objects.py                        | 2 +-
 src/tests/ecoc22/tests/test_functional_bootstrap.py      | 6 +++---
 src/tests/ecoc22/tests/test_functional_create_service.py | 2 +-
 src/tests/ecoc22/tests/test_functional_delete_service.py | 2 +-
 tutorial/2-4-ecoc22.md                                   | 5 +++++
 12 files changed, 23 insertions(+), 12 deletions(-)
 create mode 100755 src/tests/ecoc22/redeploy.sh

diff --git a/src/tests/ecoc22/deploy_specs.sh b/src/tests/ecoc22/deploy_specs.sh
index 4afe7e20f..dc75c4b2c 100644
--- a/src/tests/ecoc22/deploy_specs.sh
+++ b/src/tests/ecoc22/deploy_specs.sh
@@ -2,7 +2,7 @@
 export TFS_REGISTRY_IMAGE="http://localhost:32000/tfs/"
 
 # Set the list of components, separated by spaces, you want to build images for, and deploy.
-export TFS_COMPONENTS="context device automation service slice compute webui"
+export TFS_COMPONENTS="context device service slice compute" # automation webui
 
 # Set the tag you want to use for your images.
 export TFS_IMAGE_TAG="dev"
diff --git a/src/tests/ecoc22/redeploy.sh b/src/tests/ecoc22/redeploy.sh
new file mode 100755
index 000000000..3f3986deb
--- /dev/null
+++ b/src/tests/ecoc22/redeploy.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+source ecoc22/deploy_specs.sh
+./deploy.sh
+source tfs_runtime_env_vars.sh
diff --git a/src/tests/ecoc22/run_test_01_bootstrap.sh b/src/tests/ecoc22/run_test_01_bootstrap.sh
index 4e94fcb2c..819991d78 100755
--- a/src/tests/ecoc22/run_test_01_bootstrap.sh
+++ b/src/tests/ecoc22/run_test_01_bootstrap.sh
@@ -13,4 +13,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+source tfs_runtime_env_vars.sh
 pytest --verbose src/tests/ecoc22/tests/test_functional_bootstrap.py
diff --git a/src/tests/ecoc22/run_test_02_create_service.sh b/src/tests/ecoc22/run_test_02_create_service.sh
index 9cab7daa2..5a54d39d4 100755
--- a/src/tests/ecoc22/run_test_02_create_service.sh
+++ b/src/tests/ecoc22/run_test_02_create_service.sh
@@ -13,4 +13,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+source tfs_runtime_env_vars.sh
 pytest --verbose src/tests/ecoc22/tests/test_functional_create_service.py
diff --git a/src/tests/ecoc22/run_test_03_delete_service.sh b/src/tests/ecoc22/run_test_03_delete_service.sh
index b01ba350a..900e09b65 100755
--- a/src/tests/ecoc22/run_test_03_delete_service.sh
+++ b/src/tests/ecoc22/run_test_03_delete_service.sh
@@ -13,4 +13,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+source tfs_runtime_env_vars.sh
 pytest --verbose src/tests/ecoc22/tests/test_functional_delete_service.py
diff --git a/src/tests/ecoc22/run_test_04_cleanup.sh b/src/tests/ecoc22/run_test_04_cleanup.sh
index a2925d633..4e0622e6b 100755
--- a/src/tests/ecoc22/run_test_04_cleanup.sh
+++ b/src/tests/ecoc22/run_test_04_cleanup.sh
@@ -13,4 +13,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+source tfs_runtime_env_vars.sh
 pytest --verbose src/tests/ecoc22/tests/test_functional_cleanup.py
diff --git a/src/tests/ecoc22/tests/LoadDescriptors.py b/src/tests/ecoc22/tests/LoadDescriptors.py
index 495b05a89..bd7e48366 100644
--- a/src/tests/ecoc22/tests/LoadDescriptors.py
+++ b/src/tests/ecoc22/tests/LoadDescriptors.py
@@ -15,17 +15,15 @@
 import json, logging, sys
 from common.Settings import get_setting
 from context.client.ContextClient import ContextClient
-from context.proto.context_pb2 import Context, Device, Link, Topology
+from common.proto.context_pb2 import Context, Device, Link, Topology
 from device.client.DeviceClient import DeviceClient
 
 LOGGER = logging.getLogger(__name__)
 LOGGER.setLevel(logging.DEBUG)
 
 def main():
-    context_client = ContextClient(
-        get_setting('CONTEXTSERVICE_SERVICE_HOST'), get_setting('CONTEXTSERVICE_SERVICE_PORT_GRPC'))
-    device_client  = DeviceClient(
-        get_setting('DEVICESERVICE_SERVICE_HOST'), get_setting('DEVICESERVICE_SERVICE_PORT_GRPC'))
+    context_client = ContextClient()
+    device_client  = DeviceClient()
 
     with open('tests/ecoc22/descriptors.json', 'r', encoding='UTF-8') as f:
         descriptors = json.loads(f.read())
diff --git a/src/tests/ecoc22/tests/Objects.py b/src/tests/ecoc22/tests/Objects.py
index 062a00516..33a6ad052 100644
--- a/src/tests/ecoc22/tests/Objects.py
+++ b/src/tests/ecoc22/tests/Objects.py
@@ -258,7 +258,7 @@ WIM_SEP_DC2_SEC, WIM_MAP_DC2_SEC = mapping('DC2', ENDPOINT_ID_CE4_1_1, DEVICE_PE
 WIM_MAPPING  = [WIM_MAP_DC1_PRI, WIM_MAP_DC1_SEC, WIM_MAP_DC2_PRI, WIM_MAP_DC2_SEC]
 
 WIM_SRV_VLAN_ID = 300
-WIM_SERVICE_TYPE = 'ELINE'
+WIM_SERVICE_TYPE = 'ELAN'
 WIM_SERVICE_CONNECTION_POINTS = [
     {'service_endpoint_id': WIM_SEP_DC1_PRI,
         'service_endpoint_encapsulation_type': 'dot1q',
diff --git a/src/tests/ecoc22/tests/test_functional_bootstrap.py b/src/tests/ecoc22/tests/test_functional_bootstrap.py
index 7626ce304..a787cf049 100644
--- a/src/tests/ecoc22/tests/test_functional_bootstrap.py
+++ b/src/tests/ecoc22/tests/test_functional_bootstrap.py
@@ -14,8 +14,8 @@
 
 import copy, logging, pytest
 from common.Settings import get_setting
+from common.proto.context_pb2 import Context, ContextId, Device, Empty, Link, Topology
 from context.client.ContextClient import ContextClient
-from context.proto.context_pb2 import Context, ContextId, Device, Empty, Link, Topology
 from device.client.DeviceClient import DeviceClient
 from .Objects import CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES
 
@@ -26,14 +26,14 @@ LOGGER.setLevel(logging.DEBUG)
 
 @pytest.fixture(scope='session')
 def context_client():
-    _client = ContextClient(get_setting('CONTEXTSERVICE_SERVICE_HOST'), get_setting('CONTEXTSERVICE_SERVICE_PORT_GRPC'))
+    _client = ContextClient()
     yield _client
     _client.close()
 
 
 @pytest.fixture(scope='session')
 def device_client():
-    _client = DeviceClient(get_setting('DEVICESERVICE_SERVICE_HOST'), get_setting('DEVICESERVICE_SERVICE_PORT_GRPC'))
+    _client = DeviceClient()
     yield _client
     _client.close()
 
diff --git a/src/tests/ecoc22/tests/test_functional_create_service.py b/src/tests/ecoc22/tests/test_functional_create_service.py
index 58d87dada..2928d9b35 100644
--- a/src/tests/ecoc22/tests/test_functional_create_service.py
+++ b/src/tests/ecoc22/tests/test_functional_create_service.py
@@ -14,10 +14,10 @@
 
 import logging, pytest
 from common.Settings import get_setting
+from common.proto.context_pb2 import ContextId, Empty
 from common.tools.grpc.Tools import grpc_message_to_json_string
 from compute.tests.mock_osm.MockOSM import MockOSM
 from context.client.ContextClient import ContextClient
-from context.proto.context_pb2 import ContextId, Empty
 from .Objects import (
     CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES, WIM_MAPPING, WIM_PASSWORD, WIM_SERVICE_CONNECTION_POINTS,
     WIM_SERVICE_TYPE, WIM_USERNAME)
diff --git a/src/tests/ecoc22/tests/test_functional_delete_service.py b/src/tests/ecoc22/tests/test_functional_delete_service.py
index 51e91a596..89fe22b1f 100644
--- a/src/tests/ecoc22/tests/test_functional_delete_service.py
+++ b/src/tests/ecoc22/tests/test_functional_delete_service.py
@@ -15,6 +15,7 @@
 import logging, pytest
 from common.DeviceTypes import DeviceTypeEnum
 from common.Settings import get_setting
+from common.proto.context_pb2 import ContextId, Empty
 from common.tests.EventTools import EVENT_REMOVE, EVENT_UPDATE, check_events
 from common.tools.object_factory.Connection import json_connection_id
 from common.tools.object_factory.Device import json_device_id
@@ -23,7 +24,6 @@ from common.tools.grpc.Tools import grpc_message_to_json_string
 from compute.tests.mock_osm.MockOSM import MockOSM
 from context.client.ContextClient import ContextClient
 from context.client.EventsCollector import EventsCollector
-from context.proto.context_pb2 import ContextId, Empty
 from .Objects import (
     CONTEXT_ID, CONTEXTS, DEVICE_O1_UUID, DEVICE_R1_UUID, DEVICE_R3_UUID, DEVICES, LINKS, TOPOLOGIES, WIM_MAPPING,
     WIM_PASSWORD, WIM_USERNAME)
diff --git a/tutorial/2-4-ecoc22.md b/tutorial/2-4-ecoc22.md
index b28fdfd1c..6fc9333b5 100644
--- a/tutorial/2-4-ecoc22.md
+++ b/tutorial/2-4-ecoc22.md
@@ -29,6 +29,11 @@ environment as described in
 [Tutorial: Run Experiments Guide > 2.1. Configure Python Environment](./2-1-python-environment.md).
 Remember to source the scenario settings appropriately, e.g., `cd ~/tfs-ctrl && source my_deploy.sh` in each terminal
 you open.
+Next, remember to source the environment variables created by the deployment, e.g.,
+`cd ~/tfs-ctrl && source tfs_runtime_env_vars.sh`.
+Then, re-build the protocol buffers code from the proto files:
+`./proto/generate_code_python.sh`
+
 
 
 ## 2.4.4. Access to the WebUI and Dashboard
-- 
GitLab