X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Flibraries%2FGoBgpLib.robot;h=da71866c356a68be06dad4eb1106c2c9f62a0491;hb=2d75130cbe2149eac8a8b874368e9719b0c6441d;hp=62d6c530b547cf52823850add96c8d28d84d6bc2;hpb=fafd41f9186c22dcd639b5bb86de4ba6be578fdc;p=integration%2Ftest.git diff --git a/csit/libraries/GoBgpLib.robot b/csit/libraries/GoBgpLib.robot index 62d6c530b5..da71866c35 100644 --- a/csit/libraries/GoBgpLib.robot +++ b/csit/libraries/GoBgpLib.robot @@ -1,33 +1,35 @@ *** 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 +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 +${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 + *** 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} BuiltIn.Set Variable ${GOBGP_EXECUTION_COMMAND} /home/jenkins/${cfg_file} + [Arguments] ${cfg_file} + ${start_cmd}= BuiltIn.Set Variable ${GOBGP_EXECUTION_COMMAND} /home/jenkins/${cfg_file} BuiltIn.Log ${start_cmd} ${output}= SSHLibrary.Write ${start_cmd} BuiltIn.Log ${output} @@ -42,25 +44,35 @@ Stop_GoBgp Stop_All_GoBgps [Documentation] Sends kill command to stop all Gobgps running - ${output} SSHLibrary.Read + ${output}= SSHLibrary.Read BuiltIn.Log ${output} - ${output} SSHLibrary.Write ${GOBGP_KILL_COMMAND} + ${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] + [Arguments] ${cfg_file} ${session} ${gobgp_ip} ${connection_retries}=${3} 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" + ${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} + IF "${status}" != "PASS" Stop_GoBgp + IF "${status}" == "PASS" RETURN 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} + [Arguments] ${session} ${gobgp_ip}=${TOOLS_SYSTEM_IP} ${connected}=${True} + ${peer_check_url}= BuiltIn.Set_Variable ${REST_API}/bgp-rib:bgp-rib/rib=example-bgp-rib/peer=bgp:%2F%2F + ${exp_status_code}= BuiltIn.Set_Variable_If + ... ${connected} + ... ${ALLOWED_STATUS_CODES} + ... ${DELETED_STATUS_CODES} + ${rsp}= RequestsLibrary.Get Request ${session} ${peer_check_url}${gobgp_ip}?content=nonconfig BuiltIn.Log ${rsp.content} BuiltIn.Should_Be_Equal_As_Numbers ${exp_status_code} ${rsp.status_code}