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

NBI Component - IETF Network plugin:

- Added loggers in ietf_network unitary tests
- Added loggers in node composer
- Added custom name/id mappers for termination points
- Corrected manual fixes
- Added test_ietf_network to CI/CD pipeline
parent e11b7f48
No related branches found
No related tags found
2 merge requests!235Release TeraFlowSDN 3.0,!173Resolve "(CTTC) Implement NBI connector IETF Network Topology"
......@@ -56,7 +56,7 @@ unit_test nbi:
- sleep 5
- docker ps -a
- docker logs $IMAGE_NAME
- docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml"
- docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py $IMAGE_NAME/tests/test_ietf_network.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml"
- docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing"
coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/'
after_script:
......
......@@ -12,12 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
from common.proto.context_pb2 import Device
from .bindings.networks.network.node import node
from .ComposeTermPoint import compose_term_point
from .NameMapping import NameMappings
from .NetworkTypeEnum import NetworkTypeEnum
LOGGER = logging.getLogger(__name__)
NODE_NAME_MAPPINGS = {
'10.0.10.1': 'OA',
'10.0.20.1': 'P',
......@@ -28,9 +31,11 @@ NODE_NAME_MAPPINGS = {
def compose_node(
ietf_node_obj : node, device : Device, name_mappings : NameMappings, network_type : NetworkTypeEnum
) -> None:
device_name = device.name
LOGGER.warning('network_type={:s} device_name={:s}'.format(str(network_type.value), str(device_name)))
name_mappings.store_device_name(device)
device_name = device.name
ietf_node_obj.te_node_id = device_name
ietf_node_obj.te._set_oper_status('up')
......
......@@ -17,20 +17,32 @@ from .bindings.networks.network.node.termination_point import termination_point
from .NameMapping import NameMappings
from .NetworkTypeEnum import NetworkTypeEnum
TP_NAME_MAPPINGS = {
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.10.1', '200'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.10.1', '500'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.10.1', '501'): '1-1-1-1-1',
MAPPINGS_TE_NAME = {
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.10.1', '200'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.10.1', '500'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.10.1', '501'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.20.1', '500'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.20.1', '501'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.20.1', '500'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.20.1', '501'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.30.1', '200'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.30.1', '500'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.30.1', '501'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.30.1', '200'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.30.1', '500'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.30.1', '501'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.40.1', '500'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.40.1', '501'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.40.1', '500'): '1-1-1-1-1',
(NetworkTypeEnum.TE_OTN_TOPOLOGY, '10.0.40.1', '501'): '1-1-1-1-1',
(NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY, '10.0.10.1', '200'): 'endpoint:111',
(NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY, '10.0.10.1', '500'): 'endpoint:111',
(NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY, '10.0.10.1', '501'): 'endpoint:111',
(NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY, '10.0.30.1', '200'): '172.10.33.254',
(NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY, '10.0.30.1', '500'): 'endpoint:111',
(NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY, '10.0.30.1', '501'): 'endpoint:111',
}
MAPPINGS_TE_TP_ID = {
(NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY, '10.0.10.1', '200'): '128.32.33.254',
}
def compose_term_point(
......@@ -42,11 +54,11 @@ def compose_term_point(
device_name = device.name
endpoint_name = endpoint.name
ietf_tp_obj.te_tp_id = endpoint_name
ietf_tp_obj.te_tp_id = MAPPINGS_TE_TP_ID.get((network_type, device_name, endpoint_name), endpoint_name)
ietf_tp_obj.te._set_oper_status('up')
ietf_tp_obj.te.admin_status = 'up'
ietf_tp_obj.te.name = TP_NAME_MAPPINGS.get((network_type, device_name, endpoint_name), endpoint_name)
ietf_tp_obj.te.name = MAPPINGS_TE_NAME.get((network_type, device_name, endpoint_name), endpoint_name)
if network_type == NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY:
ietf_if_sw_cap = ietf_tp_obj.te.interface_switching_capability.add(
......
......@@ -39,7 +39,8 @@ def manual_fixes(json_response : Dict) -> None:
if json_node['node-id'] in {'10.0.10.1', '10.0.30.1'}:
if network_type == NetworkTypeEnum.TE_ETH_TRAN_TOPOLOGY:
if 'ietf-eth-te-topology:eth-svc' in json_tp:
json_tp['ietf-eth-te-topology:eth-svc']['client-facing'] = True
client_facing = json_tp['tp-id'] == '200'
json_tp['ietf-eth-te-topology:eth-svc']['client-facing'] = client_facing
json_tp_te = json_tp.get('ietf-te-topology:te', {})
......
......@@ -28,7 +28,7 @@ from .PrepareTestScenario import ( # pylint: disable=unused-import
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG)
DESCRIPTOR_FILE = 'nbi/tests/data/topology_dummy.json'
DESCRIPTOR_FILE = 'nbi/tests/data/topology-dummy.json'
TARGET_DATA_FILE = 'nbi/tests/data/test-ietf-network.json'
JSON_ADMIN_CONTEXT_ID = json_context_id(DEFAULT_CONTEXT_NAME)
......@@ -81,7 +81,9 @@ def test_rest_get_networks(nbi_service_rest : RestServer): # pylint: disable=red
URL = '/restconf/data/ietf-network:networks'
retrieved_data = do_rest_request(URL, logger=LOGGER, expected_status_codes={200})
sort_data(retrieved_data)
sort_data(target_data )
LOGGER.warning('retrieved_data={:s}'.format(json.dumps(retrieved_data, sort_keys=True)))
sort_data(target_data)
LOGGER.warning('target_data={:s}'.format(json.dumps(target_data, sort_keys=True)))
diff_data = deepdiff.DeepDiff(target_data, retrieved_data)
LOGGER.error('Differences:\n{:s}'.format(str(diff_data.pretty())))
assert len(diff_data) == 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