diff --git a/src/common/tools/descriptor/Tools.py b/src/common/tools/descriptor/Tools.py index 07bc18d31b31ede49bd8f6ecc2e478fdd3dc3024..361ddbc9f9b0f3f3f2defee80d93e2a64d3b7c81 100644 --- a/src/common/tools/descriptor/Tools.py +++ b/src/common/tools/descriptor/Tools.py @@ -148,7 +148,7 @@ def split_links_by_type(links : List[Dict]) -> Dict[str, List[Dict]]: raise Exception(MSG.format(str(link))) link_type = LinkTypeEnum.Value(str_link_type) - if link_type in {LinkTypeEnum.LINKTYPE_UNKNOWN, LinkTypeEnum.LINKTYPE_COPPER, LinkTypeEnum.LINKTYPE_RADIO}: + if link_type in {LinkTypeEnum.LINKTYPE_UNKNOWN, LinkTypeEnum.LINKTYPE_COPPER, LinkTypeEnum.LINKTYPE_RADIO, LinkTypeEnum.LINKTYPE_MANAGEMENT}: typed_links['normal'].append(link) elif link_type in {LinkTypeEnum.LINKTYPE_FIBER}: typed_links['optical'].append(link) diff --git a/src/service/service/service_handlers/p4_fabric_tna_acl/p4_fabric_tna_acl_service_handler.py b/src/service/service/service_handlers/p4_fabric_tna_acl/p4_fabric_tna_acl_service_handler.py index b57086a29d36fccb06f103c9f0f6e3eda3148e45..510b59ebb84f0af4460ba8f766e8b8be51ce5816 100644 --- a/src/service/service/service_handlers/p4_fabric_tna_acl/p4_fabric_tna_acl_service_handler.py +++ b/src/service/service/service_handlers/p4_fabric_tna_acl/p4_fabric_tna_acl_service_handler.py @@ -140,8 +140,9 @@ class P4FabricACLServiceHandler(_ServiceHandler): # You should no longer visit this device port again visited.add(dev_port_key) - LOGGER.info("Installed {}/{} ACL rules on device {} and port {}".format( - applied_rules, actual_rules, device_name, port_id)) + if applied_rules > 0: + LOGGER.info("Installed {}/{} ACL rules on device {} and port {}".format( + applied_rules, actual_rules, device_name, port_id)) return results @@ -214,7 +215,7 @@ class P4FabricACLServiceHandler(_ServiceHandler): json_config_rules=rules ) except Exception as ex: - LOGGER.error("Failed to insert ACL rules on device {} due to {}".format(device.name, ex)) + LOGGER.error("Failed to delete ACL rules from device {} due to {}".format(device.name, ex)) finally: rules.clear() @@ -225,8 +226,9 @@ class P4FabricACLServiceHandler(_ServiceHandler): # You should no longer visit this device port again visited.add(dev_port_key) - LOGGER.info("Deleted {}/{} ACL rules from device {} and port {}".format( - applied_rules, actual_rules, device_name, port_id)) + if applied_rules > 0: + LOGGER.info("Deleted {}/{} ACL rules from device {} and port {}".format( + applied_rules, actual_rules, device_name, port_id)) return results diff --git a/src/service/service/service_handlers/p4_fabric_tna_int/p4_fabric_tna_int_service_handler.py b/src/service/service/service_handlers/p4_fabric_tna_int/p4_fabric_tna_int_service_handler.py index dd19c4f895665a80a57d3235db7074ed1f297af6..c5ecdd6823665c8a11d2cc7833f9214e8e0ec71e 100644 --- a/src/service/service/service_handlers/p4_fabric_tna_int/p4_fabric_tna_int_service_handler.py +++ b/src/service/service/service_handlers/p4_fabric_tna_int/p4_fabric_tna_int_service_handler.py @@ -126,8 +126,9 @@ class P4FabricINTServiceHandler(_ServiceHandler): # You should no longer visit this device again visited.add(device.name) - LOGGER.info("Installed {}/{} INT rules on device {}".format( - applied_rules, actual_rules, device.name)) + if applied_rules > 0: + LOGGER.info("Installed {}/{} INT rules on device {}".format( + applied_rules, actual_rules, device.name)) return results @@ -191,8 +192,9 @@ class P4FabricINTServiceHandler(_ServiceHandler): # You should no longer visit this device again visited.add(device.name) - LOGGER.info("Deleted {}/{} INT rules from device {}".format( - applied_rules, actual_rules, device.name)) + if applied_rules > 0: + LOGGER.info("Deleted {}/{} INT rules from device {}".format( + applied_rules, actual_rules, device.name)) return results diff --git a/src/service/service/service_handlers/p4_fabric_tna_l2_simple/p4_fabric_tna_l2_simple_service_handler.py b/src/service/service/service_handlers/p4_fabric_tna_l2_simple/p4_fabric_tna_l2_simple_service_handler.py index 8d4aaf08119ea591a1829eee7122f45e0d9f904f..c24bdc880a0f3da485568aaaaf94dcfe183e47e6 100644 --- a/src/service/service/service_handlers/p4_fabric_tna_l2_simple/p4_fabric_tna_l2_simple_service_handler.py +++ b/src/service/service/service_handlers/p4_fabric_tna_l2_simple/p4_fabric_tna_l2_simple_service_handler.py @@ -131,8 +131,9 @@ class P4FabricL2SimpleServiceHandler(_ServiceHandler): # You should no longer visit this device port again visited.add(dev_port_key) - LOGGER.info("Installed {}/{} L2 rules on device {} and port {}".format( - applied_rules, actual_rules, device_name, port_id)) + if applied_rules > 0: + LOGGER.info("Installed {}/{} L2 rules on device {} and port {}".format( + applied_rules, actual_rules, device_name, port_id)) return results @@ -197,7 +198,7 @@ class P4FabricL2SimpleServiceHandler(_ServiceHandler): json_config_rules=rules ) except Exception as ex: - LOGGER.error("Failed to insert L2 rules on device {} due to {}".format(device.name, ex)) + LOGGER.error("Failed to delete L2 rules from device {} due to {}".format(device.name, ex)) finally: rules.clear() @@ -208,8 +209,9 @@ class P4FabricL2SimpleServiceHandler(_ServiceHandler): # You should no longer visit this device port again visited.add(dev_port_key) - LOGGER.info("Deleted {}/{} L2 rules from device {} and port {}".format( - applied_rules, actual_rules, device_name, port_id)) + if applied_rules > 0: + LOGGER.info("Deleted {}/{} L2 rules from device {} and port {}".format( + applied_rules, actual_rules, device_name, port_id)) return results diff --git a/src/service/service/service_handlers/p4_fabric_tna_l3/p4_fabric_tna_l3_service_handler.py b/src/service/service/service_handlers/p4_fabric_tna_l3/p4_fabric_tna_l3_service_handler.py index 4b013328ee30425a25d7bd6171d938818cb413dc..c97d388291505183fc43fcc948cb1bc9129646ed 100644 --- a/src/service/service/service_handlers/p4_fabric_tna_l3/p4_fabric_tna_l3_service_handler.py +++ b/src/service/service/service_handlers/p4_fabric_tna_l3/p4_fabric_tna_l3_service_handler.py @@ -129,8 +129,9 @@ class P4FabricL3ServiceHandler(_ServiceHandler): # You should no longer visit this device port again visited.add(dev_port_key) - LOGGER.info("Installed {}/{} L3 rules on device {} and port {}".format( - applied_rules, actual_rules, device_name, port_id)) + if applied_rules > 0: + LOGGER.info("Installed {}/{} L3 rules on device {} and port {}".format( + applied_rules, actual_rules, device_name, port_id)) return results @@ -195,7 +196,7 @@ class P4FabricL3ServiceHandler(_ServiceHandler): json_config_rules=rules ) except Exception as ex: - LOGGER.error("Failed to insert L3 rules on device {} due to {}".format(device.name, ex)) + LOGGER.error("Failed to delete L3 rules from device {} due to {}".format(device.name, ex)) finally: rules.clear() @@ -206,8 +207,9 @@ class P4FabricL3ServiceHandler(_ServiceHandler): # You should no longer visit this device port again visited.add(dev_port_key) - LOGGER.info("Deleted {}/{} L3 rules from device {} and port {}".format( - applied_rules, actual_rules, device_name, port_id)) + if applied_rules > 0: + LOGGER.info("Deleted {}/{} L3 rules from device {} and port {}".format( + applied_rules, actual_rules, device_name, port_id)) return results diff --git a/src/tests/p4-fabric-tna/descriptors/sbi-rules-insert-routing-corp.json b/src/tests/p4-fabric-tna/descriptors/sbi-rules-insert-routing-east.json similarity index 100% rename from src/tests/p4-fabric-tna/descriptors/sbi-rules-insert-routing-corp.json rename to src/tests/p4-fabric-tna/descriptors/sbi-rules-insert-routing-east.json diff --git a/src/tests/p4-fabric-tna/descriptors/sbi-rules-insert-routing-edge.json b/src/tests/p4-fabric-tna/descriptors/sbi-rules-insert-routing-west.json similarity index 100% rename from src/tests/p4-fabric-tna/descriptors/sbi-rules-insert-routing-edge.json rename to src/tests/p4-fabric-tna/descriptors/sbi-rules-insert-routing-west.json diff --git a/src/tests/p4-fabric-tna/descriptors/service-create-acl.json b/src/tests/p4-fabric-tna/descriptors/service-p4-acl.json similarity index 100% rename from src/tests/p4-fabric-tna/descriptors/service-create-acl.json rename to src/tests/p4-fabric-tna/descriptors/service-p4-acl.json diff --git a/src/tests/p4-fabric-tna/descriptors/service-create-int.json b/src/tests/p4-fabric-tna/descriptors/service-p4-int.json similarity index 91% rename from src/tests/p4-fabric-tna/descriptors/service-create-int.json rename to src/tests/p4-fabric-tna/descriptors/service-p4-int.json index 785468f6876b13e6186fb7f79ab82e0e0f479c60..7bffd72f1ea99e9bbf66021402b7c910252e0772 100644 --- a/src/tests/p4-fabric-tna/descriptors/service-create-int.json +++ b/src/tests/p4-fabric-tna/descriptors/service-p4-int.json @@ -37,9 +37,9 @@ } }, "int_collector_info": { - "mac": "46:e4:58:c6:74:53", - "ip": "192.168.5.137", - "port": 32766, + "mac": "3e:87:de:3d:6d:33", + "ip": "192.168.5.131", + "port": 12345, "vlan_id": 4094 } } diff --git a/src/tests/p4-fabric-tna/descriptors/service-create-l2-simple.json b/src/tests/p4-fabric-tna/descriptors/service-p4-l2-simple.json similarity index 100% rename from src/tests/p4-fabric-tna/descriptors/service-create-l2-simple.json rename to src/tests/p4-fabric-tna/descriptors/service-p4-l2-simple.json diff --git a/src/tests/p4-fabric-tna/descriptors/service-create-l3.json b/src/tests/p4-fabric-tna/descriptors/service-p4-l3.json similarity index 100% rename from src/tests/p4-fabric-tna/descriptors/service-create-l3.json rename to src/tests/p4-fabric-tna/descriptors/service-p4-l3.json diff --git a/src/tests/p4-fabric-tna/descriptors/topology.json b/src/tests/p4-fabric-tna/descriptors/topology.json index 908faaa7d07eecb04e6b301e4e2bb9a388e0e992..619060e9e00bd589ea988d2cda77f177615b85a0 100644 --- a/src/tests/p4-fabric-tna/descriptors/topology.json +++ b/src/tests/p4-fabric-tna/descriptors/topology.json @@ -10,20 +10,19 @@ { "device_id": {"device_uuid": {"uuid": "tfs-sdn-controller"}}, "name": "tfs-sdn-controller", - "device_type": "teraflowsdn", - "device_drivers": ["DEVICEDRIVER_IETF_L2VPN"], + "device_type": "ietf-slice", + "device_drivers": ["DEVICEDRIVER_IETF_SLICE"], "device_operational_status": "DEVICEOPERATIONALSTATUS_UNDEFINED", "device_config": {"config_rules": [ - {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "192.168.5.137"}}, - {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "8003"}}, + {"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": "mgmt", "name": "mgmt", "type": "mgmt-int"}], - "scheme": "http", "username": "admin", "password": "admin", "import_topology": "topology" + "endpoints": [{"uuid": "mgmt", "name": "mgmt", "type": "mgmt-int"}] }}} ]} }, { - "device_id": {"device_uuid": {"uuid": "edge-net"}}, + "device_id": {"device_uuid": {"uuid": "west-net"}}, "device_type": "network", "device_drivers": ["DEVICEDRIVER_UNDEFINED"], "device_config": { @@ -37,7 +36,7 @@ } }, { - "device_id": {"device_uuid": {"uuid": "corporate-net"}}, + "device_id": {"device_uuid": {"uuid": "east-net"}}, "device_type": "network", "device_drivers": ["DEVICEDRIVER_UNDEFINED"], "device_config": { @@ -81,26 +80,26 @@ ], "links": [ { - "link_id": {"link_uuid": {"uuid": "sw1/1==edge-net/eth1"}}, "link_type": "LINKTYPE_VIRTUAL", "link_endpoint_ids": [ + "link_id": {"link_uuid": {"uuid": "sw1/1==west-net/eth1"}}, "link_type": "LINKTYPE_COPPER", "link_endpoint_ids": [ {"device_id": {"device_uuid": {"uuid": "sw1"}}, "endpoint_uuid": {"uuid": "1"}}, - {"device_id": {"device_uuid": {"uuid": "edge-net"}}, "endpoint_uuid": {"uuid": "eth1"}} + {"device_id": {"device_uuid": {"uuid": "west-net"}}, "endpoint_uuid": {"uuid": "eth1"}} ] }, { - "link_id": {"link_uuid": {"uuid": "edge-net/eth1==sw1/1"}}, "link_type": "LINKTYPE_VIRTUAL", "link_endpoint_ids": [ - {"device_id": {"device_uuid": {"uuid": "edge-net"}}, "endpoint_uuid": {"uuid": "eth1"}}, + "link_id": {"link_uuid": {"uuid": "west-net/eth1==sw1/1"}}, "link_type": "LINKTYPE_COPPER", "link_endpoint_ids": [ + {"device_id": {"device_uuid": {"uuid": "west-net"}}, "endpoint_uuid": {"uuid": "eth1"}}, {"device_id": {"device_uuid": {"uuid": "sw1"}}, "endpoint_uuid": {"uuid": "1"}} ] }, { - "link_id": {"link_uuid": {"uuid": "sw1/2==corporate-net/eth1"}}, "link_type": "LINKTYPE_VIRTUAL", "link_endpoint_ids": [ + "link_id": {"link_uuid": {"uuid": "sw1/2==east-net/eth1"}}, "link_type": "LINKTYPE_COPPER", "link_endpoint_ids": [ {"device_id": {"device_uuid": {"uuid": "sw1"}}, "endpoint_uuid": {"uuid": "2"}}, - {"device_id": {"device_uuid": {"uuid": "corporate-net"}}, "endpoint_uuid": {"uuid": "eth1"}} + {"device_id": {"device_uuid": {"uuid": "east-net"}}, "endpoint_uuid": {"uuid": "eth1"}} ] }, { - "link_id": {"link_uuid": {"uuid": "corporate-net/eth1==sw1/2"}}, "link_type": "LINKTYPE_VIRTUAL", "link_endpoint_ids": [ - {"device_id": {"device_uuid": {"uuid": "corporate-net"}}, "endpoint_uuid": {"uuid": "eth1"}}, + "link_id": {"link_uuid": {"uuid": "east-net/eth1==sw1/2"}}, "link_type": "LINKTYPE_COPPER", "link_endpoint_ids": [ + {"device_id": {"device_uuid": {"uuid": "east-net"}}, "endpoint_uuid": {"uuid": "eth1"}}, {"device_id": {"device_uuid": {"uuid": "sw1"}}, "endpoint_uuid": {"uuid": "2"}} ] }, diff --git a/src/tests/p4-fabric-tna/tests-sbi/test_functional_sbi_rules_deprovision.py b/src/tests/p4-fabric-tna/tests-sbi/test_functional_sbi_rules_deprovision.py index 6d5f7dfd2b2207b1a98bcc516259f841285fdb9d..f9b09ebd603845aca3e9629a74eead51c4b48bef 100644 --- a/src/tests/p4-fabric-tna/tests-sbi/test_functional_sbi_rules_deprovision.py +++ b/src/tests/p4-fabric-tna/tests-sbi/test_functional_sbi_rules_deprovision.py @@ -18,7 +18,21 @@ from common.tools.grpc.Tools import grpc_message_to_json_string from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from tests.Fixtures import context_client, device_client # pylint: disable=unused-import -from tests.tools.test_tools_p4 import * +from tests.tools.test_tools_p4 import ( + ADMIN_CONTEXT_ID, + DESC_FILE_RULES_DELETE_ALL, + DEV_NB, + CONNECTION_RULES, + ENDPOINT_RULES, + DATAPLANE_RULES_NB_INT_B1, + DATAPLANE_RULES_NB_INT_B2, + DATAPLANE_RULES_NB_INT_B3, + DATAPLANE_RULES_NB_RT_WEST, + DATAPLANE_RULES_NB_RT_EAST, + DATAPLANE_RULES_NB_ACL, + DATAPLANE_RULES_NB_TOT, + verify_number_of_rules +) LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) @@ -60,8 +74,8 @@ def test_rules_before_removal( DATAPLANE_RULES_NB_INT_B1 + \ DATAPLANE_RULES_NB_INT_B2 + \ DATAPLANE_RULES_NB_INT_B3 + \ - DATAPLANE_RULES_NB_RT_EDGE + \ - DATAPLANE_RULES_NB_RT_CORP + \ + DATAPLANE_RULES_NB_RT_WEST + \ + DATAPLANE_RULES_NB_RT_EAST + \ DATAPLANE_RULES_NB_ACL assert desired_rules_nb == CONNECTION_RULES + ENDPOINT_RULES + DATAPLANE_RULES_NB_TOT verify_number_of_rules(response.devices, desired_rules_nb) diff --git a/src/tests/p4-fabric-tna/tests-sbi/test_functional_sbi_rules_provision.py b/src/tests/p4-fabric-tna/tests-sbi/test_functional_sbi_rules_provision.py index 49d9aba4d504477d1079aa55cefc607368ee79b8..afb7a6df3538ec05a07fe89bcb220ad4edad9efd 100644 --- a/src/tests/p4-fabric-tna/tests-sbi/test_functional_sbi_rules_provision.py +++ b/src/tests/p4-fabric-tna/tests-sbi/test_functional_sbi_rules_provision.py @@ -18,7 +18,26 @@ from common.tools.grpc.Tools import grpc_message_to_json_string from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from tests.Fixtures import context_client, device_client # pylint: disable=unused-import -from tests.tools.test_tools_p4 import * +from tests.tools.test_tools_p4 import ( + ADMIN_CONTEXT_ID, + DESC_FILE_RULES_INSERT_INT_B1, + DESC_FILE_RULES_INSERT_INT_B2, + DESC_FILE_RULES_INSERT_INT_B3, + DESC_FILE_RULES_INSERT_ROUTING_WEST, + DESC_FILE_RULES_INSERT_ROUTING_EAST, + DESC_FILE_RULES_INSERT_ACL, + DEV_NB, + CONNECTION_RULES, + ENDPOINT_RULES, + DATAPLANE_RULES_NB_INT_B1, + DATAPLANE_RULES_NB_INT_B2, + DATAPLANE_RULES_NB_INT_B3, + DATAPLANE_RULES_NB_RT_WEST, + DATAPLANE_RULES_NB_RT_EAST, + DATAPLANE_RULES_NB_ACL, + DATAPLANE_RULES_NB_TOT, + verify_number_of_rules +) LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) @@ -143,18 +162,18 @@ def test_rules_after_insertion_int_batch_3( DATAPLANE_RULES_NB_INT_B3 verify_number_of_rules(response.devices, desired_rules_nb) -def test_rules_insertion_routing_edge_batch_4( +def test_rules_insertion_routing_west_batch_4( context_client : ContextClient, # pylint: disable=redefined-outer-name device_client : DeviceClient # pylint: disable=redefined-outer-name ) -> None: # Load routing edge batch 4 rules for insertion descriptor_loader = DescriptorLoader( - descriptors_file=DESC_FILE_RULES_INSERT_ROUTING_EDGE, context_client=context_client, device_client=device_client + descriptors_file=DESC_FILE_RULES_INSERT_ROUTING_WEST, context_client=context_client, device_client=device_client ) results = descriptor_loader.process() check_descriptor_load_results(results, descriptor_loader) -def test_rules_after_insertion_routing_edge_batch_4( +def test_rules_after_insertion_routing_west_batch_4( context_client : ContextClient # pylint: disable=redefined-outer-name ) -> None: # State **after** inserting batch 4 of routing edge rules @@ -170,21 +189,21 @@ def test_rules_after_insertion_routing_edge_batch_4( DATAPLANE_RULES_NB_INT_B1 + \ DATAPLANE_RULES_NB_INT_B2 + \ DATAPLANE_RULES_NB_INT_B3 + \ - DATAPLANE_RULES_NB_RT_EDGE + DATAPLANE_RULES_NB_RT_WEST verify_number_of_rules(response.devices, desired_rules_nb) -def test_rules_insertion_routing_corp_batch_5( +def test_rules_insertion_routing_east_batch_5( context_client : ContextClient, # pylint: disable=redefined-outer-name device_client : DeviceClient # pylint: disable=redefined-outer-name ) -> None: # Load routing corp batch 5 rules for insertion descriptor_loader = DescriptorLoader( - descriptors_file=DESC_FILE_RULES_INSERT_ROUTING_CORP, context_client=context_client, device_client=device_client + descriptors_file=DESC_FILE_RULES_INSERT_ROUTING_EAST, context_client=context_client, device_client=device_client ) results = descriptor_loader.process() check_descriptor_load_results(results, descriptor_loader) -def test_rules_after_insertion_routing_corp_batch_5( +def test_rules_after_insertion_routing_east_batch_5( context_client : ContextClient # pylint: disable=redefined-outer-name ) -> None: # State **after** inserting batch 5 of routing corp rules @@ -200,8 +219,8 @@ def test_rules_after_insertion_routing_corp_batch_5( DATAPLANE_RULES_NB_INT_B1 + \ DATAPLANE_RULES_NB_INT_B2 + \ DATAPLANE_RULES_NB_INT_B3 + \ - DATAPLANE_RULES_NB_RT_EDGE + \ - DATAPLANE_RULES_NB_RT_CORP + DATAPLANE_RULES_NB_RT_WEST + \ + DATAPLANE_RULES_NB_RT_EAST verify_number_of_rules(response.devices, desired_rules_nb) def test_rules_insertion_acl_batch_6( @@ -231,8 +250,8 @@ def test_rules_after_insertion_acl_batch_6( DATAPLANE_RULES_NB_INT_B1 + \ DATAPLANE_RULES_NB_INT_B2 + \ DATAPLANE_RULES_NB_INT_B3 + \ - DATAPLANE_RULES_NB_RT_EDGE + \ - DATAPLANE_RULES_NB_RT_CORP + \ + DATAPLANE_RULES_NB_RT_WEST + \ + DATAPLANE_RULES_NB_RT_EAST + \ DATAPLANE_RULES_NB_ACL assert desired_rules_nb == CONNECTION_RULES + ENDPOINT_RULES + DATAPLANE_RULES_NB_TOT verify_number_of_rules(response.devices, desired_rules_nb) diff --git a/src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_acl.py b/src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_acl.py index fcecbd2c7ce5fdf266e3524a98b07e4cf5bbbb89..a93691c46e36b83a09922ec24d89df459fbd7f92 100644 --- a/src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_acl.py +++ b/src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_acl.py @@ -15,11 +15,20 @@ import logging from common.proto.context_pb2 import ServiceId, ServiceStatusEnum, ServiceTypeEnum 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.Service import json_service_id from context.client.ContextClient import ContextClient from service.client.ServiceClient import ServiceClient from tests.Fixtures import context_client, service_client # pylint: disable=unused-import -from tests.tools.test_tools_p4 import * +from tests.tools.test_tools_p4 import ( + ADMIN_CONTEXT_ID, + DEV_NB, + P4_DEV_NB, + ACL_RULES, + identify_number_of_p4_devices, + get_number_of_rules, + verify_active_service_type +) LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) diff --git a/src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_int.py b/src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_int.py index f29f6b17c92bc851e9ee2dae03fb2e040aba409f..cee498c8f73a46fb3e822242580a097f64019d95 100644 --- a/src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_int.py +++ b/src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_int.py @@ -15,11 +15,20 @@ import logging from common.proto.context_pb2 import ServiceId, ServiceStatusEnum, ServiceTypeEnum 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.Service import json_service_id from context.client.ContextClient import ContextClient from service.client.ServiceClient import ServiceClient from tests.Fixtures import context_client, service_client # pylint: disable=unused-import -from tests.tools.test_tools_p4 import * +from tests.tools.test_tools_p4 import ( + ADMIN_CONTEXT_ID, + DEV_NB, + P4_DEV_NB, + INT_RULES, + identify_number_of_p4_devices, + get_number_of_rules, + verify_active_service_type +) LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) diff --git a/src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_l2.py b/src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_l2.py index 87ef21285fe3c33944e850d689f341118b08976b..dfbd578652a4e0ae03bf1dd302ce7b7f571cad12 100644 --- a/src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_l2.py +++ b/src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_l2.py @@ -15,11 +15,20 @@ import logging from common.proto.context_pb2 import ServiceId, ServiceStatusEnum, ServiceTypeEnum 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.Service import json_service_id from context.client.ContextClient import ContextClient from service.client.ServiceClient import ServiceClient from tests.Fixtures import context_client, service_client # pylint: disable=unused-import -from tests.tools.test_tools_p4 import * +from tests.tools.test_tools_p4 import ( + ADMIN_CONTEXT_ID, + DEV_NB, + P4_DEV_NB, + L2_RULES, + identify_number_of_p4_devices, + get_number_of_rules, + verify_active_service_type +) LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) diff --git a/src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_l3.py b/src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_l3.py index d349a08747802746a1f9d04d53a165e4359b70ce..e5f804ce02f8cb0df5e0cdc3d56f59469a620850 100644 --- a/src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_l3.py +++ b/src/tests/p4-fabric-tna/tests-service/test_functional_service_deprovision_l3.py @@ -15,11 +15,20 @@ import logging from common.proto.context_pb2 import ServiceId, ServiceStatusEnum, ServiceTypeEnum 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.Service import json_service_id from context.client.ContextClient import ContextClient from service.client.ServiceClient import ServiceClient from tests.Fixtures import context_client, service_client # pylint: disable=unused-import -from tests.tools.test_tools_p4 import * +from tests.tools.test_tools_p4 import ( + ADMIN_CONTEXT_ID, + DEV_NB, + P4_DEV_NB, + L3_RULES, + identify_number_of_p4_devices, + get_number_of_rules, + verify_active_service_type +) LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) diff --git a/src/tests/p4-fabric-tna/tests-service/test_functional_service_provision_acl.py b/src/tests/p4-fabric-tna/tests-service/test_functional_service_provision_acl.py index 58de046b4171f12ccfc39d078e66cf5ad0670d2a..5593e093c4e5819d1c7782134404f5286ec64450 100644 --- a/src/tests/p4-fabric-tna/tests-service/test_functional_service_provision_acl.py +++ b/src/tests/p4-fabric-tna/tests-service/test_functional_service_provision_acl.py @@ -20,7 +20,16 @@ from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from service.client.ServiceClient import ServiceClient from tests.Fixtures import context_client, device_client, service_client # pylint: disable=unused-import -from tests.tools.test_tools_p4 import * +from tests.tools.test_tools_p4 import ( + ADMIN_CONTEXT_ID, + DESC_FILE_SERVICE_P4_ACL, + DEV_NB, + P4_DEV_NB, + ACL_RULES, + identify_number_of_p4_devices, + get_number_of_rules, + verify_active_service_type +) LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) @@ -51,7 +60,7 @@ def test_service_creation_acl( # Load service descriptor_loader = DescriptorLoader( - descriptors_file=DESC_FILE_SERVICE_CREATE_ACL, + descriptors_file=DESC_FILE_SERVICE_P4_ACL, context_client=context_client, device_client=device_client, service_client=service_client ) results = descriptor_loader.process() diff --git a/src/tests/p4-fabric-tna/tests-service/test_functional_service_provision_int.py b/src/tests/p4-fabric-tna/tests-service/test_functional_service_provision_int.py index 7a875c66abae8139e4e7bc29451dab01490f4599..7f1453dd9449d1b62b6cd4cf89f0b02a9f2307e4 100644 --- a/src/tests/p4-fabric-tna/tests-service/test_functional_service_provision_int.py +++ b/src/tests/p4-fabric-tna/tests-service/test_functional_service_provision_int.py @@ -20,7 +20,16 @@ from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from service.client.ServiceClient import ServiceClient from tests.Fixtures import context_client, device_client, service_client # pylint: disable=unused-import -from tests.tools.test_tools_p4 import * +from tests.tools.test_tools_p4 import ( + ADMIN_CONTEXT_ID, + DESC_FILE_SERVICE_P4_INT, + DEV_NB, + P4_DEV_NB, + INT_RULES, + identify_number_of_p4_devices, + get_number_of_rules, + verify_active_service_type +) LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) @@ -51,7 +60,7 @@ def test_service_creation_int( # Load service descriptor_loader = DescriptorLoader( - descriptors_file=DESC_FILE_SERVICE_CREATE_INT, + descriptors_file=DESC_FILE_SERVICE_P4_INT, context_client=context_client, device_client=device_client, service_client=service_client ) results = descriptor_loader.process() diff --git a/src/tests/p4-fabric-tna/tests-service/test_functional_service_provision_l2.py b/src/tests/p4-fabric-tna/tests-service/test_functional_service_provision_l2.py index a42c05546659c809cfa94049255296beecd7069a..4786cb32427d1fe6a1fa92678df7cdfe9ab4ad6e 100644 --- a/src/tests/p4-fabric-tna/tests-service/test_functional_service_provision_l2.py +++ b/src/tests/p4-fabric-tna/tests-service/test_functional_service_provision_l2.py @@ -20,7 +20,16 @@ from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from service.client.ServiceClient import ServiceClient from tests.Fixtures import context_client, device_client, service_client # pylint: disable=unused-import -from tests.tools.test_tools_p4 import * +from tests.tools.test_tools_p4 import ( + ADMIN_CONTEXT_ID, + DESC_FILE_SERVICE_P4_L2_SIMPLE, + DEV_NB, + P4_DEV_NB, + L2_RULES, + identify_number_of_p4_devices, + get_number_of_rules, + verify_active_service_type +) LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) @@ -51,7 +60,7 @@ def test_service_creation_l2( # Load service descriptor_loader = DescriptorLoader( - descriptors_file=DESC_FILE_SERVICE_CREATE_L2_SIMPLE, + descriptors_file=DESC_FILE_SERVICE_P4_L2_SIMPLE, context_client=context_client, device_client=device_client, service_client=service_client ) results = descriptor_loader.process() diff --git a/src/tests/p4-fabric-tna/tests-service/test_functional_service_provision_l3.py b/src/tests/p4-fabric-tna/tests-service/test_functional_service_provision_l3.py index 9c0009b14472ddf055d41a8bf4923c64a9f5c151..8c480ce8374438f72793ccafc270737d5fc4e2fc 100644 --- a/src/tests/p4-fabric-tna/tests-service/test_functional_service_provision_l3.py +++ b/src/tests/p4-fabric-tna/tests-service/test_functional_service_provision_l3.py @@ -20,7 +20,16 @@ from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from service.client.ServiceClient import ServiceClient from tests.Fixtures import context_client, device_client, service_client # pylint: disable=unused-import -from tests.tools.test_tools_p4 import * +from tests.tools.test_tools_p4 import ( + ADMIN_CONTEXT_ID, + DESC_FILE_SERVICE_P4_L3, + DEV_NB, + P4_DEV_NB, + L3_RULES, + identify_number_of_p4_devices, + get_number_of_rules, + verify_active_service_type +) LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) @@ -51,7 +60,7 @@ def test_service_creation_l3( # Load service descriptor_loader = DescriptorLoader( - descriptors_file=DESC_FILE_SERVICE_CREATE_L3, + descriptors_file=DESC_FILE_SERVICE_P4_L3, context_client=context_client, device_client=device_client, service_client=service_client ) results = descriptor_loader.process() diff --git a/src/tests/p4-fabric-tna/tests-setup/test_functional_bootstrap.py b/src/tests/p4-fabric-tna/tests-setup/test_functional_bootstrap.py index 2f9130ad000f406c7dab6de828c314670ffaa173..fb06a659e0189ca8478785f038ffa10220cfc665 100644 --- a/src/tests/p4-fabric-tna/tests-setup/test_functional_bootstrap.py +++ b/src/tests/p4-fabric-tna/tests-setup/test_functional_bootstrap.py @@ -19,7 +19,7 @@ from common.tools.descriptor.Loader import DescriptorLoader, \ from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from tests.Fixtures import context_client, device_client # pylint: disable=unused-import -from tests.tools.test_tools_p4 import * +from tests.tools.test_tools_p4 import ADMIN_CONTEXT_ID, DESC_TOPO LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) diff --git a/src/tests/p4-fabric-tna/tests-setup/test_functional_cleanup.py b/src/tests/p4-fabric-tna/tests-setup/test_functional_cleanup.py index 4d98c9e0500281c4e8dfd6f43de833c4ad3411fd..eff11b3c2e2fd9bf0376e489ee276eb112583e9b 100644 --- a/src/tests/p4-fabric-tna/tests-setup/test_functional_cleanup.py +++ b/src/tests/p4-fabric-tna/tests-setup/test_functional_cleanup.py @@ -17,7 +17,7 @@ from common.tools.descriptor.Loader import DescriptorLoader, validate_empty_scen from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from tests.Fixtures import context_client, device_client # pylint: disable=unused-import -from tests.tools.test_tools_p4 import * +from tests.tools.test_tools_p4 import ADMIN_CONTEXT_ID, DESC_TOPO LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) diff --git a/src/tests/p4-fabric-tna/tests-setup/test_functional_purge.py b/src/tests/p4-fabric-tna/tests-setup/test_functional_purge.py index ba37fbd89c2eea9ab6e3bae84fcfb8669f9a4e78..f9baeaf9736c016e78674d93773fadeb4f0ce6b3 100644 --- a/src/tests/p4-fabric-tna/tests-setup/test_functional_purge.py +++ b/src/tests/p4-fabric-tna/tests-setup/test_functional_purge.py @@ -15,12 +15,14 @@ import logging from common.proto.context_pb2 import ServiceId, DeviceId, LinkId, ServiceStatusEnum, ServiceTypeEnum 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.Device import json_device_id from common.tools.object_factory.Service import json_service_id from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from service.client.ServiceClient import ServiceClient from tests.Fixtures import context_client, device_client, service_client # pylint: disable=unused-import -from tests.tools.test_tools_p4 import * +from tests.tools.test_tools_p4 import ADMIN_CONTEXT_ID LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) @@ -63,10 +65,11 @@ def test_clean_devices( LOGGER.warning('Devices[{:d}] = {:s}'.format(len(response.devices), grpc_message_to_json_string(response))) for device in response.devices: - device_id = device.device_id + device_uuid = device.device_id.device_uuid.uuid + device_json = json_device_id(device_uuid) # Delete device - device_client.DeleteDevice(DeviceId(**device_id)) + device_client.DeleteDevice(DeviceId(**device_json)) def test_clean_context( context_client : ContextClient # pylint: disable=redefined-outer-name diff --git a/src/tests/tools/test_tools_p4.py b/src/tests/tools/test_tools_p4.py index c68f3518326d2cae4e0c145b3e8630c2a61f7f39..4e9c637340cf0ed395601693927d14b254ac3258 100644 --- a/src/tests/tools/test_tools_p4.py +++ b/src/tests/tools/test_tools_p4.py @@ -35,15 +35,15 @@ ACL_RULES = 1 DATAPLANE_RULES_NB_INT_B1 = 5 DATAPLANE_RULES_NB_INT_B2 = 6 DATAPLANE_RULES_NB_INT_B3 = 8 -DATAPLANE_RULES_NB_RT_EDGE = 7 -DATAPLANE_RULES_NB_RT_CORP = 7 +DATAPLANE_RULES_NB_RT_WEST = 7 +DATAPLANE_RULES_NB_RT_EAST = 7 DATAPLANE_RULES_NB_ACL = 1 DATAPLANE_RULES_NB_TOT = \ DATAPLANE_RULES_NB_INT_B1 +\ DATAPLANE_RULES_NB_INT_B2 +\ DATAPLANE_RULES_NB_INT_B3 +\ - DATAPLANE_RULES_NB_RT_EDGE +\ - DATAPLANE_RULES_NB_RT_CORP +\ + DATAPLANE_RULES_NB_RT_WEST +\ + DATAPLANE_RULES_NB_RT_EAST +\ DATAPLANE_RULES_NB_ACL # Service-related variables @@ -75,12 +75,12 @@ DESC_FILE_RULES_INSERT_INT_B3 = os.path.join(TEST_PATH, 'sbi-rules-insert-int-b3 assert os.path.exists(DESC_FILE_RULES_INSERT_INT_B3),\ "Invalid path to the SD-Fabric INT SBI descriptor (batch #3)" -DESC_FILE_RULES_INSERT_ROUTING_EDGE = os.path.join(TEST_PATH, 'sbi-rules-insert-routing-edge.json') -assert os.path.exists(DESC_FILE_RULES_INSERT_ROUTING_EDGE),\ +DESC_FILE_RULES_INSERT_ROUTING_WEST = os.path.join(TEST_PATH, 'sbi-rules-insert-routing-west.json') +assert os.path.exists(DESC_FILE_RULES_INSERT_ROUTING_WEST),\ "Invalid path to the SD-Fabric routing SBI descriptor (domain1-side)" -DESC_FILE_RULES_INSERT_ROUTING_CORP = os.path.join(TEST_PATH, 'sbi-rules-insert-routing-corp.json') -assert os.path.exists(DESC_FILE_RULES_INSERT_ROUTING_CORP),\ +DESC_FILE_RULES_INSERT_ROUTING_EAST = os.path.join(TEST_PATH, 'sbi-rules-insert-routing-east.json') +assert os.path.exists(DESC_FILE_RULES_INSERT_ROUTING_EAST),\ "Invalid path to the SD-Fabric routing SBI descriptor (domain2-side)" DESC_FILE_RULES_INSERT_ACL = os.path.join(TEST_PATH, 'sbi-rules-insert-acl.json') @@ -92,20 +92,20 @@ assert os.path.exists(DESC_FILE_RULES_DELETE_ALL),\ "Invalid path to the SD-Fabric rule removal SBI descriptor" # Service descriptors -DESC_FILE_SERVICE_CREATE_INT = os.path.join(TEST_PATH, 'service-create-int.json') -assert os.path.exists(DESC_FILE_SERVICE_CREATE_INT),\ +DESC_FILE_SERVICE_P4_INT = os.path.join(TEST_PATH, 'service-p4-int.json') +assert os.path.exists(DESC_FILE_SERVICE_P4_INT),\ "Invalid path to the SD-Fabric INT service descriptor" -DESC_FILE_SERVICE_CREATE_L2_SIMPLE = os.path.join(TEST_PATH, 'service-create-l2-simple.json') -assert os.path.exists(DESC_FILE_SERVICE_CREATE_L2_SIMPLE),\ +DESC_FILE_SERVICE_P4_L2_SIMPLE = os.path.join(TEST_PATH, 'service-p4-l2-simple.json') +assert os.path.exists(DESC_FILE_SERVICE_P4_L2_SIMPLE),\ "Invalid path to the SD-Fabric L2 simple service descriptor" -DESC_FILE_SERVICE_CREATE_L3 = os.path.join(TEST_PATH, 'service-create-l3.json') -assert os.path.exists(DESC_FILE_SERVICE_CREATE_L3),\ +DESC_FILE_SERVICE_P4_L3 = os.path.join(TEST_PATH, 'service-p4-l3.json') +assert os.path.exists(DESC_FILE_SERVICE_P4_L3),\ "Invalid path to the SD-Fabric L3 service descriptor" -DESC_FILE_SERVICE_CREATE_ACL = os.path.join(TEST_PATH, 'service-create-acl.json') -assert os.path.exists(DESC_FILE_SERVICE_CREATE_ACL),\ +DESC_FILE_SERVICE_P4_ACL = os.path.join(TEST_PATH, 'service-p4-acl.json') +assert os.path.exists(DESC_FILE_SERVICE_P4_ACL),\ "Invalid path to the SD-Fabric ACL service descriptor" def identify_number_of_p4_devices(devices) -> int: