--- /dev/null
+*** Settings ***
+Documentation Robot keyword library (Resource) for handling the GoBgp tool.
+...
+... Copyright (c) 2020 Lumina Networks and others. 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 distribution,
+... and is available at http://www.eclipse.org/legal/epl-v10.html
+...
+...
+... This library assumes that a SSH connection exists (and is switched to)
+... to a Linux machine (usualy TOOLS_SYSTEM) where the GoBgp should be run.
+...
+Library Process
+Library SSHLibrary
+Resource ${CURDIR}/BGPcliKeywords.robot
+Resource ${CURDIR}/RemoteBash.robot
+Resource ${CURDIR}/SSHKeywords.robot
+
+*** Variables ***
+${GOBGP_KILL_COMMAND} ps axf | grep gobgp | grep -v grep | awk '{print \"kill -9 \" $1}' | sh
+${GOBGP_EXECUTION_COMMAND} /home/jenkins/gobgpd -l debug -f
+${PEER_CHECK_URL} /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/peer/bgp:%2F%2F
+
+*** Keywords ***
+Start_GoBgp
+ [Arguments] ${cfg_file}
+ [Documentation] Dump the start command into prompt. It assumes that no gobgp is running. For verified
+ ... start use Start_GoBgp_And_Verify_Connected keyword.
+ ${start_cmd}= ${GOBGP_EXECUTION_COMMAND} /home/jenkins/${cfg_file}
+ BuiltIn.Log ${start_cmd}
+ ${output}= SSHLibrary.Write ${start_cmd}
+ BuiltIn.Log ${output}
+
+Stop_GoBgp
+ [Documentation] Stops the GoBgp by sending ctrl+c
+ ${output}= SSHLibrary.Read
+ BuiltIn.Log ${output}
+ RemoteBash.Write_Bare_Ctrl_C
+ ${output}= SSHLibrary.Read_Until_Prompt
+ BuiltIn.Log ${output}
+
+Stop_All_GoBgps
+ [Documentation] Sends kill command to stop all Gobgps running
+ ${output} SSHLibrary.Read
+ BuiltIn.Log ${output}
+ ${output} SSHLibrary.Write ${GOBGP_KILL_COMMAND}
+ BuiltIn.Log ${output}
+
+Start_GoBgp_And_Verify_Connected
+ [Arguments] ${cfg_file} ${session} ${gobgp_ip} ${connection_retries}=${3}
+ [Documentation] Starts the GoBgp and verifies its connection. The verification is done by checking the presence
+ ... of the peer in the bgp rib. [Gobgp at times might take more time, hence the loop]
+ Start_GoBgp ${cfg_file}
+ ${status} ${value}= BuiltIn.Run_Keyword_And_Ignore_Error BuiltIn.Wait_Until_Keyword_Succeeds ${connection_retries}x 15s
+ ... Verify_GoBgps_Connection ${session} ${gobgp_ip} connected=${True}
+ BuiltIn.Run_Keyword_Unless "${status}" == "PASS" Stop_GoBgp
+ BuiltIn.Return_From_Keyword_If "${status}" == "PASS"
+
+Verify_GoBgps_Connection
+ [Arguments] ${session} ${gobgp_ip}=${TOOLS_SYSTEM_IP} ${connected}=${True}
+ [Documentation] Checks peer presence in operational datastore
+ ${exp_status_code}= BuiltIn.Set_Variable_If ${connected} ${ALLOWED_STATUS_CODES} ${DELETED_STATUS_CODES}
+ ${rsp}= RequestsLibrary.Get Request ${session} ${PEER_CHECK_URL}${gobgp_ip}
+ BuiltIn.Log ${rsp.content}
+ BuiltIn.Should_Be_Equal_As_Numbers ${exp_status_code} ${rsp.status_code}
--- /dev/null
+*** Settings ***
+Documentation Functional test for ipv6 connection with bgp.
+...
+... Copyright (c) 2020 Lumina Networks 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 distribution,
+... and is available at http://www.eclipse.org/legal/epl-v10.html
+...
+... This suite tests simple connection between one ibgp peer (goabgp) and Odl.
+... Peer is configured with ipv6, and gobgp connectes to odl via ipv6.
+Suite Setup Start_Suite
+Suite Teardown Stop_Suite
+Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
+Library RequestsLibrary
+Library SSHLibrary
+Resource ../../../variables/Variables.robot
+Resource ../../../libraries/BGPcliKeywords.robot
+Resource ../../../libraries/GoBgpLib.robot
+Resource ../../../libraries/SetupUtils.robot
+Resource ../../../libraries/SSHKeywords.robot
+Resource ../../../libraries/TemplatedRequests.robot
+
+*** Variables ***
+${BGP_VAR_FOLDER} ${CURDIR}/../../../variables/bgpfunctional/ipv6
+${GOBGP_FOLDER} ${CURDIR}/../../../variables/bgpfunctional/gobgp
+${CONFIG_SESSION} config-session
+${GOBGP_CFG} gobgp.cfg
+${GOBGP_LOG} gobgp.log
+${HOLDTIME} 180
+${RIB_INSTANCE} example-bgp-rib
+${GOBGP_BINARY_URL} https://github.com/osrg/gobgp/releases/download/v2.18.0/gobgp_2.18.0_linux_386.tar.gz
+${FILE_NAME} gobgp_2.18.0_linux_386.tar.gz
+
+*** Test Cases ***
+Reconfigure_ODL_To_Accept_Connections
+ [Documentation] Configure BGP peer modules with initiate-connection set to false with short ipv6 address.
+ &{mapping} Create Dictionary IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT} INITIATE=false BGP_RIB=${RIB_INSTANCE}
+ ... PASSIVE_MODE=true BGP_RIB_OPENCONFIG=${RIB_INSTANCE} RIB_INSTANCE_NAME=${RIB_INSTANCE}
+ TemplatedRequests.Put_As_Xml_Templated ${BGP_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
+
+Start_Gobgp
+ [Tags] critical
+ ${cmd}= ${GOBGP_CFG} > ${GOBGP_LOG}
+ GoBgpLib.Start_GoBgp_And_Verify_Connected ${cmd} ${CONFIG_SESSION} ${TOOLS_SYSTEM_IP}
+
+Delete_Bgp_Peer_Configuration
+ [Documentation] Revert the BGP configuration to the original state: without any configured peers.
+ &{mapping} Create Dictionary IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT} INITIATE=false BGP_RIB=${RIB_INSTANCE}
+ ... PASSIVE_MODE=true BGP_RIB_OPENCONFIG=${RIB_INSTANCE} RIB_INSTANCE_NAME=${RIB_INSTANCE}
+ TemplatedRequests.Delete_Templated ${BGP_VAR_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION}
+
+Stop_All_Gobgps
+ [Documentation] Save exabgp logs as exaipv6.log, and stop exabgp with ctrl-c bash signal
+ BGPcliKeywords.Store_File_To_Workspace ${GOBGP_LOG} ${GOBGP_LOG}
+ GoBgpLib.Stop_GoBgp
+
+*** Keywords ***
+Start_Suite
+ [Documentation] Suite setup keyword.
+ SetupUtils.Setup_Utils_For_Setup_And_Teardown
+ ${tools_system_conn_id}= SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
+ Builtin.Set_Suite_Variable ${tools_system_conn_id}
+ SSHKeywords.Flexible_Mininet_Login ${TOOLS_SYSTEM_USER}
+ RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
+ Upload_Config_Files
+ Download_Gobgp_Binary
+
+Stop_Suite
+ [Documentation] Suite teardown keyword
+ SSHLibrary.Close_All_Connections
+ RequestsLibrary.Delete_All_Sessions
+ BuiltIn.Run Keyword And Ignore Error GoBgpLib.Stop_GoBgp
+
+Upload_Config_Files
+ [Documentation] Uploads gobgp config files
+ SSHLibrary.Put_File ${GOBGP_FOLDER}/${GOBGP_CFG} .
+ @{cfgfiles}= SSHLibrary.List_Files_In_Directory . *.cfg
+ FOR ${cfgfile} IN @{cfgfiles}
+ SSHLibrary.Execute_Command sed -i -e 's/GOBGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
+ SSHLibrary.Execute_Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
+ SSHLibrary.Execute_Command sed -i -e 's/ROUTERID/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
+ SSHLibrary.Execute_Command sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
+ SSHLibrary.Execute_Command sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
+ ${stdout}= SSHLibrary.Execute_Command cat ${cfgfile}
+ Log ${stdout}
+ END
+
+Download_Gobgp_Binary
+ [Documentation] Downloads gobgp binary and untar the binary zip file
+ SSHKeywords.Open_Connection_To_Tools_System ${TOOLS_SYSTEM_IP}
+ SSHLibrary.Execute Command wget ${GOBGP_BINARY_URL}
+ SSHLibrary.File Should Exist ./${FILE_NAME}
+ SSHLibrary.Execute Command tar -xzf ${FILE_NAME}