Commit 8a26fd5d authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Context/Service/PathComp component fixes:

Common:
- Added missing object factory methods for constraints

Context:
- Adapted unitary tests to new constraint object factory methods

Service:
- Adapted unitary tests to new constraint object factory methods

PathComp-Backend:
- Deactivated health probes since it causes problems in backend REST server

PathComp-Frontend:
- Correct unitary test constraints for SP algorithm
- Adapted unitary tests to new constraint object factory methods
- Fixed instantiation of ShortestPath and KDisjointPath Algorithms
- Ignore unknown constraints in Algorithm request composition
parent 49fef75e
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -51,18 +51,18 @@ spec:
      - name: backend
        image: registry.gitlab.com/teraflow-h2020/controller/pathcomp-backend:latest
        imagePullPolicy: Always
        readinessProbe:
          httpGet:
            path: /health
            port: 8081
          initialDelaySeconds: 5
          timeoutSeconds: 5
        livenessProbe:
          httpGet:
            path: /health
            port: 8081
          initialDelaySeconds: 5
          timeoutSeconds: 5
        #readinessProbe:
        #  httpGet:
        #    path: /health
        #    port: 8081
        #  initialDelaySeconds: 5
        #  timeoutSeconds: 5
        #livenessProbe:
        #  httpGet:
        #    path: /health
        #    port: 8081
        #  initialDelaySeconds: 5
        #  timeoutSeconds: 5
        resources:
          requests:
            cpu: 250m
+14 −1
Original line number Diff line number Diff line
@@ -15,6 +15,19 @@
import json
from typing import Any, Dict, Union

def json_constraint(constraint_type : str, constraint_value : Union[str, Dict[str, Any]]):
def json_constraint_custom(constraint_type : str, constraint_value : Union[str, Dict[str, Any]]) -> Dict:
    if not isinstance(constraint_value, str): constraint_value = json.dumps(constraint_value, sort_keys=True)
    return {'custom': {'constraint_type': constraint_type, 'constraint_value': constraint_value}}

def json_constraint_endpoint_location_region(endpoint_id : Dict, region : str) -> Dict:
    return {'endpoint_location': {'endpoint_id': endpoint_id, 'location': {'region': region}}}

def json_constraint_endpoint_location_gps(endpoint_id : Dict, latitude : float, longitude : float) -> Dict:
    gps_position = {'latitude': latitude, 'longitude': longitude}
    return {'endpoint_location': {'endpoint_id': endpoint_id, 'location': {'gps_position': gps_position}}}

def json_constraint_endpoint_priority(endpoint_id : Dict, priority : int) -> Dict:
    return {'endpoint_priority': {'endpoint_id': endpoint_id, 'priority': priority}}

def json_constraint_sla_availability(num_disjoint_paths : int, all_active : bool) -> Dict:
    return {'sla_availability': {'num_disjoint_paths': num_disjoint_paths, 'all_active': all_active}}
+7 −7
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ from common.Constants import DEFAULT_CONTEXT_UUID, DEFAULT_TOPOLOGY_UUID
from common.proto.kpi_sample_types_pb2 import KpiSampleType
from common.tools.object_factory.ConfigRule import json_config_rule_set
from common.tools.object_factory.Connection import json_connection, json_connection_id
from common.tools.object_factory.Constraint import json_constraint
from common.tools.object_factory.Constraint import json_constraint_custom
from common.tools.object_factory.Context import json_context, json_context_id
from common.tools.object_factory.Device import json_device_id, json_device_packetrouter_disabled
from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_id
@@ -129,8 +129,8 @@ SERVICE_R1_R2_EPIDS = [
    json_endpoint_id(DEVICE_R2_ID, 'EP100', topology_id=TOPOLOGY_ID),
]
SERVICE_R1_R2_CONST = [
    json_constraint('latency_ms', '15.2'),
    json_constraint('jitter_us',  '1.2'),
    json_constraint_custom('latency_ms', '15.2'),
    json_constraint_custom('jitter_us',  '1.2'),
]
SERVICE_R1_R2_RULES = [
    json_config_rule_set('svc/rsrc1/value', 'value7'),
@@ -149,8 +149,8 @@ SERVICE_R1_R3_EPIDS = [
    json_endpoint_id(DEVICE_R3_ID, 'EP100', topology_id=TOPOLOGY_ID),
]
SERVICE_R1_R3_CONST = [
    json_constraint('latency_ms', '5.8'),
    json_constraint('jitter_us',  '0.1'),
    json_constraint_custom('latency_ms', '5.8'),
    json_constraint_custom('jitter_us',  '0.1'),
]
SERVICE_R1_R3_RULES = [
    json_config_rule_set('svc/rsrc1/value', 'value7'),
@@ -169,8 +169,8 @@ SERVICE_R2_R3_EPIDS = [
    json_endpoint_id(DEVICE_R3_ID, 'EP100', topology_id=TOPOLOGY_ID),
]
SERVICE_R2_R3_CONST = [
    json_constraint('latency_ms', '23.1'),
    json_constraint('jitter_us',  '3.4'),
    json_constraint_custom('latency_ms', '23.1'),
    json_constraint_custom('jitter_us',  '3.4'),
]
SERVICE_R2_R3_RULES = [
    json_config_rule_set('svc/rsrc1/value', 'value7'),
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ Service_Endpoints = Dict[Endpoint_Id, Endpoint_Details]
Service_Details     = Tuple[int, Service_Constraints, Service_Endpoints]
Services_Details    = Dict[Service_Id, Service_Details]

CUSTOM_CONSTRAINTS = {'bandwidth[gbps]', 'latency[ms]'}
CUSTOM_CONSTRAINTS = {'bandwidth[gbps]', 'latency[ms]', 'jitter[us]'}

DUMP_EXECUTION_STEPS = False

+0 −2
Original line number Diff line number Diff line
@@ -18,11 +18,9 @@ from ._Algorithm import _Algorithm
class ShortestPathAlgorithm(_Algorithm):
    def __init__(self, algorithm : Algorithm_ShortestPath, class_name=__name__) -> None:
        super().__init__('SP', False, class_name=class_name)
        self.k_paths = 1

    def add_service_requests(self, requested_services) -> None:
        super().add_service_requests(requested_services)
        for service_request in self.service_list:
            service_request['algId'    ] = self.algorithm_id
            service_request['syncPaths'] = self.sync_paths
            service_request['kPaths'   ] = self.k_paths
Loading