... how to use restconf application peer interface:
... https://wiki.opendaylight.org/view/BGP_LS_PCEP:User_Guide#BGP_Application_Peer
... https://wiki.opendaylight.org/view/BGP_LS_PCEP:Programmer_Guide#BGP
+... http://docs.opendaylight.org/en/stable-boron/user-guide/bgp-user-guide.html#bgp-peering
+... http://docs.opendaylight.org/en/stable-boron/user-guide/bgp-user-guide.html#application-peer-configuration
...
... Reported bugs:
... Bug 4689 - Not a reasonable duration of 1M prefix introduction from BGP application peer via restconf
Force Tags critical
Library SSHLibrary timeout=10s
Library RequestsLibrary
-Variables ${CURDIR}/../../../variables/Variables.py
-Resource ${CURDIR}/../../../libraries/BGPcliKeywords.robot
-Resource ${CURDIR}/../../../libraries/BGPSpeaker.robot
-Resource ${CURDIR}/../../../libraries/ConfigViaRestconf.robot
-Resource ${CURDIR}/../../../libraries/FailFast.robot
-Resource ${CURDIR}/../../../libraries/KillPythonTool.robot
-Resource ${CURDIR}/../../../libraries/PrefixCounting.robot
-Resource ${CURDIR}/../../../libraries/SetupUtils.robot
+Resource ../../../libraries/BGPcliKeywords.robot
+Resource ../../../libraries/KarafKeywords.robot
+Resource ../../../libraries/KillPythonTool.robot
+Resource ../../../libraries/PrefixCounting.robot
+Resource ../../../libraries/SetupUtils.robot
+Resource ../../../libraries/SSHKeywords.robot
+Resource ../../../libraries/TemplatedRequests.robot
+Resource ../../../libraries/Utils.robot
+Resource ../../../variables/Variables.robot
*** Variables ***
${BGP_VARIABLES_FOLDER} ${CURDIR}/../../../variables/bgpuser/
${COUNT} 200000
${PREFILL} 100000
${COUNT_APP_PEER_PREFIX_COUNT} ${COUNT}
-${CHECK_PERIOD} 1
+${CHECK_PERIOD} 10
${CHECK_PERIOD_APP_PEER_PREFIX_COUNT} ${CHECK_PERIOD}
${REPETITIONS_APP_PEER_PREFIX_COUNT} 1
${BGP_PEER_LOG_LEVEL} info
${BGP_APP_PEER_LOG_LEVEL} info
-${CONTROLLER_LOG_LEVEL} INFO
-${CONTROLLER_BGP_LOG_LEVEL} DEFAULT
+${ODL_LOG_LEVEL} INFO
+${ODL_BGP_LOG_LEVEL} DEFAULT
${BGP_PEER_COMMAND} python play.py --amount 0 --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --${BGP_PEER_LOG_LEVEL}
${BGP_PEER_OPTIONS} &>bgp_peer.log
${BGP_APP_PEER_ID} 10.0.0.10
-${BGP_APP_PEER_INITIAL_COMMAND} python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command post --count ${PREFILL} --prefix 8.0.0.0 --prefixlen 28 --${BGP_APP_PEER_LOG_LEVEL}
-${BGP_APP_PEER_PUT_COMMAND} python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command put --count ${PREFILL} --prefix 8.0.0.0 --prefixlen 28 --${BGP_APP_PEER_LOG_LEVEL}
-${BGP_APP_PEER_DELETE_ALL_COMMAND} python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command delete-all --${BGP_APP_PEER_LOG_LEVEL}
-${BGP_APP_PEER_GET_COMMAND} python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command get --${BGP_APP_PEER_LOG_LEVEL}
+${BGP_APP_PEER_INITIAL_COMMAND} python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command post --count ${PREFILL} --prefix 8.0.0.0 --prefixlen 28 --${BGP_APP_PEER_LOG_LEVEL} --stream=${ODL_STREAM}
+${BGP_APP_PEER_PUT_COMMAND} python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command put --count ${PREFILL} --prefix 8.0.0.0 --prefixlen 28 --${BGP_APP_PEER_LOG_LEVEL} --stream=${ODL_STREAM}
+${BGP_APP_PEER_DELETE_ALL_COMMAND} python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command delete-all --${BGP_APP_PEER_LOG_LEVEL} --stream=${ODL_STREAM}
+${BGP_APP_PEER_GET_COMMAND} python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command get --${BGP_APP_PEER_LOG_LEVEL} --stream=${ODL_STREAM}
${BGP_APP_PEER_OPTIONS} &>bgp_app_peer.log
${TEST_DURATION_MULTIPLIER} 30
${last_prefix_count} -1
+${DEVICE_NAME} controller-config
+${BGP_PEER_NAME} example-bgp-peer
+${RIB_INSTANCE} example-bgp-rib
+${PROTOCOL_OPENCONFIG} ${RIB_INSTANCE}
*** Test Cases ***
Check_For_Empty_Ipv4_Topology_Before_Starting
Reconfigure_ODL_To_Accept_Connection
[Documentation] Configure BGP peer module with initiate-connection set to false.
- ${template_as_string}= BuiltIn.Set_Variable {'NAME': 'example-bgp-peer', 'IP': '${TOOLS_SYSTEM_IP}', 'HOLDTIME': '${HOLDTIME_APP_PEER_PREFIX_COUNT}', 'PEER_PORT': '${BGP_TOOL_PORT}', 'INITIATE': 'false'}
- ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${BGP_VARIABLES_FOLDER}${/}bgp_peer ${template_as_string}
+ &{mapping} Create Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME_APP_PEER_PREFIX_COUNT} PEER_PORT=${BGP_TOOL_PORT}
+ ... INITIATE=false BGP_RIB=${RIB_INSTANCE} PASSIVE_MODE=true BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} RIB_INSTANCE_NAME=${RIB_INSTANCE}
+ TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}${/}bgp_peer mapping=${mapping}
Reconfigure_ODL_To_Accept_BGP_Application_Peer
[Documentation] Configure BGP application peer module.
- ${template_as_string}= BuiltIn.Set_Variable {'NAME': 'example-bgp-peer-app', 'IP': '${BGP_APP_PEER_ID}'}
- ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${BGP_VARIABLES_FOLDER}${/}bgp_application_peer ${template_as_string}
+ &{mapping} Create Dictionary DEVICE_NAME=${DEVICE_NAME} NAME=example-bgp-peer-app RIB_INSTANCE_NAME=${RIB_INSTANCE} IP=${BGP_APP_PEER_ID} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
+ TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}${/}bgp_application_peer mapping=${mapping}
Connect_BGP_Peer
[Documentation] Start BGP peer tool
SSHLibrary.Switch Connection bgp_peer_console
- Start_Console_Tool ${BGP_PEER_COMMAND} ${BGP_PEER_OPTIONS}
- Read_And_Fail_If_Prompt_Is_Seen
+ BGPcliKeywords.Start_Console_Tool ${BGP_PEER_COMMAND} ${BGP_PEER_OPTIONS}
+ BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
BGP_Application_Peer_Prefill_Routes
[Documentation] Start BGP application peer tool and prefill routes.
SSHLibrary.Switch Connection bgp_app_peer_console
- Start_Console_Tool ${BGP_APP_PEER_INITIAL_COMMAND} ${BGP_APP_PEER_OPTIONS}
- Wait_Until_Console_Tool_Finish ${bgp_filling_timeout}
- Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_prefill.log
+ BGPcliKeywords.Start_Console_Tool ${BGP_APP_PEER_INITIAL_COMMAND} ${script_uri_opt} ${BGP_APP_PEER_OPTIONS}
+ BGPcliKeywords.Wait_Until_Console_Tool_Finish ${bgp_filling_timeout}
+ BGPcliKeywords.Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_prefill.log
Wait_For_Ipv4_Topology_Is_Prefilled
[Documentation] Wait until example-ipv4-topology reaches the target prfix count.
Check_Bgp_Peer_Updates_For_Prefilled_Routes
[Documentation] Count the routes introduced by updates.
[Setup] SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
- BuiltIn.Wait Until Keyword Succeeds ${bgp_filling_timeout} 1s Check_File_For_Word_Count bgp_peer.log total_received_nlri_prefix_counter: ${PREFILL} 2
+ ${count} BuiltIn.Wait Until Keyword Succeeds ${bgp_filling_timeout} 3s Check_For_String_In_File bgp_peer.log total_received_nlri_prefix_counter: ${PREFILL}
+ BuiltIn.Log ${count}
BGP_Application_Peer_Introduce_Single_Routes
[Documentation] Start BGP application peer tool and introduce routes.
SSHLibrary.Switch Connection bgp_app_peer_console
- Start_Console_Tool python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command add --count ${remaining_prefixes} --prefix 12.0.0.0 --prefixlen 28 --${BGP_APP_PEER_LOG_LEVEL} ${BGP_APP_PEER_OPTIONS}
- Wait_Until_Console_Tool_Finish ${bgp_filling_timeout}
- Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_singles.log
+ BGPcliKeywords.Start_Console_Tool python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command add --count ${remaining_prefixes} --prefix 12.0.0.0 --prefixlen 28 --${BGP_APP_PEER_LOG_LEVEL} --stream=${ODL_STREAM} ${script_uri_opt} ${BGP_APP_PEER_OPTIONS}
+ BGPcliKeywords.Wait_Until_Console_Tool_Finish ${bgp_filling_timeout}
+ BGPcliKeywords.Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_singles.log
Wait_For_Ipv4_Topology_Is_Filled
[Documentation] Wait until example-ipv4-topology reaches the target prfix count.
Check_Bgp_Peer_Updates_For_All_Routes
[Documentation] Count the routes introduced by updates.
[Setup] SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
- BuiltIn.Wait Until Keyword Succeeds ${bgp_filling_timeout} 1s Check_File_For_Word_Count bgp_peer.log total_received_nlri_prefix_counter: ${COUNT_APP_PEER_PREFIX_COUNT} 2
+ BuiltIn.Wait Until Keyword Succeeds ${bgp_filling_timeout} 3s Check_For_String_In_File bgp_peer.log total_received_nlri_prefix_counter: ${COUNT_APP_PEER_PREFIX_COUNT}
Disconnect_BGP_Peer
[Documentation] Stop BGP peer tool
SSHLibrary.Switch Connection bgp_peer_console
- Stop_Console_Tool
- Store_File_To_Workspace bgp_peer.log bgp_peer_reconnect.log
+ BGPcliKeywords.Stop_Console_Tool
+ BGPcliKeywords.Store_File_To_Workspace bgp_peer.log bgp_peer_reconnect.log
Reconnect_BGP_Peer
[Documentation] Start BGP peer tool
SSHLibrary.Switch Connection bgp_peer_console
- Start_Console_Tool ${BGP_PEER_COMMAND} ${BGP_PEER_OPTIONS}
- Read_And_Fail_If_Prompt_Is_Seen
+ BGPcliKeywords.Start_Console_Tool ${BGP_PEER_COMMAND} ${BGP_PEER_OPTIONS}
+ BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
Check_Bgp_Peer_Updates_For_Reintroduced_Routes
[Documentation] Count the routes introduced by updates.
[Setup] SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
- BuiltIn.Wait Until Keyword Succeeds ${bgp_filling_timeout} 1s Check_File_For_Word_Count bgp_peer.log total_received_nlri_prefix_counter: ${COUNT_APP_PEER_PREFIX_COUNT} 2
+ BuiltIn.Wait Until Keyword Succeeds ${bgp_filling_timeout} 3s Check_For_String_In_File bgp_peer.log total_received_nlri_prefix_counter: ${COUNT_APP_PEER_PREFIX_COUNT}
BGP_Application_Peer_Delete_All_Routes
[Documentation] Start BGP application peer tool and delete all routes.
SSHLibrary.Switch Connection bgp_app_peer_console
- Start_Console_Tool ${BGP_APP_PEER_DELETE_ALL_COMMAND} ${BGP_APP_PEER_OPTIONS}
- Wait_Until_Console_Tool_Finish ${bgp_emptying_timeout}
- Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_delete_all.log
+ BGPcliKeywords.Start_Console_Tool ${BGP_APP_PEER_DELETE_ALL_COMMAND} --stream=${ODL_STREAM} ${script_uri_opt} ${BGP_APP_PEER_OPTIONS}
+ BGPcliKeywords.Wait_Until_Console_Tool_Finish ${bgp_emptying_timeout}
+ BGPcliKeywords.Store_File_To_Workspace bgp_app_peer.log bgp_app_peer_delete_all.log
Wait_For_Stable_Topology_After_Deletion
[Documentation] Wait until example-ipv4-topology becomes stable again.
Check_Bgp_Peer_Updates_For_Prefix_Withdrawals
[Documentation] Count the routes withdrawn by updates.
[Setup] SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
- BuiltIn.Wait Until Keyword Succeeds ${bgp_emptying_timeout} 1s Check_File_For_Word_Count bgp_peer.log total_received_withdrawn_prefix_counter: ${COUNT_APP_PEER_PREFIX_COUNT} 2
+ BuiltIn.Wait Until Keyword Succeeds ${bgp_emptying_timeout} 3s Check_For_String_In_File bgp_peer.log total_received_withdrawn_prefix_counter: ${COUNT_APP_PEER_PREFIX_COUNT}
Stop_BGP_Peer
[Documentation] Stop BGP peer tool
SSHLibrary.Switch Connection bgp_peer_console
- Stop_Console_Tool
- Store_File_To_Workspace bgp_peer.log bgp_peer_reconnect.log
+ BGPcliKeywords.Stop_Console_Tool
+ BGPcliKeywords.Store_File_To_Workspace bgp_peer.log bgp_peer_reconnect.log
Delete_Bgp_Peer_Configuration
[Documentation] Revert the BGP configuration to the original state: without any configured peers.
- ${template_as_string}= BuiltIn.Set_Variable {'NAME': 'example-bgp-peer'}
- ConfigViaRestconf.Delete_Xml_Template_Folder_Config_Via_Restconf ${BGP_VARIABLES_FOLDER}${/}bgp_peer ${template_as_string}
+ &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} BGP_NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
+ TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}${/}bgp_peer mapping=${mapping}
Delete_Bgp_Application_Peer_Configuration
[Documentation] Revert the BGP configuration to the original state: without any configured peers.
- ${template_as_string}= BuiltIn.Set_Variable {'NAME': 'example-bgp-peer-app'}
- ConfigViaRestconf.Delete_Xml_Template_Folder_Config_Via_Restconf ${BGP_VARIABLES_FOLDER}${/}bgp_application_peer ${template_as_string}
-
-Check_Bug_4791
- [Documentation] Check controller's log for errors
- Check Karaf Log File Does Not Have Messages ${ODL_SYSTEM_IP} Failed to send message Update
+ &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} NAME=example-bgp-peer-app IP=${BGP_APP_PEER_ID} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
+ TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}${/}bgp_application_peer mapping=${mapping}
*** Keywords ***
Setup_Everything
[Documentation] Setup imported resources, SSH-login to tools system,
... create HTTP session, put Python tool to tools system.
SetupUtils.Setup_Utils_For_Setup_And_Teardown
- ConfigViaRestconf.Setup_Config_Via_Restconf
+ TemplatedRequests.Create_Default_Session
PrefixCounting.PC_Setup
SSHLibrary.Set_Default_Configuration prompt=${TOOLS_SYSTEM_PROMPT}
- RequestsLibrary.Create_Session operational http://${ODL_SYSTEM_IP}:${RESTCONFPORT}${OPERATIONAL_API} auth=${AUTH}
+ RequestsLibrary.Create_Session operational http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} timeout=125 max_retries=0
# TODO: Do not include slash in ${OPERATIONAL_TOPO_API}, having it typed here is more readable.
# TODO: Alternatively, create variable in Variables which starts with http.
# Both TODOs would probably need to update every suite relying on current Variables.
Open_BGP_Peer_Console
Open_BGP_Aplicationp_Peer_Console
+ SSHKeywords.Require_Python
+ SSHKeywords.Assure_Library_Ipaddr target_dir=.
SSHLibrary.Put_File ${CURDIR}/../../../../tools/fastbgp/play.py
SSHLibrary.Put_File ${CURDIR}/../../../../tools/fastbgp/bgp_app_peer.py
- SSHLibrary.Put_File ${CURDIR}/../../../../tools/fastbgp/ipv4-routes-template.xml
+ SSHLibrary.Put_File ${CURDIR}/../../../../tools/fastbgp/ipv4-routes-template.xml*
# Calculate the timeout value based on how many routes are going to be pushed.
# The offset (20) is set for keeping reasonable timeout for low COUNT values.
${timeout} = BuiltIn.Evaluate ${TEST_DURATION_MULTIPLIER} * ${COUNT_APP_PEER_PREFIX_COUNT} * 3.0 / 10000 + 20
Builtin.Set_Suite_Variable ${bgp_emptying_timeout} ${bgp_filling_timeout*3.0/4}
${result} = BuiltIn.Evaluate str(int(${COUNT_APP_PEER_PREFIX_COUNT}) - int(${PREFILL}))
Builtin.Set_Suite_Variable ${remaining_prefixes} ${result}
- KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set ${CONTROLLER_LOG_LEVEL}
- KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set ${CONTROLLER_BGP_LOG_LEVEL} org.opendaylight.bgpcep
- KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set ${CONTROLLER_BGP_LOG_LEVEL} org.opendaylight.protocol
+ KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set ${ODL_LOG_LEVEL}
+ KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set ${ODL_BGP_LOG_LEVEL} org.opendaylight.bgpcep
+ KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set ${ODL_BGP_LOG_LEVEL} org.opendaylight.protocol
+ ${script_uri_opt}= Set Variable --uri config/bgp-rib:application-rib/${BGP_APP_PEER_ID}/tables/bgp-types:ipv4-address-family/bgp-types:unicast-subsequent-address-family/
+ BuiltIn.Set_Suite_Variable ${script_uri_opt}
Teardown_Everything
[Documentation] Make sure Python tool was killed and tear down imported Resources.
SSHLibrary.Switch Connection bgp_peer_console
KillPythonTool.Search_And_Kill_Remote_Python 'play\.py'
KillPythonTool.Search_And_Kill_Remote_Python 'bgp_app_peer\.py'
- ConfigViaRestconf.Teardown_Config_Via_Restconf
+ BuiltIn.Run_Keyword_And_Ignore_Error Utils.Get_Sysstat_Statistics
RequestsLibrary.Delete_All_Sessions
SSHLibrary.Close_All_Connections
Open_BGP_Peer_Console
[Documentation] Create a session for BGP peer.
SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} alias=bgp_peer_console
- Utils.Flexible_Mininet_Login
+ SSHKeywords.Flexible_Mininet_Login
Open_BGP_Aplicationp_Peer_Console
[Documentation] Create a session for BGP peer.
SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} alias=bgp_app_peer_console
- Utils.Flexible_Mininet_Login
+ SSHKeywords.Flexible_Mininet_Login
+
+Check_For_String_In_File
+ [Arguments] ${file_name} ${string} ${threshold}=2
+ [Documentation] Check file for ${string} and returns number of occurences
+ ${matches} = SSHLibrary.Execute_Command grep -c '${string}' '${file_name}'
+ ${count} = Convert To Integer ${matches}
+ BuiltIn.Should_Be_True ${count} >= ${threshold}