From a868d68d0d45152c1e697716a9f926e9d323b9d4 Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Tue, 11 Jul 2023 13:27:42 +0000
Subject: [PATCH] Pre-release CI/CD pipeline fixes

---
 src/common/tools/object_factory/EndPoint.py       | 15 ++++++++++-----
 src/service/.gitlab-ci.yml                        |  1 +
 src/service/service/ServiceServiceServicerImpl.py |  3 +++
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/common/tools/object_factory/EndPoint.py b/src/common/tools/object_factory/EndPoint.py
index 0e754be9f..a776dfebb 100644
--- a/src/common/tools/object_factory/EndPoint.py
+++ b/src/common/tools/object_factory/EndPoint.py
@@ -20,9 +20,12 @@ def json_endpoint_descriptor(
     sample_types : List[int] = [], location : Optional[Dict] = None
 ) -> Dict:
     result = {'uuid': endpoint_uuid, 'type': endpoint_type}
-    if endpoint_name is not None: result['name'] = endpoint_name
-    if sample_types is not None and len(sample_types) > 0: result['sample_types'] = sample_types
-    if location is not None and len(location) > 0: result['location'] = location
+    if endpoint_name is not None:
+        result['name'] = endpoint_name
+    if sample_types is not None and len(sample_types) > 0:
+        result['sample_types'] = sample_types
+    if location is not None and len(location) > 0:
+        result['location'] = location
     return result
 
 def json_endpoint_id(device_id : Dict, endpoint_uuid : str, topology_id : Optional[Dict] = None):
@@ -47,8 +50,10 @@ def json_endpoint(
         'endpoint_id': json_endpoint_id(device_id, endpoint_uuid, topology_id=topology_id),
         'endpoint_type': endpoint_type,
     }
-    if len(kpi_sample_types) > 0: result['kpi_sample_types'] = copy.deepcopy(kpi_sample_types)
-    if location: result['endpoint_location'] = copy.deepcopy(location)
+    if kpi_sample_types is not None and len(kpi_sample_types) > 0:
+        result['kpi_sample_types'] = copy.deepcopy(kpi_sample_types)
+    if location is not None:
+        result['endpoint_location'] = copy.deepcopy(location)
     return result
 
 def json_endpoints(
diff --git a/src/service/.gitlab-ci.yml b/src/service/.gitlab-ci.yml
index c9ff94ac9..b1657dd9f 100644
--- a/src/service/.gitlab-ci.yml
+++ b/src/service/.gitlab-ci.yml
@@ -136,6 +136,7 @@ unit_test service:
     # Service preparation
     - >
       docker run --name $IMAGE_NAME -d -p 3030:3030
+      --env "LOG_LEVEL=DEBUG"
       --env "CONTEXTSERVICE_SERVICE_HOST=${CONTEXTSERVICE_SERVICE_HOST}"
       --env "DEVICESERVICE_SERVICE_HOST=${DEVICESERVICE_SERVICE_HOST}"
       --env "PATHCOMPSERVICE_SERVICE_HOST=${PATHCOMPSERVICE_SERVICE_HOST}"
diff --git a/src/service/service/ServiceServiceServicerImpl.py b/src/service/service/ServiceServiceServicerImpl.py
index 84a856e5e..fe66c04e2 100644
--- a/src/service/service/ServiceServiceServicerImpl.py
+++ b/src/service/service/ServiceServiceServicerImpl.py
@@ -106,6 +106,7 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
         for endpoint_id in request.service_endpoint_ids:
             service.service_endpoint_ids.add().CopyFrom(endpoint_id)    # pylint: disable=no-member
 
+        LOGGER.warning('[before] request={:s}'.format(grpc_message_to_json_string(request)))
         for constraint in request.service_constraints:
             if constraint.action != ConstraintActionEnum.CONSTRAINTACTION_SET: continue
             if constraint.WhichOneof('constraint') != 'endpoint_location': continue
@@ -130,6 +131,8 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
             ]
             if closer_endpoint_id not in service_endpoint_ids:
                 service.service_endpoint_ids.append(closer_endpoint_id)
+        LOGGER.warning('[after] request={:s}'.format(grpc_message_to_json_string(request)))
+        LOGGER.warning('[after] service={:s}'.format(grpc_message_to_json_string(service)))
 
         del service.service_constraints[:]  # pylint: disable=no-member
         for constraint in request.service_constraints:
-- 
GitLab