Commit 88805c73 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

NBI component - Debug API - Unitary Tests:

- Completed test descriptor debug_api_dummy.json
- Removed unneeded debug_api_dummy.txt file
- Corrected unitary test
parent 01bbcbfc
Loading
Loading
Loading
Loading
+207 −3
Original line number Diff line number Diff line
@@ -232,7 +232,211 @@
            ]
        }
    ],
    "services": [],
    "slices": [],
    "connections": []
    "services": [
        {
            "service_id" : {"context_id": {"context_uuid": {"uuid": "admin"}}, "service_uuid": {"uuid": "SVC:R1/200==R2/200"}},
            "name": "SVC:R1/200==R2/200", "service_type": 1, "service_status": {"service_status": 1},
            "service_endpoint_ids": [
                {
                    "device_id": {"device_uuid": {"uuid": "R1"}}, "endpoint_uuid": {"uuid": "200"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                },
                {
                    "device_id": {"device_uuid": {"uuid": "R2"}}, "endpoint_uuid": {"uuid": "200"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                }
            ],
            "service_constraints": [
                {"action": 1, "sla_capacity": {"capacity_gbps": 40.0}},
                {"action": 1, "sla_latency": {"e2e_latency_ms": 10.0}},
                {"action": 1, "sla_availability": {"num_disjoint_paths": 1, "all_active": true, "availability": 99.99}}
            ],
            "service_config": {"config_rules": [
                {"action": 1, "custom": {"resource_key": "/device[R1]/endpoint[200]/settings", "resource_value": {
                    "ipv4_address": "10.0.1.1", "ipv4_prefix": 24
                }}},
                {"action": 1, "custom": {"resource_key": "/device[R2]/endpoint[200]/settings", "resource_value": {
                    "ipv4_address": "10.0.2.1", "ipv4_prefix": 24
                }}}
            ]}
        },
        {
            "service_id" : {"context_id": {"context_uuid": {"uuid": "admin"}}, "service_uuid": {"uuid": "SVC:R1/200==R3/200"}},
            "name": "SVC:R1/200==R3/200", "service_type": 1, "service_status": {"service_status": 1},
            "service_endpoint_ids": [
                {
                    "device_id": {"device_uuid": {"uuid": "R1"}}, "endpoint_uuid": {"uuid": "200"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                },
                {
                    "device_id": {"device_uuid": {"uuid": "R3"}}, "endpoint_uuid": {"uuid": "200"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                }
            ],
            "service_constraints": [
                {"action": 1, "sla_capacity": {"capacity_gbps": 50.0}},
                {"action": 1, "sla_latency": {"e2e_latency_ms": 8.0}},
                {"action": 1, "sla_availability": {"num_disjoint_paths": 1, "all_active": true, "availability": 99.9}}
            ],
            "service_config": {"config_rules": [
                {"action": 1, "custom": {"resource_key": "/device[R1]/endpoint[200]/settings", "resource_value": {
                    "ipv4_address": "10.0.1.1", "ipv4_prefix": 24
                }}},
                {"action": 1, "custom": {"resource_key": "/device[R3]/endpoint[200]/settings", "resource_value": {
                    "ipv4_address": "10.0.3.1", "ipv4_prefix": 24
                }}}
            ]}
        },
        {
            "service_id" : {"context_id": {"context_uuid": {"uuid": "admin"}}, "service_uuid": {"uuid": "SVC:R2/200==R3/200"}},
            "name": "SVC:R2/200==R3/200", "service_type": 1, "service_status": {"service_status": 1},
            "service_endpoint_ids": [
                {
                    "device_id": {"device_uuid": {"uuid": "R2"}}, "endpoint_uuid": {"uuid": "200"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                },
                {
                    "device_id": {"device_uuid": {"uuid": "R3"}}, "endpoint_uuid": {"uuid": "200"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                }
            ],
            "service_constraints": [
                {"action": 1, "sla_capacity": {"capacity_gbps": 10.0}},
                {"action": 1, "sla_latency": {"e2e_latency_ms": 3.0}},
                {"action": 1, "sla_availability": {"num_disjoint_paths": 1, "all_active": true, "availability": 99.9999}}
            ],
            "service_config": {"config_rules": [
                {"action": 1, "custom": {"resource_key": "/device[R2]/endpoint[200]/settings", "resource_value": {
                    "ipv4_address": "10.0.2.1", "ipv4_prefix": 24
                }}},
                {"action": 1, "custom": {"resource_key": "/device[R3]/endpoint[200]/settings", "resource_value": {
                    "ipv4_address": "10.0.3.1", "ipv4_prefix": 24
                }}}
            ]}
        }
    ],
    "slices": [
        {
            "slice_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "slice_uuid": {"uuid": "SLC:R1-R2-R3"}},
            "name": "SLC:R1-R2-R3",
            "slice_endpoint_ids": [
                {
                    "device_id": {"device_uuid": {"uuid": "R1"}}, "endpoint_uuid": {"uuid": "200"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                },
                {
                    "device_id": {"device_uuid": {"uuid": "R2"}}, "endpoint_uuid": {"uuid": "200"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                },
                {
                    "device_id": {"device_uuid": {"uuid": "R3"}}, "endpoint_uuid": {"uuid": "200"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                }
            ],
            "slice_constraints": [
                {"action": 1, "sla_capacity": {"capacity_gbps": 40.0}},
                {"action": 1, "sla_latency": {"e2e_latency_ms": 10.0}},
                {"action": 1, "sla_availability": {"num_disjoint_paths": 1, "all_active": true, "availability": 99.99}}
            ],
            "slice_service_ids": [
                {"context_id": {"context_uuid": {"uuid": "admin"}}, "service_uuid": {"uuid": "SVC:R1/200==R2/200"}},
                {"context_id": {"context_uuid": {"uuid": "admin"}}, "service_uuid": {"uuid": "SVC:R1/200==R3/200"}},
                {"context_id": {"context_uuid": {"uuid": "admin"}}, "service_uuid": {"uuid": "SVC:R2/200==R3/200"}}
            ],
            "slice_subslice_ids": [],
            "slice_status": {"slice_status" : 1},
            "slice_config": {"config_rules": [
                {"action": 1, "custom": {"resource_key": "/device[R1]/endpoint[200]/settings", "resource_value": {
                    "ipv4_address": "10.0.1.1", "ipv4_prefix": 24
                }}},
                {"action": 1, "custom": {"resource_key": "/device[R2]/endpoint[200]/settings", "resource_value": {
                    "ipv4_address": "10.0.2.1", "ipv4_prefix": 24
                }}},
                {"action": 1, "custom": {"resource_key": "/device[R3]/endpoint[200]/settings", "resource_value": {
                    "ipv4_address": "10.0.3.1", "ipv4_prefix": 24
                }}}
            ]},
            "slice_owner": {"owner_uuid": {"uuid": "TFS"}, "owner_string": "TFS:SLC:R1-R2-R3"}
        }
    ],
    "connections": [
        {
            "connection_id": {"connection_uuid": {"uuid": "CON:R1/200==R2/200:1"}},
            "service_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "service_uuid": {"uuid": "SVC:R1/200==R2/200"}},
            "path_hops_endpoint_ids" : [
                {
                    "device_id": {"device_uuid": {"uuid": "R1"}}, "endpoint_uuid": {"uuid": "200"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                },
                {
                    "device_id": {"device_uuid": {"uuid": "R1"}}, "endpoint_uuid": {"uuid": "502"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                },
                {
                    "device_id": {"device_uuid": {"uuid": "R2"}}, "endpoint_uuid": {"uuid": "501"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                },
                {
                    "device_id": {"device_uuid": {"uuid": "R2"}}, "endpoint_uuid": {"uuid": "200"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                }
            ],
            "sub_service_ids": [],
            "settings": {
                "l3": {"src_ip_address": "10.0.1.10", "dst_ip_address": "10.0.2.10", "ttl": 20}
            }
        },
        {
            "connection_id": {"connection_uuid": {"uuid": "CON:R1/200==R3/200:1"}},
            "service_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "service_uuid": {"uuid": "SVC:R1/200==R3/200"}},
            "path_hops_endpoint_ids" : [
                {
                    "device_id": {"device_uuid": {"uuid": "R1"}}, "endpoint_uuid": {"uuid": "200"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                },
                {
                    "device_id": {"device_uuid": {"uuid": "R1"}}, "endpoint_uuid": {"uuid": "503"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                },
                {
                    "device_id": {"device_uuid": {"uuid": "R3"}}, "endpoint_uuid": {"uuid": "501"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                },
                {
                    "device_id": {"device_uuid": {"uuid": "R3"}}, "endpoint_uuid": {"uuid": "200"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                }
            ],
            "sub_service_ids": [],
            "settings": {
                "l3": {"src_ip_address": "10.0.1.10", "dst_ip_address": "10.0.3.10", "ttl": 20}
            }
        },
        {
            "connection_id": {"connection_uuid": {"uuid": "CON:R2/200==R3/200:1"}},
            "service_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "service_uuid": {"uuid": "SVC:R2/200==R3/200"}},
            "path_hops_endpoint_ids" : [
                {
                    "device_id": {"device_uuid": {"uuid": "R2"}}, "endpoint_uuid": {"uuid": "200"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                },
                {
                    "device_id": {"device_uuid": {"uuid": "R2"}}, "endpoint_uuid": {"uuid": "503"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                },
                {
                    "device_id": {"device_uuid": {"uuid": "R3"}}, "endpoint_uuid": {"uuid": "502"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                },
                {
                    "device_id": {"device_uuid": {"uuid": "R3"}}, "endpoint_uuid": {"uuid": "200"},
                    "topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
                }
            ],
            "sub_service_ids": [],
            "settings": {
                "l3": {"src_ip_address": "10.0.2.10", "dst_ip_address": "10.0.3.10", "ttl": 20}
            }
        }
    ]
}
+0 −6
Original line number Diff line number Diff line
add:
context_client.SetService(Service(**SERVICE_R1_R2))
context_client.SetService(Service(**SERVICE_R1_R3))
context_client.SetService(Service(**SERVICE_R2_R3))
context_client.SetSlice(Slice(**SLICE_R1_R3))
context_client.SetConnection(Connection(**CONNECTION_R1_R3))
+11 −7
Original line number Diff line number Diff line
@@ -20,16 +20,20 @@ from common.tools.descriptor.Loader import (
)
from common.tools.object_factory.Context import json_context_id
from common.type_checkers.Assertions import (
    validate_connection, validate_connection_ids, validate_connections, validate_context, validate_context_ids,
    validate_contexts, validate_device, validate_device_ids, validate_devices, validate_link, validate_link_ids,
    validate_links, validate_service, validate_service_ids, validate_services, validate_topologies, validate_topology,
    validate_topology_ids)
    validate_connection, validate_connection_ids, validate_connections,
    validate_context, validate_context_ids, validate_contexts,
    validate_device, validate_device_ids, validate_devices,
    validate_link, validate_link_ids, validate_links,
    validate_service, validate_service_ids, validate_services,
    validate_slice, validate_slice_ids, validate_slices,
    validate_topologies, validate_topology, validate_topology_ids
)
from context.client.ContextClient import ContextClient
from nbi.service.rest_server.RestServer import RestServer
from .PrepareTestScenario import ( # pylint: disable=unused-import
    # be careful, order of symbols is important here!
    do_rest_delete_request, do_rest_get_request, do_rest_post_request,
    mock_service, nbi_service_rest, osm_wim, context_client
    mock_service, nbi_service_rest, context_client,
    do_rest_get_request
)

LOGGER = logging.getLogger(__name__)
@@ -89,7 +93,7 @@ def test_rest_get_topology(nbi_service_rest : RestServer): # pylint: disable=red
    context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME)
    topology_uuid = urllib.parse.quote(DEFAULT_TOPOLOGY_NAME)
    reply = do_rest_get_request('/debug-api/context/{:s}/topology/{:s}'.format(context_uuid, topology_uuid))
    validate_topology(reply, num_devices=3, num_links=3)
    validate_topology(reply, num_devices=3, num_links=6)


# ----- Device ---------------------------------------------------------------------------------------------------------