From c98308966370b6f280472301414b3902ac52307b Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Thu, 10 Oct 2024 17:20:08 +0000
Subject: [PATCH] EuCNC24: Updated CI/CD pipeline and tests

---
 src/tests/eucnc24/Dockerfile                  |  2 +-
 src/tests/eucnc24/tests/Fixtures.py           | 43 +++++++++++++++++++
 .../tests/test_functional_bootstrap.py        |  2 +-
 .../eucnc24/tests/test_functional_cleanup.py  |  2 +-
 .../tests/test_functional_service_ietf.py     |  2 +-
 .../tests/test_functional_service_tfs.py      |  2 +-
 6 files changed, 48 insertions(+), 5 deletions(-)
 create mode 100644 src/tests/eucnc24/tests/Fixtures.py

diff --git a/src/tests/eucnc24/Dockerfile b/src/tests/eucnc24/Dockerfile
index 956d54b74..c46100fff 100644
--- a/src/tests/eucnc24/Dockerfile
+++ b/src/tests/eucnc24/Dockerfile
@@ -82,7 +82,7 @@ source /var/teraflow/tfs_runtime_env_vars.sh
 export PYTHONPATH=/var/teraflow
 pytest --verbose --log-level=INFO /var/teraflow/tests/eucnc24/tests/test_functional_bootstrap.py    --junitxml=/opt/results/report_bootstrap.xml
 pytest --verbose --log-level=INFO /var/teraflow/tests/eucnc24/tests/test_functional_service_tfs.py  --junitxml=/opt/results/report_service_tfs.xml
-#pytest --verbose --log-level=INFO /var/teraflow/tests/eucnc24/tests/test_functional_service_ietf.py --junitxml=/opt/results/report_service_ietf.xml
+pytest --verbose --log-level=INFO /var/teraflow/tests/eucnc24/tests/test_functional_service_ietf.py --junitxml=/opt/results/report_service_ietf.xml
 pytest --verbose --log-level=INFO /var/teraflow/tests/eucnc24/tests/test_functional_cleanup.py      --junitxml=/opt/results/report_cleanup.xml
 EOF
 RUN chmod ug+x ./run_tests.sh
diff --git a/src/tests/eucnc24/tests/Fixtures.py b/src/tests/eucnc24/tests/Fixtures.py
new file mode 100644
index 000000000..a9d2ceb24
--- /dev/null
+++ b/src/tests/eucnc24/tests/Fixtures.py
@@ -0,0 +1,43 @@
+# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import pytest
+from context.client.ContextClient import ContextClient
+from device.client.DeviceClient import DeviceClient
+from monitoring.client.MonitoringClient import MonitoringClient
+from service.client.ServiceClient import ServiceClient
+
+@pytest.fixture(scope='session')
+def context_client():
+    _client = ContextClient()
+    yield _client
+    _client.close()
+
+@pytest.fixture(scope='session')
+def device_client():
+    _client = DeviceClient()
+    yield _client
+    _client.close()
+
+@pytest.fixture(scope='session')
+def monitoring_client():
+    _client = MonitoringClient()
+    yield _client
+    _client.close()
+
+@pytest.fixture(scope='session')
+def service_client():
+    _client = ServiceClient()
+    yield _client
+    _client.close()
diff --git a/src/tests/eucnc24/tests/test_functional_bootstrap.py b/src/tests/eucnc24/tests/test_functional_bootstrap.py
index 38040a308..5222a4c87 100644
--- a/src/tests/eucnc24/tests/test_functional_bootstrap.py
+++ b/src/tests/eucnc24/tests/test_functional_bootstrap.py
@@ -19,7 +19,7 @@ from common.tools.descriptor.Loader import DescriptorLoader, check_descriptor_lo
 from common.tools.object_factory.Context import json_context_id
 from context.client.ContextClient import ContextClient
 from device.client.DeviceClient import DeviceClient
-from tests.Fixtures import context_client, device_client # pylint: disable=unused-import
+from .Fixtures import context_client, device_client # pylint: disable=unused-import
 
 LOGGER = logging.getLogger(__name__)
 LOGGER.setLevel(logging.DEBUG)
diff --git a/src/tests/eucnc24/tests/test_functional_cleanup.py b/src/tests/eucnc24/tests/test_functional_cleanup.py
index 1adf8f2b9..7cfed0caf 100644
--- a/src/tests/eucnc24/tests/test_functional_cleanup.py
+++ b/src/tests/eucnc24/tests/test_functional_cleanup.py
@@ -19,7 +19,7 @@ from common.tools.descriptor.Loader import DescriptorLoader, validate_empty_scen
 from common.tools.object_factory.Context import json_context_id
 from context.client.ContextClient import ContextClient
 from device.client.DeviceClient import DeviceClient
-from tests.Fixtures import context_client, device_client    # pylint: disable=unused-import
+from .Fixtures import context_client, device_client    # pylint: disable=unused-import
 
 LOGGER = logging.getLogger(__name__)
 LOGGER.setLevel(logging.DEBUG)
diff --git a/src/tests/eucnc24/tests/test_functional_service_ietf.py b/src/tests/eucnc24/tests/test_functional_service_ietf.py
index 4b9e69bb0..70d398873 100644
--- a/src/tests/eucnc24/tests/test_functional_service_ietf.py
+++ b/src/tests/eucnc24/tests/test_functional_service_ietf.py
@@ -19,7 +19,7 @@ from common.proto.context_pb2 import ContextId, ServiceStatusEnum, ServiceTypeEn
 from common.tools.grpc.Tools import grpc_message_to_json_string
 from common.tools.object_factory.Context import json_context_id
 from context.client.ContextClient import ContextClient
-from tests.Fixtures import context_client   # pylint: disable=unused-import
+from .Fixtures import context_client   # pylint: disable=unused-import
 from .Tools import do_rest_delete_request, do_rest_get_request, do_rest_post_request
 
 
diff --git a/src/tests/eucnc24/tests/test_functional_service_tfs.py b/src/tests/eucnc24/tests/test_functional_service_tfs.py
index 596da9a49..f66047db3 100644
--- a/src/tests/eucnc24/tests/test_functional_service_tfs.py
+++ b/src/tests/eucnc24/tests/test_functional_service_tfs.py
@@ -23,7 +23,7 @@ from common.tools.object_factory.Service import json_service_id
 from context.client.ContextClient import ContextClient
 from device.client.DeviceClient import DeviceClient
 from service.client.ServiceClient import ServiceClient
-from tests.Fixtures import context_client, device_client, service_client        # pylint: disable=unused-import
+from .Fixtures import context_client, device_client, service_client        # pylint: disable=unused-import
 
 LOGGER = logging.getLogger(__name__)
 LOGGER.setLevel(logging.DEBUG)
-- 
GitLab