Skip to content
Snippets Groups Projects
Commit 82ff7793 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

NBI component - Debug API

- Updated unitary tests
- Added test descriptor file
parent 9cc2fb42
No related branches found
No related tags found
2 merge requests!235Release TeraFlowSDN 3.0,!195Resolve "(CTTC) NBI unitary tests not running and/or not working"
{
"dummy_mode": true,
"contexts": [
{
"context_id": {"context_uuid": {"uuid": "admin"}},
"name": "admin",
"topology_ids": [
{"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
],
"service_ids": [
{"context_id": {"context_uuid": {"uuid": "admin"}}, "service_uuid": {"uuid": "admin"}},
{"context_id": {"context_uuid": {"uuid": "admin"}}, "service_uuid": {"uuid": "admin"}},
{"context_id": {"context_uuid": {"uuid": "admin"}}, "service_uuid": {"uuid": "admin"}}
],
"slice_ids": [
{"context_id": {"context_uuid": {"uuid": "admin"}}, "slice_uuid": {"uuid": "admin"}}
]
}
],
"topologies": [
{
"device_ids": [
{"device_uuid": {"uuid": "R1"}},
{"device_uuid": {"uuid": "R2"}},
{"device_uuid": {"uuid": "R3"}}
],
"link_ids": [
{"link_uuid": {"uuid": "R1/502==R2/501"}},
{"link_uuid": {"uuid": "R1/503==R3/501"}},
{"link_uuid": {"uuid": "R2/501==R1/502"}},
{"link_uuid": {"uuid": "R2/503==R3/502"}},
{"link_uuid": {"uuid": "R3/501==R1/503"}},
{"link_uuid": {"uuid": "R3/502==R2/503"}}
],
"name": "admin",
"topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
}
],
"devices": [
{
"device_id": {"device_uuid": {"uuid": "R1"}}, "name": "R1", "device_type": "emu-packet-router",
"device_drivers": [0], "device_operational_status": 2,
"device_endpoints": [
{"name": "200", "endpoint_type": "copper", "endpoint_id": {
"device_id": {"device_uuid": {"uuid": "R1"}}, "endpoint_uuid": {"uuid": "200"},
"topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
}},
{"name": "502", "endpoint_type": "optical", "endpoint_id": {
"device_id": {"device_uuid": {"uuid": "R1"}}, "endpoint_uuid": {"uuid": "502"},
"topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
}},
{"name": "503", "endpoint_type": "optical", "endpoint_id": {
"device_id": {"device_uuid": {"uuid": "R1"}}, "endpoint_uuid": {"uuid": "503"},
"topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
}}
],
"device_config": {"config_rules": [
{"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}},
{"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": 0}},
{"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [
{"uuid": "200", "name": "200", "type": "copper"},
{"uuid": "502", "name": "502", "type": "optical"},
{"uuid": "503", "name": "503", "type": "optical"}
]}}},
{"action": 1, "custom": {"resource_key": "/endpoints/endpoint[200]", "resource_value": {
"uuid": "200", "name": "200", "type": "copper"
}}},
{"action": 1, "custom": {"resource_key": "/endpoints/endpoint[502]", "resource_value": {
"uuid": "502", "name": "502", "type": "optical"
}}},
{"action": 1, "custom": {"resource_key": "/endpoints/endpoint[503]", "resource_value": {
"uuid": "503", "name": "503", "type": "optical"
}}}
]}
},
{
"device_id": {"device_uuid": {"uuid": "R2"}}, "name": "R2", "device_type": "emu-packet-router",
"device_drivers": [0], "device_operational_status": 2,
"device_endpoints": [
{"name": "200", "endpoint_type": "copper", "endpoint_id": {
"device_id": {"device_uuid": {"uuid": "R2"}}, "endpoint_uuid": {"uuid": "200"},
"topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
}},
{"name": "501", "endpoint_type": "optical", "endpoint_id": {
"device_id": {"device_uuid": {"uuid": "R2"}}, "endpoint_uuid": {"uuid": "501"},
"topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
}},
{"name": "503", "endpoint_type": "optical", "endpoint_id": {
"device_id": {"device_uuid": {"uuid": "R2"}}, "endpoint_uuid": {"uuid": "503"},
"topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
}}
],
"device_config": {"config_rules": [
{"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}},
{"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": 0}},
{"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [
{"uuid": "200", "name": "200", "type": "copper"},
{"uuid": "501", "name": "501", "type": "optical"},
{"uuid": "503", "name": "503", "type": "optical"}
]}}},
{"action": 1, "custom": {"resource_key": "/endpoints/endpoint[200]", "resource_value": {
"uuid": "200", "name": "200", "type": "copper"
}}},
{"action": 1, "custom": {"resource_key": "/endpoints/endpoint[501]", "resource_value": {
"uuid": "501", "name": "501", "type": "optical"
}}},
{"action": 1, "custom": {"resource_key": "/endpoints/endpoint[503]", "resource_value": {
"uuid": "503", "name": "503", "type": "optical"
}}}
]}
},
{
"device_id": {"device_uuid": {"uuid": "R3"}}, "name": "R3", "device_type": "emu-packet-router",
"device_drivers": [0], "device_operational_status": 2,
"device_endpoints": [
{"name": "200", "endpoint_type": "copper", "endpoint_id": {
"device_id": {"device_uuid": {"uuid": "R3"}}, "endpoint_uuid": {"uuid": "200"},
"topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
}},
{"name": "502", "endpoint_type": "optical", "endpoint_id": {
"device_id": {"device_uuid": {"uuid": "R3"}}, "endpoint_uuid": {"uuid": "502"},
"topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
}},
{"name": "503", "endpoint_type": "optical", "endpoint_id": {
"device_id": {"device_uuid": {"uuid": "R3"}}, "endpoint_uuid": {"uuid": "503"},
"topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
}}
],
"device_config": {"config_rules": [
{"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}},
{"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": 0}},
{"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"endpoints": [
{"uuid": "200", "name": "200", "type": "copper"},
{"uuid": "502", "name": "502", "type": "optical"},
{"uuid": "503", "name": "503", "type": "optical"}
]}}},
{"action": 1, "custom": {"resource_key": "/endpoints/endpoint[200]", "resource_value": {
"uuid": "200", "name": "200", "type": "copper"
}}},
{"action": 1, "custom": {"resource_key": "/endpoints/endpoint[502]", "resource_value": {
"uuid": "502", "name": "502", "type": "optical"
}}},
{"action": 1, "custom": {"resource_key": "/endpoints/endpoint[503]", "resource_value": {
"uuid": "503", "name": "503", "type": "optical"
}}}
]}
}
],
"links": [
{
"link_id": {"link_uuid": {"uuid": "R1/502==R2/501"}}, "name": "R1/502==R2/501",
"attributes": {"total_capacity_gbps": 10.0, "used_capacity_gbps": 0.0},
"link_endpoint_ids": [
{
"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"}}
}
]
},
{
"link_id": {"link_uuid": {"uuid": "R1/503==R3/501"}}, "name": "R1/503==R3/501",
"attributes": {"total_capacity_gbps": 10.0, "used_capacity_gbps": 0.0},
"link_endpoint_ids": [
{
"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"}}
}
]
},
{
"link_id": {"link_uuid": {"uuid": "R2/501==R1/502"}}, "name": "R2/501==R1/502",
"attributes": {"total_capacity_gbps": 10.0, "used_capacity_gbps": 0.0},
"link_endpoint_ids": [
{
"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": "R1"}}, "endpoint_uuid": {"uuid": "502"},
"topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
}
]
},
{
"link_id": {"link_uuid": {"uuid": "R2/503==R3/502"}}, "name": "R2/503==R3/502",
"attributes": {"total_capacity_gbps": 10.0, "used_capacity_gbps": 0.0},
"link_endpoint_ids": [
{
"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"}}
}
]
},
{
"link_id": {"link_uuid": {"uuid": "R3/501==R1/503"}}, "name": "R3/501==R1/503",
"attributes": {"total_capacity_gbps": 10.0, "used_capacity_gbps": 0.0},
"link_endpoint_ids": [
{
"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": "R1"}}, "endpoint_uuid": {"uuid": "503"},
"topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
}
]
},
{
"link_id": {"link_uuid": {"uuid": "R3/502==R2/503"}}, "name": "R3/502==R2/503",
"attributes": {"total_capacity_gbps": 10.0, "used_capacity_gbps": 0.0},
"link_endpoint_ids": [
{
"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": "R2"}}, "endpoint_uuid": {"uuid": "503"},
"topology_id": {"context_id": {"context_uuid": {"uuid": "admin"}}, "topology_uuid": {"uuid": "admin"}}
}
]
}
],
"services": [],
"slices": [],
"connections": []
}
...@@ -12,211 +12,202 @@ ...@@ -12,211 +12,202 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import logging, os, pytest, time, urllib import logging, urllib
import pprint from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME
from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME, ServiceNameEnum from common.proto.context_pb2 import ContextId
from common.proto.context_pb2 import Connection, Context, Device, Link, Service, Slice, Topology from common.tools.descriptor.Loader import (
from common.proto.policy_pb2 import PolicyRuleIdList, PolicyRuleId, PolicyRuleList, PolicyRule DescriptorLoader, check_descriptor_load_results, validate_empty_scenario
from common.Settings import (
ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, ENVVAR_SUFIX_SERVICE_PORT_HTTP, get_env_var_name,
get_service_port_grpc, get_service_port_http
) )
from common.tools.object_factory.Context import json_context_id
from common.type_checkers.Assertions import ( from common.type_checkers.Assertions import (
validate_connection, validate_connection_ids, validate_connections, validate_context, validate_context_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_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_links, validate_service, validate_service_ids, validate_services, validate_topologies, validate_topology,
validate_topology_ids) validate_topology_ids)
from nbi.tests.PrepareTestScenario import do_rest_get_request, context_client, nbi_service_rest from context.client.ContextClient import ContextClient
from ..service.rest_server.RestServer import RestServer from nbi.service.rest_server.RestServer import RestServer
from .MockService_Dependencies import MockService_Dependencies from .PrepareTestScenario import ( # pylint: disable=unused-import
from context.tests.Objects import ( # be careful, order of symbols is important here!
CONNECTION_R1_R3, CONTEXT, DEVICE_R1, DEVICE_R2, DEVICE_R3, LINK_R1_R2, LINK_R1_R3, LINK_R2_R3, SERVICE_R1_R2, SERVICE_R1_R3, do_rest_delete_request, do_rest_get_request, do_rest_post_request,
SERVICE_R2_R3, SLICE_R1_R3, TOPOLOGY mock_service, nbi_service_rest, osm_wim, context_client
) )
from ..service.rest_server.nbi_plugins.debug_api import URL_PREFIX
# from context.client.ContextClient import ContextClient
# from ..service.rest_server.nbi_plugins.debug_api import RESOURCES
# connection_r1_r3_uuid = ''
# policyrule_uuid = ''
# slice_r1_r3_uuid = ''
# service_r1_r2_uuid = ''
# service_r1_r3_uuid = ''
# link_r1_r2_uuid = ''
# device_r1_uuid = ''
def pytest_namespace():
return {
'connection_r1_r3_uuid' : '',
'policyrule_uuid' : '',
'slice_r1_r3_uuid' : '',
'service_r1_r2_uuid' : '',
'service_r1_r3_uuid' : '',
'link_r1_r2_uuid' : '',
'device_r1_uuid' : '',
}
@pytest.fixture(scope='session')
def mock_service():
_service = MockService_Dependencies(MOCKSERVICE_PORT)
_service.configure_env_vars()
_service.start()
yield _service
_service.stop()
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG) LOGGER.setLevel(logging.DEBUG)
LOCAL_HOST = '127.0.0.1' DESCRIPTOR_FILE = 'nbi/tests/data/debug_api_dummy.json'
GRPC_PORT = 10000 + int(get_service_port_grpc(ServiceNameEnum.CONTEXT)) # avoid privileged ports
HTTP_PORT = 10000 + int(get_service_port_http(ServiceNameEnum.CONTEXT)) # avoid privileged ports JSON_ADMIN_CONTEXT_ID = json_context_id(DEFAULT_CONTEXT_NAME)
ADMIN_CONTEXT_ID = ContextId(**JSON_ADMIN_CONTEXT_ID)
MOCKSERVICE_PORT = 10000
DEVICE_SERVICE_PORT = MOCKSERVICE_PORT + get_service_port_grpc(ServiceNameEnum.DEVICE) # avoid privileged ports
# ----- Prepare Environment --------------------------------------------------------------------------------------------
os.environ[get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_HOST )] = str(LOCAL_HOST)
os.environ[get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(GRPC_PORT) def test_prepare_environment(context_client : ContextClient) -> None: # pylint: disable=redefined-outer-name
os.environ[get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_HTTP)] = str(HTTP_PORT) validate_empty_scenario(context_client)
descriptor_loader = DescriptorLoader(descriptors_file=DESCRIPTOR_FILE, context_client=context_client)
def test_populate_database(context_client): results = descriptor_loader.process()
set_context_response = context_client.SetContext(Context(**CONTEXT)) check_descriptor_load_results(results, descriptor_loader)
pytest.connection_r1_r3_uuid = set_context_response.context_uuid.uuid descriptor_loader.validate()
context_client.SetTopology(Topology(**TOPOLOGY))
set_device_r1_response = context_client.SetDevice(Device(**DEVICE_R1)) # Verify the scenario has no services/slices
pytest.device_r1_uuid = set_device_r1_response.device_uuid.uuid response = context_client.GetContext(ADMIN_CONTEXT_ID)
context_client.SetDevice(Device(**DEVICE_R2)) assert len(response.topology_ids) == 1
context_client.SetDevice(Device(**DEVICE_R3)) assert len(response.service_ids ) == 0
set_link_r1_r2_response = context_client.SetLink(Link(**LINK_R1_R2)) assert len(response.slice_ids ) == 0
pytest.link_r1_r2_uuid = set_link_r1_r2_response.link_uuid.uuid
context_client.SetLink(Link(**LINK_R1_R3))
context_client.SetLink(Link(**LINK_R2_R3)) # ----- Context --------------------------------------------------------------------------------------------------------
set_service_r1_r2_response = context_client.SetService(Service(**SERVICE_R1_R2))
pytest.service_r1_r2_uuid = set_service_r1_r2_response.service_uuid.uuid def test_rest_get_context_ids(nbi_service_rest: RestServer): # pylint: disable=redefined-outer-name, unused-argument
set_service_r1_r3_response = context_client.SetService(Service(**SERVICE_R1_R3)) reply = do_rest_get_request('/debug-api/context_ids')
pytest.service_r1_r3_uuid = set_service_r1_r3_response.service_uuid.uuid
context_client.SetService(Service(**SERVICE_R2_R3))
set_slice_response = context_client.SetSlice(Slice(**SLICE_R1_R3))
pytest.slice_r1_r3_uuid = set_slice_response.slice_uuid.uuid
context_client.SetConnection(Connection(**CONNECTION_R1_R3))
def test_rest_get_context_ids(nbi_service_rest: RestServer): # pylint: disable=redefined-outer-name
reply = do_rest_get_request(URL_PREFIX + '/context_ids')
validate_context_ids(reply) validate_context_ids(reply)
def test_rest_get_contexts(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name def test_rest_get_contexts(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
reply = do_rest_get_request(URL_PREFIX + '/contexts') reply = do_rest_get_request('/debug-api/contexts')
# LOGGER.warning(reply['contexts'][0]['service_ids'][0])
# LOGGER.warning(reply['contexts'][0]['service_ids'][0].keys())
pprint.pprint(reply)
validate_contexts(reply) validate_contexts(reply)
# def test_rest_get_context(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name def test_rest_get_context(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
# context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME) context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME)
# reply = do_rest_get_request(URL_PREFIX + '/context/{:s}'.format(context_uuid)) reply = do_rest_get_request('/debug-api/context/{:s}'.format(context_uuid))
# validate_context(reply) validate_context(reply)
# def test_rest_get_topology_ids(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name
# context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME) # ----- Topology -------------------------------------------------------------------------------------------------------
# reply = do_rest_get_request(URL_PREFIX + '/context/{:s}/topology_ids'.format(context_uuid))
# validate_topology_ids(reply) def test_rest_get_topology_ids(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME)
# def test_rest_get_topologies(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name reply = do_rest_get_request('/debug-api/context/{:s}/topology_ids'.format(context_uuid))
# context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME) validate_topology_ids(reply)
# reply = do_rest_get_request(URL_PREFIX + '/context/{:s}/topologies'.format(context_uuid))
# validate_topologies(reply) def test_rest_get_topologies(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME)
# def test_rest_get_topology(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name reply = do_rest_get_request('/debug-api/context/{:s}/topologies'.format(context_uuid))
# context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME) validate_topologies(reply)
# topology_uuid = urllib.parse.quote(DEFAULT_TOPOLOGY_NAME)
# reply = do_rest_get_request(URL_PREFIX + '/context/{:s}/topology/{:s}'.format(context_uuid, topology_uuid)) def test_rest_get_topology(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
# validate_topology(reply, num_devices=3, num_links=3) context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME)
topology_uuid = urllib.parse.quote(DEFAULT_TOPOLOGY_NAME)
# def test_rest_get_service_ids(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name reply = do_rest_get_request('/debug-api/context/{:s}/topology/{:s}'.format(context_uuid, topology_uuid))
# context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME) validate_topology(reply, num_devices=3, num_links=3)
# reply = do_rest_get_request(URL_PREFIX + '/context/{:s}/service_ids'.format(context_uuid))
# validate_service_ids(reply)
# ----- Device ---------------------------------------------------------------------------------------------------------
# def test_rest_get_services(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name
# context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME) def test_rest_get_device_ids(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
# reply = do_rest_get_request(URL_PREFIX + '/context/{:s}/services'.format(context_uuid)) reply = do_rest_get_request('/debug-api/device_ids')
# validate_services(reply) validate_device_ids(reply)
# def test_rest_get_service(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name def test_rest_get_devices(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
# context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME) reply = do_rest_get_request('/debug-api/devices')
# service_uuid = urllib.parse.quote(service_r1_r2_uuid, safe='') validate_devices(reply)
# reply = do_rest_get_request(URL_PREFIX + '/context/{:s}/service/{:s}'.format(context_uuid, service_uuid))
# validate_service(reply) def test_rest_get_device(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
device_uuid = urllib.parse.quote('R1', safe='')
# def test_rest_get_slice_ids(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name reply = do_rest_get_request('/debug-api/device/{:s}'.format(device_uuid))
# context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME) validate_device(reply)
# reply = do_rest_get_request(URL_PREFIX + '/context/{:s}/slice_ids'.format(context_uuid))
# #validate_slice_ids(reply)
# ----- Link -----------------------------------------------------------------------------------------------------------
# def test_rest_get_slices(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name
# context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME) def test_rest_get_link_ids(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
# reply = do_rest_get_request(URL_PREFIX + '/context/{:s}/slices'.format(context_uuid)) reply = do_rest_get_request('/debug-api/link_ids')
# #validate_slices(reply) validate_link_ids(reply)
# def test_rest_get_slice(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name def test_rest_get_links(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
# context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME) reply = do_rest_get_request('/debug-api/links')
# slice_uuid = urllib.parse.quote(slice_r1_r3_uuid, safe='') validate_links(reply)
# reply = do_rest_get_request(URL_PREFIX + '/context/{:s}/slice/{:s}'.format(context_uuid, slice_uuid))
# #validate_slice(reply) def test_rest_get_link(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
link_uuid = urllib.parse.quote('R1/502==R2/501', safe='')
# def test_rest_get_device_ids(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name reply = do_rest_get_request('/debug-api/link/{:s}'.format(link_uuid))
# reply = do_rest_get_request(URL_PREFIX + '/device_ids') validate_link(reply)
# validate_device_ids(reply)
# def test_rest_get_devices(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name # ----- Service --------------------------------------------------------------------------------------------------------
# reply = do_rest_get_request(URL_PREFIX + '/devices')
# validate_devices(reply) def test_rest_get_service_ids(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME)
# def test_rest_get_device(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name reply = do_rest_get_request('/debug-api/context/{:s}/service_ids'.format(context_uuid))
# device_uuid = urllib.parse.quote(device_r1_uuid, safe='') validate_service_ids(reply)
# reply = do_rest_get_request(URL_PREFIX + '/device/{:s}'.format(device_uuid))
# validate_device(reply) def test_rest_get_services(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME)
# def test_rest_get_link_ids(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name reply = do_rest_get_request('/debug-api/context/{:s}/services'.format(context_uuid))
# reply = do_rest_get_request(URL_PREFIX + '/link_ids') validate_services(reply)
# validate_link_ids(reply)
def test_rest_get_service(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
# def test_rest_get_links(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME)
# reply = do_rest_get_request(URL_PREFIX + '/links') service_uuid = urllib.parse.quote('SVC:R1/200==R2/200', safe='')
# validate_links(reply) reply = do_rest_get_request('/debug-api/context/{:s}/service/{:s}'.format(context_uuid, service_uuid))
validate_service(reply)
# def test_rest_get_link(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name
# link_uuid = urllib.parse.quote(link_r1_r2_uuid, safe='')
# reply = do_rest_get_request(URL_PREFIX + '/link/{:s}'.format(link_uuid)) # ----- Slice ----------------------------------------------------------------------------------------------------------
# validate_link(reply)
def test_rest_get_slice_ids(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
# def test_rest_get_connection_ids(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME)
# context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME) reply = do_rest_get_request('/debug-api/context/{:s}/slice_ids'.format(context_uuid))
# service_uuid = urllib.parse.quote(service_r1_r3_uuid, safe='') validate_slice_ids(reply)
# reply = do_rest_get_request(URL_PREFIX + '/context/{:s}/service/{:s}/connection_ids'.format(context_uuid, service_uuid))
# validate_connection_ids(reply) def test_rest_get_slices(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME)
# def test_rest_get_connections(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name reply = do_rest_get_request('/debug-api/context/{:s}/slices'.format(context_uuid))
# context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME) validate_slices(reply)
# service_uuid = urllib.parse.quote(service_r1_r3_uuid, safe='')
# reply = do_rest_get_request(URL_PREFIX + '/context/{:s}/service/{:s}/connections'.format(context_uuid, service_uuid)) def test_rest_get_slice(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
# validate_connections(reply) context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME)
slice_uuid = urllib.parse.quote('SLC:R1-R2-R3', safe='')
# def test_rest_get_connection(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name reply = do_rest_get_request('/debug-api/context/{:s}/slice/{:s}'.format(context_uuid, slice_uuid))
# connection_uuid = urllib.parse.quote(connection_r1_r3_uuid, safe='') validate_slice(reply)
# reply = do_rest_get_request(URL_PREFIX + '/connection/{:s}'.format(connection_uuid))
# validate_connection(reply)
# ----- Connection -----------------------------------------------------------------------------------------------------
# def test_rest_get_policyrule_ids(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name
# reply = do_rest_get_request(URL_PREFIX + '/policyrule_ids') def test_rest_get_connection_ids(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
# #validate_policyrule_ids(reply) context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME)
service_uuid = urllib.parse.quote('SVC:R1/200==R2/200', safe='')
# def test_rest_get_policyrules(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name reply = do_rest_get_request('/debug-api/context/{:s}/service/{:s}/connection_ids'.format(context_uuid, service_uuid))
# reply = do_rest_get_request(URL_PREFIX + '/policyrules') validate_connection_ids(reply)
# #validate_policyrules(reply)
def test_rest_get_connections(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
# def test_rest_get_policyrule(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name context_uuid = urllib.parse.quote(DEFAULT_CONTEXT_NAME)
# policyrule_uuid_quoted = urllib.parse.quote(policyrule_uuid, safe='') service_uuid = urllib.parse.quote('SVC:R1/200==R2/200', safe='')
# reply = do_rest_get_request(URL_PREFIX + '/policyrule/{:s}'.format(policyrule_uuid_quoted)) reply = do_rest_get_request('/debug-api/context/{:s}/service/{:s}/connections'.format(context_uuid, service_uuid))
# #validate_policyrule(reply) validate_connections(reply)
def test_rest_get_connection(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
connection_uuid = urllib.parse.quote('CON:R1/200==R2/200:1', safe='')
reply = do_rest_get_request('/debug-api/connection/{:s}'.format(connection_uuid))
validate_connection(reply)
# ----- Policy ---------------------------------------------------------------------------------------------------------
#def test_rest_get_policyrule_ids(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
# reply = do_rest_get_request('/debug-api/policyrule_ids')
# validate_policyrule_ids(reply)
#def test_rest_get_policyrules(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
# reply = do_rest_get_request('/debug-api/policyrules')
# validate_policyrules(reply)
#def test_rest_get_policyrule(nbi_service_rest : RestServer): # pylint: disable=redefined-outer-name, unused-argument
# policyrule_uuid_quoted = urllib.parse.quote(policyrule_uuid, safe='')
# reply = do_rest_get_request('/debug-api/policyrule/{:s}'.format(policyrule_uuid_quoted))
# validate_policyrule(reply)
# ----- Cleanup Environment --------------------------------------------------------------------------------------------
def test_cleanup_environment(context_client : ContextClient) -> None: # pylint: disable=redefined-outer-name
# Verify the scenario has no services/slices
response = context_client.GetContext(ADMIN_CONTEXT_ID)
assert len(response.topology_ids) == 1
assert len(response.service_ids ) == 0
assert len(response.slice_ids ) == 0
# Load descriptors and validate the base scenario
descriptor_loader = DescriptorLoader(descriptors_file=DESCRIPTOR_FILE, context_client=context_client)
descriptor_loader.validate()
descriptor_loader.unload()
validate_empty_scenario(context_client)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment