Loading src/tests/ryu-openflow/tests/test_cleanup.py +27 −15 Original line number Diff line number Diff line Loading @@ -37,23 +37,35 @@ def test_scenario_cleanup( assert len(response.service_ids) == 0 assert len(response.slice_ids) == 0 response = context_client.SelectDevice(DeviceFilter( include_endpoints=False, include_config_rules=False, include_components=False )) #LOGGER.debug('Devices: {:s}'.format(grpc_message_to_json_string(response))) for device in response.devices: if device.device_type in {'openflow-ryu-controller', 'emu-client'}: continue if device.name == 'RYU': continue context_client.RemoveDevice(device.device_id) # Load descriptors and validate the base scenario descriptor_loader = DescriptorLoader( descriptors_file=DESCRIPTOR_FILE, context_client=context_client, device_client=device_client ) #descriptor_loader.validate() descriptor_loader.unload() # Automatic scenario cleanup does not work due to addition of virtual devices. # Doing it manually... link_ids = context_client.ListLinkIds(Empty()) LOGGER.debug('Link Ids: {:s}'.format(grpc_message_to_json_string(link_ids))) for link_id in link_ids.link_ids: context_client.RemoveLink(link_id) device_ids = context_client.ListDeviceIds(Empty()) LOGGER.debug('Device Ids: {:s}'.format(grpc_message_to_json_string(device_ids))) for device_id in device_ids.device_ids: context_client.RemoveDevice(device_id) context_ids = context_client.ListContextIds(Empty()) LOGGER.debug('Context Ids: {:s}'.format(grpc_message_to_json_string(context_ids))) for context_id in context_ids.context_ids: topology_ids = context_client.ListTopologyIds(context_id) LOGGER.debug('Topology Ids: {:s}'.format(grpc_message_to_json_string(topology_ids))) for topology_id in topology_ids.topology_ids: context_client.RemoveTopology(topology_id) context_client.RemoveContext(context_id) response = context_client.ListLinks(Empty()) LOGGER.info('Links: {:s}'.format(grpc_message_to_json_string(response))) response = context_client.ListDevices(Empty()) LOGGER.info('Devices: {:s}'.format(grpc_message_to_json_string(response))) response = context_client.ListContexts(Empty()) LOGGER.info('Contexts: {:s}'.format(grpc_message_to_json_string(response))) validate_empty_scenario(context_client) Loading
src/tests/ryu-openflow/tests/test_cleanup.py +27 −15 Original line number Diff line number Diff line Loading @@ -37,23 +37,35 @@ def test_scenario_cleanup( assert len(response.service_ids) == 0 assert len(response.slice_ids) == 0 response = context_client.SelectDevice(DeviceFilter( include_endpoints=False, include_config_rules=False, include_components=False )) #LOGGER.debug('Devices: {:s}'.format(grpc_message_to_json_string(response))) for device in response.devices: if device.device_type in {'openflow-ryu-controller', 'emu-client'}: continue if device.name == 'RYU': continue context_client.RemoveDevice(device.device_id) # Load descriptors and validate the base scenario descriptor_loader = DescriptorLoader( descriptors_file=DESCRIPTOR_FILE, context_client=context_client, device_client=device_client ) #descriptor_loader.validate() descriptor_loader.unload() # Automatic scenario cleanup does not work due to addition of virtual devices. # Doing it manually... link_ids = context_client.ListLinkIds(Empty()) LOGGER.debug('Link Ids: {:s}'.format(grpc_message_to_json_string(link_ids))) for link_id in link_ids.link_ids: context_client.RemoveLink(link_id) device_ids = context_client.ListDeviceIds(Empty()) LOGGER.debug('Device Ids: {:s}'.format(grpc_message_to_json_string(device_ids))) for device_id in device_ids.device_ids: context_client.RemoveDevice(device_id) context_ids = context_client.ListContextIds(Empty()) LOGGER.debug('Context Ids: {:s}'.format(grpc_message_to_json_string(context_ids))) for context_id in context_ids.context_ids: topology_ids = context_client.ListTopologyIds(context_id) LOGGER.debug('Topology Ids: {:s}'.format(grpc_message_to_json_string(topology_ids))) for topology_id in topology_ids.topology_ids: context_client.RemoveTopology(topology_id) context_client.RemoveContext(context_id) response = context_client.ListLinks(Empty()) LOGGER.info('Links: {:s}'.format(grpc_message_to_json_string(response))) response = context_client.ListDevices(Empty()) LOGGER.info('Devices: {:s}'.format(grpc_message_to_json_string(response))) response = context_client.ListContexts(Empty()) LOGGER.info('Contexts: {:s}'.format(grpc_message_to_json_string(response))) validate_empty_scenario(context_client)