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

OFC'22 functional test:

- corrected service creation/removal checks
- cleaned up code
- cleaned up scripts
parent 4e3700b6
No related branches found
No related tags found
2 merge requests!54Release 2.0.0,!48Fixes for OFC'22 and ECOC'22 tests
Showing with 205 additions and 92 deletions
# Set the URL of your local Docker registry where the images will be uploaded to. #!/bin/bash
export TFS_REGISTRY_IMAGE="http://localhost:32000/tfs/" # Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----- TeraFlowSDN ------------------------------------------------------------
# Set the URL of the internal MicroK8s Docker registry where the images will be uploaded to.
export TFS_REGISTRY_IMAGES="http://localhost:32000/tfs/"
# Set the list of components, separated by spaces, you want to build images for, and deploy. # Set the list of components, separated by spaces, you want to build images for, and deploy.
# Supported components are: #export TFS_COMPONENTS="context device automation monitoring pathcomp service slice compute webui load_generator"
# context device automation policy service compute monitoring webui
# interdomain slice pathcomp dlt
# dbscanserving opticalattackmitigator opticalattackdetector
# l3_attackmitigator l3_centralizedattackdetector l3_distributedattackdetector
export TFS_COMPONENTS="context device automation monitoring pathcomp service slice compute webui" export TFS_COMPONENTS="context device automation monitoring pathcomp service slice compute webui"
# Set the tag you want to use for your images. # Set the tag you want to use for your images.
export TFS_IMAGE_TAG="dev" export TFS_IMAGE_TAG="dev"
# Set the name of the Kubernetes namespace to deploy to. # Set the name of the Kubernetes namespace to deploy TFS to.
export TFS_K8S_NAMESPACE="tfs" export TFS_K8S_NAMESPACE="tfs"
# Set additional manifest files to be applied after the deployment # Set additional manifest files to be applied after the deployment
...@@ -21,6 +35,60 @@ export TFS_EXTRA_MANIFESTS="manifests/nginx_ingress_http.yaml" ...@@ -21,6 +35,60 @@ export TFS_EXTRA_MANIFESTS="manifests/nginx_ingress_http.yaml"
# Set the new Grafana admin password # Set the new Grafana admin password
export TFS_GRAFANA_PASSWORD="admin123+" export TFS_GRAFANA_PASSWORD="admin123+"
# If not already set, disable skip-build flag. # Disable skip-build flag to rebuild the Docker images.
# If TFS_SKIP_BUILD is "YES", the containers are not rebuilt-retagged-repushed and existing ones are used. export TFS_SKIP_BUILD=""
export TFS_SKIP_BUILD=${TFS_SKIP_BUILD:-""}
# ----- CockroachDB ------------------------------------------------------------
# Set the namespace where CockroackDB will be deployed.
export CRDB_NAMESPACE="crdb"
# Set the database username to be used by Context.
export CRDB_USERNAME="tfs"
# Set the database user's password to be used by Context.
export CRDB_PASSWORD="tfs123"
# Set the database name to be used by Context.
export CRDB_DATABASE="tfs"
# Set CockroachDB installation mode to 'single'. This option is convenient for development and testing.
# See ./deploy/all.sh or ./deploy/crdb.sh for additional details
export CRDB_DEPLOY_MODE="single"
# Disable flag for dropping database, if exists.
export CRDB_DROP_DATABASE_IF_EXISTS="YES"
# Disable flag for re-deploying CockroachDB from scratch.
export CRDB_REDEPLOY=""
# ----- NATS -------------------------------------------------------------------
# Set the namespace where NATS will be deployed.
export NATS_NAMESPACE="nats"
# Disable flag for re-deploying NATS from scratch.
export NATS_REDEPLOY=""
# ----- QuestDB ----------------------------------------------------------------
# If not already set, set the namespace where QuestDB will be deployed.
export QDB_NAMESPACE=${QDB_NAMESPACE:-"qdb"}
# If not already set, set the database username to be used by Monitoring.
export QDB_USERNAME=${QDB_USERNAME:-"admin"}
# If not already set, set the database user's password to be used by Monitoring.
export QDB_PASSWORD=${QDB_PASSWORD:-"quest"}
# If not already set, set the table name to be used by Monitoring.
export QDB_TABLE=${QDB_TABLE:-"tfs_monitoring"}
## If not already set, disable flag for dropping table if exists.
#export QDB_DROP_TABLE_IF_EXISTS=${QDB_DROP_TABLE_IF_EXISTS:-""}
# If not already set, disable flag for re-deploying QuestDB from scratch.
export QDB_REDEPLOY=${QDB_REDEPLOY:-"YES"}
#!/bin/bash
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
source ofc22/deploy_specs.sh
./deploy/all.sh
source tfs_runtime_env_vars.sh
...@@ -14,4 +14,4 @@ ...@@ -14,4 +14,4 @@
# limitations under the License. # limitations under the License.
source tfs_runtime_env_vars.sh source tfs_runtime_env_vars.sh
pytest --verbose --log-level=INFO -o log_cli=true -o log_cli_level=INFO src/tests/ofc22/tests/test_functional_bootstrap.py pytest --verbose --log-level=INFO src/tests/ofc22/tests/test_functional_bootstrap.py
...@@ -14,4 +14,4 @@ ...@@ -14,4 +14,4 @@
# limitations under the License. # limitations under the License.
source tfs_runtime_env_vars.sh source tfs_runtime_env_vars.sh
pytest --verbose --log-level=INFO -o log_cli=true -o log_cli_level=INFO src/tests/ofc22/tests/test_functional_create_service.py pytest --verbose --log-level=INFO src/tests/ofc22/tests/test_functional_create_service.py
...@@ -14,4 +14,4 @@ ...@@ -14,4 +14,4 @@
# limitations under the License. # limitations under the License.
source tfs_runtime_env_vars.sh source tfs_runtime_env_vars.sh
pytest --verbose --log-level=INFO -o log_cli=true -o log_cli_level=INFO src/tests/ofc22/tests/test_functional_delete_service.py pytest --verbose --log-level=INFO src/tests/ofc22/tests/test_functional_delete_service.py
...@@ -14,4 +14,4 @@ ...@@ -14,4 +14,4 @@
# limitations under the License. # limitations under the License.
source tfs_runtime_env_vars.sh source tfs_runtime_env_vars.sh
pytest --verbose --log-level=INFO -o log_cli=true -o log_cli_level=INFO src/tests/ofc22/tests/test_functional_cleanup.py pytest --verbose --log-level=INFO src/tests/ofc22/tests/test_functional_cleanup.py
...@@ -13,32 +13,9 @@ ...@@ -13,32 +13,9 @@
# 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.
PROJECTDIR=`pwd`
RCFILE=$PROJECTDIR/coverage/.coveragerc
COVERAGEFILE=$PROJECTDIR/coverage/.coverage
# Configure the correct folder on the .coveragerc file
cat $PROJECTDIR/coverage/.coveragerc.template | sed s+~/teraflow/controller+$PROJECTDIR/src+g > $RCFILE
# Destroy old coverage file
rm -f $COVERAGEFILE
source tfs_runtime_env_vars.sh
# Force a flush of Context database
kubectl --namespace $TFS_K8S_NAMESPACE exec -it deployment/contextservice --container redis -- redis-cli FLUSHALL
# Run functional tests # Run functional tests
pytest --log-level=INFO --verbose \ source tfs_runtime_env_vars.sh
src/tests/ofc22/tests/test_functional_bootstrap.py pytest --verbose --log-level=INFO src/tests/ofc22/tests/test_functional_bootstrap.py
pytest --verbose --log-level=INFO src/tests/ofc22/tests/test_functional_create_service.py
pytest --log-level=INFO --verbose \ pytest --verbose --log-level=INFO src/tests/ofc22/tests/test_functional_delete_service.py
src/tests/ofc22/tests/test_functional_create_service.py pytest --verbose --log-level=INFO src/tests/ofc22/tests/test_functional_cleanup.py
pytest --log-level=INFO --verbose \
src/tests/ofc22/tests/test_functional_delete_service.py
pytest --log-level=INFO --verbose \
src/tests/ofc22/tests/test_functional_cleanup.py
...@@ -18,17 +18,21 @@ from tests.tools.mock_osm.Tools import connection_point, wim_mapping ...@@ -18,17 +18,21 @@ from tests.tools.mock_osm.Tools import connection_point, wim_mapping
# ----- WIM Service Settings ------------------------------------------------------------------------------------------- # ----- WIM Service Settings -------------------------------------------------------------------------------------------
WIM_DC1_SITE_ID = '1' SITE_ID_DC1 = '1'
WIM_DC1_DEVICE_ID = json_device_id('R1-EMU') DEV_ID_DC1 = json_device_id('R1-EMU')
WIM_DC1_ENDPOINT_ID = json_endpoint_id(WIM_DC1_DEVICE_ID, '13/1/2') EP_ID_DC1 = json_endpoint_id(DEV_ID_DC1, '13/1/2')
WIM_DC2_SITE_ID = '2' SITE_ID_DC2 = '2'
WIM_DC2_DEVICE_ID = json_device_id('R3-EMU') DEV_ID_DC2 = json_device_id('R3-EMU')
WIM_DC2_ENDPOINT_ID = json_endpoint_id(WIM_DC2_DEVICE_ID, '13/1/2') EP_ID_DC2 = json_endpoint_id(DEV_ID_DC2, '13/1/2')
WIM_SEP_DC1, WIM_MAP_DC1 = wim_mapping(WIM_DC1_SITE_ID, WIM_DC1_ENDPOINT_ID) WIM_SEP_DC1, WIM_MAP_DC1 = wim_mapping(SITE_ID_DC1, EP_ID_DC1)
WIM_SEP_DC2, WIM_MAP_DC2 = wim_mapping(WIM_DC2_SITE_ID, WIM_DC2_ENDPOINT_ID) WIM_SEP_DC2, WIM_MAP_DC2 = wim_mapping(SITE_ID_DC2, EP_ID_DC2)
WIM_MAPPING = [WIM_MAP_DC1, WIM_MAP_DC2]
WIM_MAPPING = [
WIM_MAP_DC1,
WIM_MAP_DC2,
]
WIM_SRV_VLAN_ID = 300 WIM_SRV_VLAN_ID = 300
WIM_SERVICE_TYPE = 'ELINE' WIM_SERVICE_TYPE = 'ELINE'
......
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
# limitations under the License. # limitations under the License.
import logging, time import logging, time
from common.Constants import DEFAULT_CONTEXT_NAME
from common.proto.context_pb2 import ContextId, Empty from common.proto.context_pb2 import ContextId, Empty
from common.proto.monitoring_pb2 import KpiDescriptorList from common.proto.monitoring_pb2 import KpiDescriptorList
from common.tests.LoadScenario import load_scenario_from_descriptor from common.tests.LoadScenario import load_scenario_from_descriptor
from common.tools.grpc.Tools import grpc_message_to_json_string
from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Context import json_context_id
from context.client.ContextClient import ContextClient from context.client.ContextClient import ContextClient
from device.client.DeviceClient import DeviceClient from device.client.DeviceClient import DeviceClient
...@@ -27,6 +27,7 @@ LOGGER = logging.getLogger(__name__) ...@@ -27,6 +27,7 @@ LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG) LOGGER.setLevel(logging.DEBUG)
DESCRIPTOR_FILE = 'ofc22/descriptors_emulated.json' DESCRIPTOR_FILE = 'ofc22/descriptors_emulated.json'
ADMIN_CONTEXT_ID = ContextId(**json_context_id(DEFAULT_CONTEXT_NAME))
def test_scenario_bootstrap( def test_scenario_bootstrap(
context_client : ContextClient, # pylint: disable=redefined-outer-name context_client : ContextClient, # pylint: disable=redefined-outer-name
...@@ -66,6 +67,16 @@ def test_scenario_bootstrap( ...@@ -66,6 +67,16 @@ def test_scenario_bootstrap(
response = context_client.ListServices(ContextId(**json_context_id(context_uuid))) response = context_client.ListServices(ContextId(**json_context_id(context_uuid)))
assert len(response.services) == 0 assert len(response.services) == 0
for context_uuid, _ in descriptor_loader.num_slices.items():
response = context_client.ListSlices(ContextId(**json_context_id(context_uuid)))
assert len(response.slices) == 0
# This scenario assumes no services are created beforehand
response = context_client.GetContext(ADMIN_CONTEXT_ID)
assert len(response.service_ids) == 0
assert len(response.slice_ids) == 0
def test_scenario_kpis_created( def test_scenario_kpis_created(
context_client : ContextClient, # pylint: disable=redefined-outer-name context_client : ContextClient, # pylint: disable=redefined-outer-name
monitoring_client: MonitoringClient, # pylint: disable=redefined-outer-name monitoring_client: MonitoringClient, # pylint: disable=redefined-outer-name
......
...@@ -13,9 +13,10 @@ ...@@ -13,9 +13,10 @@
# limitations under the License. # limitations under the License.
import logging import logging
from common.Constants import DEFAULT_CONTEXT_NAME
from common.proto.context_pb2 import ContextId, DeviceId, Empty, LinkId, TopologyId
from common.tools.descriptor.Loader import DescriptorLoader from common.tools.descriptor.Loader import DescriptorLoader
from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Context import json_context_id
from common.proto.context_pb2 import ContextId, DeviceId, Empty, LinkId, TopologyId
from context.client.ContextClient import ContextClient from context.client.ContextClient import ContextClient
from device.client.DeviceClient import DeviceClient from device.client.DeviceClient import DeviceClient
from tests.Fixtures import context_client, device_client # pylint: disable=unused-import from tests.Fixtures import context_client, device_client # pylint: disable=unused-import
...@@ -24,7 +25,7 @@ LOGGER = logging.getLogger(__name__) ...@@ -24,7 +25,7 @@ LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG) LOGGER.setLevel(logging.DEBUG)
DESCRIPTOR_FILE = 'ofc22/descriptors_emulated.json' DESCRIPTOR_FILE = 'ofc22/descriptors_emulated.json'
ADMIN_CONTEXT_ID = ContextId(**json_context_id(DEFAULT_CONTEXT_NAME))
def test_services_removed( def test_services_removed(
context_client : ContextClient, # pylint: disable=redefined-outer-name context_client : ContextClient, # pylint: disable=redefined-outer-name
...@@ -53,6 +54,15 @@ def test_services_removed( ...@@ -53,6 +54,15 @@ def test_services_removed(
response = context_client.ListServices(ContextId(**json_context_id(context_uuid))) response = context_client.ListServices(ContextId(**json_context_id(context_uuid)))
assert len(response.services) == 0 assert len(response.services) == 0
for context_uuid, _ in descriptor_loader.num_slices.items():
response = context_client.ListSlices(ContextId(**json_context_id(context_uuid)))
assert len(response.slices) == 0
# This scenario assumes no services are created beforehand
response = context_client.GetContext(ADMIN_CONTEXT_ID)
assert len(response.service_ids) == 0
assert len(response.slice_ids) == 0
# ----- Delete Links, Devices, Topologies, Contexts ---------------------------------------------------------------- # ----- Delete Links, Devices, Topologies, Contexts ----------------------------------------------------------------
for link in descriptor_loader.links: for link in descriptor_loader.links:
......
...@@ -13,26 +13,24 @@ ...@@ -13,26 +13,24 @@
# limitations under the License. # limitations under the License.
import logging, random import logging, random
from common.DeviceTypes import DeviceTypeEnum from common.Constants import DEFAULT_CONTEXT_NAME
from common.proto.context_pb2 import ContextId, Empty from common.proto.context_pb2 import ContextId, Empty, ServiceTypeEnum
from common.proto.kpi_sample_types_pb2 import KpiSampleType from common.proto.kpi_sample_types_pb2 import KpiSampleType
from common.tools.descriptor.Loader import DescriptorLoader from common.tools.descriptor.Loader import DescriptorLoader
from common.tools.grpc.Tools import grpc_message_to_json_string from common.tools.grpc.Tools import grpc_message_to_json_string
from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Context import json_context_id
from context.client.ContextClient import ContextClient from context.client.ContextClient import ContextClient
from monitoring.client.MonitoringClient import MonitoringClient from monitoring.client.MonitoringClient import MonitoringClient
from tests.Fixtures import context_client, device_client, monitoring_client # pylint: disable=unused-import from tests.Fixtures import context_client, device_client, monitoring_client # pylint: disable=unused-import
from tests.tools.mock_osm.MockOSM import MockOSM from tests.tools.mock_osm.MockOSM import MockOSM
from .Fixtures import osm_wim # pylint: disable=unused-import from .Fixtures import osm_wim # pylint: disable=unused-import
from .Objects import WIM_SERVICE_CONNECTION_POINTS, WIM_SERVICE_TYPE from .Objects import WIM_SERVICE_CONNECTION_POINTS, WIM_SERVICE_TYPE
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG) LOGGER.setLevel(logging.DEBUG)
DEVTYPE_EMU_PR = DeviceTypeEnum.EMULATED_PACKET_ROUTER.value
DEVTYPE_EMU_OLS = DeviceTypeEnum.EMULATED_OPEN_LINE_SYSTEM.value
DESCRIPTOR_FILE = 'ofc22/descriptors_emulated.json' DESCRIPTOR_FILE = 'ofc22/descriptors_emulated.json'
ADMIN_CONTEXT_ID = ContextId(**json_context_id(DEFAULT_CONTEXT_NAME))
def test_service_creation(context_client : ContextClient, osm_wim : MockOSM): # pylint: disable=redefined-outer-name def test_service_creation(context_client : ContextClient, osm_wim : MockOSM): # pylint: disable=redefined-outer-name
# ----- List entities - Ensure scenario is ready ------------------------------------------------------------------- # ----- List entities - Ensure scenario is ready -------------------------------------------------------------------
...@@ -56,7 +54,16 @@ def test_service_creation(context_client : ContextClient, osm_wim : MockOSM): # ...@@ -56,7 +54,16 @@ def test_service_creation(context_client : ContextClient, osm_wim : MockOSM): #
for context_uuid, num_services in descriptor_loader.num_services.items(): for context_uuid, num_services in descriptor_loader.num_services.items():
response = context_client.ListServices(ContextId(**json_context_id(context_uuid))) response = context_client.ListServices(ContextId(**json_context_id(context_uuid)))
assert len(response.services) == 0 assert len(response.services) == num_services
for context_uuid, num_slices in descriptor_loader.num_slices.items():
response = context_client.ListSlices(ContextId(**json_context_id(context_uuid)))
assert len(response.slices) == num_slices
# This scenario assumes no services are created beforehand
response = context_client.GetContext(ADMIN_CONTEXT_ID)
assert len(response.service_ids) == 0
assert len(response.slice_ids) == 0
# ----- Create Service --------------------------------------------------------------------------------------------- # ----- Create Service ---------------------------------------------------------------------------------------------
...@@ -78,18 +85,24 @@ def test_service_creation(context_client : ContextClient, osm_wim : MockOSM): # ...@@ -78,18 +85,24 @@ def test_service_creation(context_client : ContextClient, osm_wim : MockOSM): #
response = context_client.ListLinks(Empty()) response = context_client.ListLinks(Empty())
assert len(response.links) == descriptor_loader.num_links assert len(response.links) == descriptor_loader.num_links
for context_uuid, num_services in descriptor_loader.num_services.items(): response = context_client.ListServices(ADMIN_CONTEXT_ID)
response = context_client.ListServices(ContextId(**json_context_id(context_uuid))) LOGGER.info('Services[{:d}] = {:s}'.format(len(response.services), grpc_message_to_json_string(response)))
LOGGER.info('Services[{:d}] = {:s}'.format(len(response.services), grpc_message_to_json_string(response))) assert len(response.services) == 2 # OLS & L3NM => (L3NM + TAPI)
assert len(response.services) == 2*num_services # OLS & L3NM => (L3NM + TAPI)
for service in response.services:
for service in response.services: service_id = service.service_id
service_id = service.service_id response = context_client.ListConnections(service_id)
response = context_client.ListConnections(service_id) LOGGER.info(' ServiceId[{:s}] => Connections[{:d}] = {:s}'.format(
LOGGER.info(' ServiceId[{:s}] => Connections[{:d}] = {:s}'.format( grpc_message_to_json_string(service_id), len(response.connections), grpc_message_to_json_string(response)))
grpc_message_to_json_string(service_id), len(response.connections),
grpc_message_to_json_string(response))) if service.service_type == ServiceTypeEnum.SERVICETYPE_L3NM:
assert len(response.connections) == 1 # one connection per service assert len(response.connections) == 1 # 1 connection per service
elif service.service_type == ServiceTypeEnum.SERVICETYPE_TAPI_CONNECTIVITY_SERVICE:
assert len(response.connections) == 1 # 1 connection per service
else:
str_service = grpc_message_to_json_string(service)
raise Exception('Unexpected ServiceType: {:s}'.format(str_service))
def test_scenario_kpi_values_created( def test_scenario_kpi_values_created(
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
import logging import logging
from common.Constants import DEFAULT_CONTEXT_NAME from common.Constants import DEFAULT_CONTEXT_NAME
from common.DeviceTypes import DeviceTypeEnum
from common.proto.context_pb2 import ContextId, Empty, ServiceTypeEnum from common.proto.context_pb2 import ContextId, Empty, ServiceTypeEnum
from common.tools.descriptor.Loader import DescriptorLoader from common.tools.descriptor.Loader import DescriptorLoader
from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Context import json_context_id
...@@ -22,17 +21,13 @@ from common.tools.grpc.Tools import grpc_message_to_json_string ...@@ -22,17 +21,13 @@ from common.tools.grpc.Tools import grpc_message_to_json_string
from context.client.ContextClient import ContextClient from context.client.ContextClient import ContextClient
from tests.Fixtures import context_client # pylint: disable=unused-import from tests.Fixtures import context_client # pylint: disable=unused-import
from tests.tools.mock_osm.MockOSM import MockOSM from tests.tools.mock_osm.MockOSM import MockOSM
from .Fixtures import osm_wim # pylint: disable=unused-import from .Fixtures import osm_wim # pylint: disable=unused-import
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG) LOGGER.setLevel(logging.DEBUG)
DEVTYPE_EMU_PR = DeviceTypeEnum.EMULATED_PACKET_ROUTER.value
DEVTYPE_EMU_OLS = DeviceTypeEnum.EMULATED_OPEN_LINE_SYSTEM.value
DESCRIPTOR_FILE = 'ofc22/descriptors_emulated.json' DESCRIPTOR_FILE = 'ofc22/descriptors_emulated.json'
ADMIN_CONTEXT_ID = ContextId(**json_context_id(DEFAULT_CONTEXT_NAME))
def test_service_removal(context_client : ContextClient, osm_wim : MockOSM): # pylint: disable=redefined-outer-name def test_service_removal(context_client : ContextClient, osm_wim : MockOSM): # pylint: disable=redefined-outer-name
# ----- List entities - Ensure service is created ------------------------------------------------------------------ # ----- List entities - Ensure service is created ------------------------------------------------------------------
...@@ -54,30 +49,38 @@ def test_service_removal(context_client : ContextClient, osm_wim : MockOSM): # p ...@@ -54,30 +49,38 @@ def test_service_removal(context_client : ContextClient, osm_wim : MockOSM): # p
response = context_client.ListLinks(Empty()) response = context_client.ListLinks(Empty())
assert len(response.links) == descriptor_loader.num_links assert len(response.links) == descriptor_loader.num_links
l3nm_service_uuids = set() service_uuids = set()
response = context_client.ListServices(ContextId(**json_context_id(DEFAULT_CONTEXT_NAME))) response = context_client.ListServices(ADMIN_CONTEXT_ID)
LOGGER.info('Services[{:d}] = {:s}'.format(len(response.services), grpc_message_to_json_string(response)))
assert len(response.services) == 2 # OLS & L3NM => (L3NM + TAPI) assert len(response.services) == 2 # OLS & L3NM => (L3NM + TAPI)
for service in response.services: for service in response.services:
service_id = service.service_id service_id = service.service_id
if service.service_type == ServiceTypeEnum.SERVICETYPE_L3NM: if service.service_type == ServiceTypeEnum.SERVICETYPE_L3NM:
service_uuid = service_id.service_uuid.uuid service_uuid = service_id.service_uuid.uuid
l3nm_service_uuids.add(service_uuid) service_uuids.add(service_uuid)
osm_wim.conn_info[service_uuid] = {} osm_wim.conn_info[service_uuid] = {}
response = context_client.ListConnections(service_id) response = context_client.ListConnections(service_id)
LOGGER.info(' ServiceId[{:s}] => Connections[{:d}] = {:s}'.format( LOGGER.info(' ServiceId[{:s}] => Connections[{:d}] = {:s}'.format(
grpc_message_to_json_string(service_id), len(response.connections), grpc_message_to_json_string(service_id), len(response.connections), grpc_message_to_json_string(response)))
grpc_message_to_json_string(response)))
assert len(response.connections) == 1 # one connection per service if service.service_type == ServiceTypeEnum.SERVICETYPE_L3NM:
assert len(response.connections) == 1 # 1 connection per service
elif service.service_type == ServiceTypeEnum.SERVICETYPE_TAPI_CONNECTIVITY_SERVICE:
assert len(response.connections) == 1 # 1 connection per service
else:
str_service = grpc_message_to_json_string(service)
raise Exception('Unexpected ServiceType: {:s}'.format(str_service))
# Identify service to delete # Identify service to delete
assert len(l3nm_service_uuids) == 1 # assume a single L3NM service has been created assert len(service_uuids) == 1 # assume a single L3NM service has been created
l3nm_service_uuid = set(l3nm_service_uuids).pop() service_uuid = set(service_uuids).pop()
# ----- Delete Service --------------------------------------------------------------------------------------------- # ----- Delete Service ---------------------------------------------------------------------------------------------
osm_wim.delete_connectivity_service(l3nm_service_uuid) osm_wim.delete_connectivity_service(service_uuid)
# ----- List entities - Ensure service is removed ------------------------------------------------------------------ # ----- List entities - Ensure service is removed ------------------------------------------------------------------
...@@ -96,4 +99,13 @@ def test_service_removal(context_client : ContextClient, osm_wim : MockOSM): # p ...@@ -96,4 +99,13 @@ def test_service_removal(context_client : ContextClient, osm_wim : MockOSM): # p
for context_uuid, num_services in descriptor_loader.num_services.items(): for context_uuid, num_services in descriptor_loader.num_services.items():
response = context_client.ListServices(ContextId(**json_context_id(context_uuid))) response = context_client.ListServices(ContextId(**json_context_id(context_uuid)))
assert len(response.services) == 0 assert len(response.services) == num_services
for context_uuid, num_slices in descriptor_loader.num_slices.items():
response = context_client.ListSlices(ContextId(**json_context_id(context_uuid)))
assert len(response.slices) == num_slices
# This scenario assumes no services are created beforehand
response = context_client.GetContext(ADMIN_CONTEXT_ID)
assert len(response.service_ids) == 0
assert len(response.slice_ids) == 0
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