*** Settings ***
-Documentation Functional test for bgp - graceful-restart
+Documentation Functional test for bgp - graceful-restart
...
-... Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+... Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
...
-... This program and the accompanying materials are made available under the
-... terms of the Eclipse Public License v1.0 which accompanies this distbmution,
-... and is available at http://www.eclipse.org/legal/epl-v10.html
-Suite Setup Start_Suite
-Suite Teardown Stop_Suite
-Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
-Library ../../../libraries/BgpRpcClient.py ${ODL_SYSTEM_IP} 8001 WITH NAME BgpRpcClient1
-Library ../../../libraries/BgpRpcClient.py ${ODL_SYSTEM_IP} 8002 WITH NAME BgpRpcClient2
-Library OperatingSystem
-Library RequestsLibrary
-Library SSHLibrary
-Library String
-Resource ../../../libraries/BGPcliKeywords.robot
-Resource ../../../libraries/BgpOperations.robot
-Resource ../../../libraries/BGPSpeaker.robot
-Resource ../../../libraries/SetupUtils.robot
-Resource ../../../libraries/SSHKeywords.robot
-Resource ../../../libraries/TemplatedRequests.robot
-Resource ../../../variables/Variables.robot
+... This program and the accompanying materials are made available under the
+... terms of the Eclipse Public License v1.0 which accompanies this distbmution,
+... and is available at http://www.eclipse.org/legal/epl-v10.html
+
+Library ../../../libraries/BgpRpcClient.py ${ODL_SYSTEM_IP} 8001 WITH NAME BgpRpcClient1
+Library ../../../libraries/BgpRpcClient.py ${ODL_SYSTEM_IP} 8002 WITH NAME BgpRpcClient2
+Library OperatingSystem
+Library RequestsLibrary
+Library SSHLibrary
+Library String
+Resource ../../../libraries/BGPcliKeywords.robot
+Resource ../../../libraries/BgpOperations.robot
+Resource ../../../libraries/BGPSpeaker.robot
+Resource ../../../libraries/SetupUtils.robot
+Resource ../../../libraries/SSHKeywords.robot
+Resource ../../../libraries/TemplatedRequests.robot
+Resource ../../../variables/Variables.robot
+
+Suite Setup Start_Suite
+Suite Teardown Stop_Suite
+Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
+
*** Variables ***
-${HOLDTIME} 180
-${RIB_NAME} example-bgp-rib
-${CONFIG_SESSION} config-session
-${PLAY_SCRIPT} ${CURDIR}/../../../../tools/fastbgp/play.py
-${GR_FOLDER} ${CURDIR}/../../../variables/bgpfunctional/graceful_restart
-${PEER1_AS} 65000
-${PEER2_AS} 65001
-${PEER1_IP} 127.0.0.2
-${PEER2_IP} 127.0.0.3
-${PEER1_PORT} 8001
-${PEER2_PORT} 8002
-${FIRST_PREFIX} 8.1.0.0
-${SECOND_PREFIX} 8.2.0.0
-${NEXT_HOP} 1.1.1.1
-${PREFIX_LEN} 28
+${HOLDTIME} 180
+${RIB_NAME} example-bgp-rib
+${CONFIG_SESSION} config-session
+${PLAY_SCRIPT} ${CURDIR}/../../../../tools/fastbgp/play.py
+${GR_FOLDER} ${CURDIR}/../../../variables/bgpfunctional/graceful_restart
+${PEER1_AS} 65000
+${PEER2_AS} 65001
+${PEER1_IP} 127.0.0.2
+${PEER2_IP} 127.0.0.3
+${PEER1_PORT} 8001
+${PEER2_PORT} 8002
+${FIRST_PREFIX} 8.1.0.0
+${SECOND_PREFIX} 8.2.0.0
+${NEXT_HOP} 1.1.1.1
+${PREFIX_LEN} 28
+
*** Test Cases ***
Verify_Empty_Rib_After_Graceful_Restart_Timer_Expired
Verify_Routes dir=empty_ipv6_route interval=1s
[Teardown] Teardown_TC gr_tc6.out
+
*** Keywords ***
Start_Suite
[Documentation] Initialize SetupUtils. Suite setup keyword.
... Start two bgp peers, each with their default values, and verify their respective routes
... are present in loc-rib, than kill the first bgp speaker (effectively simulating graceful-restart)
SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
- Start_Bgp_Peer prefix=${SECOND_PREFIX} myip=${PEER2_IP} port=${PEER2_PORT} as_number=${PEER2_AS} log_name=gr_tc3.out
+ Start_Bgp_Peer
+ ... prefix=${SECOND_PREFIX}
+ ... myip=${PEER2_IP}
+ ... port=${PEER2_PORT}
+ ... as_number=${PEER2_AS}
+ ... log_name=gr_tc3.out
Start_Bgp_Peer multiple=${EMPTY}
Verify_Routes dir=ipv4_1_1
BGPSpeaker.Kill_BGP_Speaker
Verify_Routes dir=ipv6_1
Teardown_TC
- [Arguments] ${log_name}=play.py.out
[Documentation] In case Test Case failed to close Python Speakers, we close them.
... Wait until there are no routes present in loc-rib.
+ [Arguments] ${log_name}=play.py.out
Kill_Talking_BGP_Speakers ${log_name}
Verify_Routes dir=empty_route retry=10x
Verify_Routes dir=empty_ipv6_route interval=1s
Verify_Routes
- [Arguments] ${dir}=empty_route ${retry}=5x ${interval}=3s
[Documentation] Verify route based on how many routes are present in rib.
- BuiltIn.Wait_Until_Keyword_Succeeds ${retry} ${interval} TemplatedRequests.Get_As_Json_Templated ${GR_FOLDER}${/}${dir} session=${CONFIG_SESSION} verify=True
+ [Arguments] ${dir}=empty_route ${retry}=5x ${interval}=3s
+ BuiltIn.Wait_Until_Keyword_Succeeds
+ ... ${retry}
+ ... ${interval}
+ ... TemplatedRequests.Get_As_Json_Templated
+ ... ${GR_FOLDER}${/}${dir}
+ ... session=${CONFIG_SESSION}
+ ... verify=True
Verify_Hex_Message
- [Arguments] ${file_dir} ${peer}=${PEER1_IP} ${file_name}=${file_dir}.hex
[Documentation] Verify hex message advertised from odl.
+ [Arguments] ${file_dir} ${peer}=${PEER1_IP} ${file_name}=${file_dir}.hex
${expected} = TemplatedRequests.Resolve_Text_From_Template_File ${GR_FOLDER}${/}${file_dir} ${file_name}
${actual} = BuiltIn.Wait_Until_Keyword_Succeeds 5x 3s Get_Hex_Message peer=${peer}
BgpOperations.Verify_Two_Hex_Messages_Are_Equal ${expected} ${actual}
Get_Hex_Message
- [Arguments] ${peer}=${PEER1_IP}
[Documentation] Gets open message in case of first peer, and update message in case of second peer.
- ${hex} = BuiltIn.Run_Keyword_If "${peer}" == "${PEER1_IP}" BgpRpcClient1.play_get what=open
- ... ELSE BgpRpcClient2.play_get
+ [Arguments] ${peer}=${PEER1_IP}
+ IF "${peer}" == "${PEER1_IP}"
+ ${hex} = BgpRpcClient1.play_get what=open
+ ELSE
+ ${hex} = BgpRpcClient2.play_get
+ END
BuiltIn.Should_Not_Be_Equal ${hex} ${EMPTY}
- [Return] ${hex}
+ RETURN ${hex}
Start_Bgp_Peer
+ [Documentation] Starts bgp peer.
[Arguments] ${prefix}=${FIRST_PREFIX} ${amount}=1 ${myip}=${PEER1_IP} ${port}=${PEER1_PORT} ${as_number}=${PEER1_AS} ${grace}=0
... ${log_name}=play.py.out ${multiple}=& ${ipv6}=${EMPTY}
- [Documentation] Starts bgp peer.
- ${command} = BuiltIn.Set_Variable python3 play.py${ipv6} --firstprefix ${prefix} --prefixlen ${PREFIX_LEN} --amount ${amount} --myip ${myip} --myport ${BGP_TOOL_PORT} --peerip ${ODL_SYSTEM_IP} --peerport ${ODL_BGP_PORT} --port ${port} --usepeerip --nexthop ${NEXT_HOP} --asnumber ${as_number} --debug --grace ${grace} --wfr 1 &> ${log_name} ${multiple}
+ ${command} = BuiltIn.Set_Variable
+ ... python3 play.py${ipv6} --firstprefix ${prefix} --prefixlen ${PREFIX_LEN} --amount ${amount} --myip ${myip} --myport ${BGP_TOOL_PORT} --peerip ${ODL_SYSTEM_IP} --peerport ${ODL_BGP_PORT} --port ${port} --usepeerip --nexthop ${NEXT_HOP} --asnumber ${as_number} --debug --grace ${grace} --wfr 1 &> ${log_name} ${multiple}
BuiltIn.Log ${command}
${output} = SSHLibrary.Write ${command}
Kill_Talking_BGP_Speakers
- [Arguments] ${log_name}=play.py.out
[Documentation] Save play.py log into workspace, attempt to dump speaker logs into robot log.
... Abort all Python speakers.
+ [Arguments] ${log_name}=play.py.out
BuiltIn.Run_Keyword_And_Ignore_Error BGPcliKeywords.Store_File_To_Workspace ${log_name} ${log_name}.log
BuiltIn.Run_Keyword_And_Ignore_Error BGPSpeaker.Dump_BGP_Speaker_Logs
BGPSpeaker.Kill_All_BGP_Speakers
Configure_BGP_Peers
- [Arguments] ${folder}=${EMPTY}
[Documentation] Configure two eBGP peers with graceful-restart enabled
- &{mapping} BuiltIn.Create_Dictionary IP=${PEER1_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT} AS_NUMBER=${PEER1_AS} BGP_RIB=${RIB_NAME}
- TemplatedRequests.Put_As_Xml_Templated ${GR_FOLDER}${/}${folder}peers mapping=${mapping} session=${CONFIG_SESSION}
- &{mapping} BuiltIn.Create_Dictionary IP=${PEER2_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT} AS_NUMBER=${PEER2_AS} BGP_RIB=${RIB_NAME}
- TemplatedRequests.Put_As_Xml_Templated ${GR_FOLDER}${/}${folder}peers mapping=${mapping} session=${CONFIG_SESSION}
+ [Arguments] ${folder}=${EMPTY}
+ &{mapping} = BuiltIn.Create_Dictionary
+ ... IP=${PEER1_IP}
+ ... HOLDTIME=${HOLDTIME}
+ ... PEER_PORT=${BGP_TOOL_PORT}
+ ... AS_NUMBER=${PEER1_AS}
+ ... BGP_RIB=${RIB_NAME}
+ TemplatedRequests.Put_As_Xml_Templated
+ ... ${GR_FOLDER}${/}${folder}peers
+ ... mapping=${mapping}
+ ... session=${CONFIG_SESSION}
+ &{mapping} = BuiltIn.Create_Dictionary
+ ... IP=${PEER2_IP}
+ ... HOLDTIME=${HOLDTIME}
+ ... PEER_PORT=${BGP_TOOL_PORT}
+ ... AS_NUMBER=${PEER2_AS}
+ ... BGP_RIB=${RIB_NAME}
+ TemplatedRequests.Put_As_Xml_Templated
+ ... ${GR_FOLDER}${/}${folder}peers
+ ... mapping=${mapping}
+ ... session=${CONFIG_SESSION}
Delete_Bgp_Peers_Configuration
[Documentation] Revert the BGP configuration to the original state: without any configured peers.
- &{mapping} BuiltIn.Create_Dictionary IP=${PEER1_IP} BGP_RIB=${RIB_NAME}
+ &{mapping} = BuiltIn.Create_Dictionary IP=${PEER1_IP} BGP_RIB=${RIB_NAME}
TemplatedRequests.Delete_Templated ${GR_FOLDER}${/}peers mapping=${mapping} session=${CONFIG_SESSION}
- &{mapping} BuiltIn.Create_Dictionary IP=${PEER2_IP} BGP_RIB=${RIB_NAME}
+ &{mapping} = BuiltIn.Create_Dictionary IP=${PEER2_IP} BGP_RIB=${RIB_NAME}
TemplatedRequests.Delete_Templated ${GR_FOLDER}${/}peers mapping=${mapping} session=${CONFIG_SESSION}
Post_Graceful_Restart
- [Arguments] ${ip}=${PEER1_IP}
[Documentation] Post rpc to odl, effectively restarting it.
- &{mapping} BuiltIn.Create_Dictionary IP=${ip} BGP_RIB=${RIB_NAME}
- TemplatedRequests.Post_As_Xml_Templated ${GR_FOLDER}${/}restart mapping=${mapping} session=${CONFIG_SESSION}
+ [Arguments] ${ip}=${PEER1_IP}
+ &{mapping} = BuiltIn.Create_Dictionary IP=${ip} BGP_RIB=${RIB_NAME}
+ TemplatedRequests.Post_As_Xml_Templated
+ ... ${GR_FOLDER}${/}restart
+ ... mapping=${mapping}
+ ... session=${CONFIG_SESSION}