Commit 96f54ae3 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Tests:

- Corrected new definition of endpoint descriptors in tests and components
parent 6efeac2c
Loading
Loading
Loading
Loading
+0 −10
Original line number Original line Diff line number Diff line
@@ -143,16 +143,6 @@ def json_device_connect_rules(address : str, port : int, settings : Dict = {}) -
        json_config_rule_set('_connect/settings', settings),
        json_config_rule_set('_connect/settings', settings),
    ]
    ]


def json_endpoint_descriptor(
    endpoint_uuid : str, endpoint_type : str, endpoint_name : Optional[str] = None,
    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
    return result

def json_device_emulated_connect_rules(
def json_device_emulated_connect_rules(
    endpoint_descriptors : List[Dict], address : str = DEVICE_EMU_ADDRESS, port : int = DEVICE_EMU_PORT
    endpoint_descriptors : List[Dict], address : str = DEVICE_EMU_ADDRESS, port : int = DEVICE_EMU_PORT
) -> List[Dict]:
) -> List[Dict]:
+18 −8
Original line number Original line Diff line number Diff line
@@ -13,7 +13,17 @@
# limitations under the License.
# limitations under the License.


import copy
import copy
from typing import Dict, List, Optional, Tuple
from typing import Dict, List, Optional

def json_endpoint_descriptor(
    endpoint_uuid : str, endpoint_type : str, endpoint_name : Optional[str] = None,
    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
    return result


def json_endpoint_id(device_id : Dict, endpoint_uuid : str, topology_id : Optional[Dict] = None):
def json_endpoint_id(device_id : Dict, endpoint_uuid : str, topology_id : Optional[Dict] = None):
    result = {'device_id': copy.deepcopy(device_id), 'endpoint_uuid': {'uuid': endpoint_uuid}}
    result = {'device_id': copy.deepcopy(device_id), 'endpoint_uuid': {'uuid': endpoint_uuid}}
@@ -21,11 +31,11 @@ def json_endpoint_id(device_id : Dict, endpoint_uuid : str, topology_id : Option
    return result
    return result


def json_endpoint_ids(
def json_endpoint_ids(
        device_id : Dict, endpoint_descriptors : List[Tuple[str, str, List[int]]], topology_id : Optional[Dict] = None
        device_id : Dict, endpoint_descriptors : List[Dict], topology_id : Optional[Dict] = None
    ):
    ):
    return [
    return [
        json_endpoint_id(device_id, endpoint_uuid, topology_id=topology_id)
        json_endpoint_id(device_id, endpoint_data['uuid'], topology_id=topology_id)
        for endpoint_uuid, _, _ in endpoint_descriptors
        for endpoint_data in endpoint_descriptors
    ]
    ]


def json_endpoint(
def json_endpoint(
@@ -42,11 +52,11 @@ def json_endpoint(
    return result
    return result


def json_endpoints(
def json_endpoints(
        device_id : Dict, endpoint_descriptors : List[Tuple[str, str, List[int]]], topology_id : Optional[Dict] = None
        device_id : Dict, endpoint_descriptors : List[Dict], topology_id : Optional[Dict] = None
    ):
    ):
    return [
    return [
        json_endpoint(
        json_endpoint(
            device_id, endpoint_uuid, endpoint_type, topology_id=topology_id,
            device_id, endpoint_data['uuid'], endpoint_data['type'], topology_id=topology_id,
            kpi_sample_types=endpoint_sample_types)
            kpi_sample_types=endpoint_data['sample_types'])
        for endpoint_uuid, endpoint_type, endpoint_sample_types in endpoint_descriptors
        for endpoint_data in endpoint_descriptors
    ]
    ]
+2 −2
Original line number Original line Diff line number Diff line
@@ -15,8 +15,8 @@
from common.proto.kpi_sample_types_pb2 import KpiSampleType
from common.proto.kpi_sample_types_pb2 import KpiSampleType
from common.tools.object_factory.ConfigRule import json_config_rule_delete, json_config_rule_set
from common.tools.object_factory.ConfigRule import json_config_rule_delete, json_config_rule_set
from common.tools.object_factory.Device import (
from common.tools.object_factory.Device import (
    json_device_emulated_connect_rules, json_device_emulated_packet_router_disabled, json_device_id,
    json_device_emulated_connect_rules, json_device_emulated_packet_router_disabled, json_device_id)
    json_endpoint_descriptor)
from common.tools.object_factory.EndPoint import json_endpoint_descriptor
from device.tests.CommonObjects import PACKET_PORT_SAMPLE_TYPES
from device.tests.CommonObjects import PACKET_PORT_SAMPLE_TYPES


DEVICE_EMU_UUID     = 'R1-EMU'
DEVICE_EMU_UUID     = 'R1-EMU'
+5 −2
Original line number Original line Diff line number Diff line
@@ -14,7 +14,7 @@


from common.tools.object_factory.Context import json_context, json_context_id
from common.tools.object_factory.Context import json_context, json_context_id
from common.tools.object_factory.Device import json_device_emulated_packet_router_disabled, json_device_id
from common.tools.object_factory.Device import json_device_emulated_packet_router_disabled, json_device_id
from common.tools.object_factory.EndPoint import json_endpoints
from common.tools.object_factory.EndPoint import json_endpoint_descriptor, json_endpoints
from common.tools.object_factory.Link import compose_link
from common.tools.object_factory.Link import compose_link
from common.tools.object_factory.Topology import json_topology, json_topology_id
from common.tools.object_factory.Topology import json_topology, json_topology_id


@@ -22,7 +22,10 @@ def compose_device(
    device_uuid, endpoint_uuids, endpoint_type='copper', endpoint_topology_id=None, endpoint_sample_types=[]
    device_uuid, endpoint_uuids, endpoint_type='copper', endpoint_topology_id=None, endpoint_sample_types=[]
):
):
    device_id = json_device_id(device_uuid)
    device_id = json_device_id(device_uuid)
    endpoints = [(endpoint_uuid, endpoint_type, endpoint_sample_types) for endpoint_uuid in endpoint_uuids]
    endpoints = [
        json_endpoint_descriptor(endpoint_uuid, endpoint_type, endpoint_sample_types)
        for endpoint_uuid in endpoint_uuids
    ]
    endpoints = json_endpoints(device_id, endpoints, topology_id=endpoint_topology_id)
    endpoints = json_endpoints(device_id, endpoints, topology_id=endpoint_topology_id)
    device = json_device_emulated_packet_router_disabled(device_uuid, endpoints=endpoints)
    device = json_device_emulated_packet_router_disabled(device_uuid, endpoints=endpoints)
    return device_id, endpoints, device
    return device_id, endpoints, device
+2 −1
Original line number Original line Diff line number Diff line
@@ -14,7 +14,8 @@


from common.proto.kpi_sample_types_pb2 import KpiSampleType
from common.proto.kpi_sample_types_pb2 import KpiSampleType
from common.tools.object_factory.Device import (
from common.tools.object_factory.Device import (
    json_device_emulated_connect_rules, json_device_emulated_packet_router_disabled, json_endpoint_descriptor)
    json_device_emulated_connect_rules, json_device_emulated_packet_router_disabled)
from common.tools.object_factory.EndPoint import json_endpoint_descriptor


PACKET_PORT_SAMPLE_TYPES = [
PACKET_PORT_SAMPLE_TYPES = [
    KpiSampleType.KPISAMPLETYPE_PACKETS_TRANSMITTED,
    KpiSampleType.KPISAMPLETYPE_PACKETS_TRANSMITTED,
Loading