Fix bgpcep-1node-userfeatures tests
[integration/test.git] / csit / libraries / BGPSpeaker.robot
index 053debd06aea0929313a86a45e07ced470d44640..ef2cfa5f1adf5af5ac9129be57cd82cc42d7ded9 100644 (file)
@@ -26,10 +26,10 @@ Documentation     Robot keyword library (Resource) for handling the BGP speaker
 Library           SSHLibrary
 Library           RequestsLibrary
 Resource          RemoteBash.robot
+Resource          ../variables/Variables.robot
 
 *** Variables ***
 ${BGPSpeaker__OUTPUT_LOG}    play.py.out
-${PEER_URL}       /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/peer/bgp:%2F%2F
 
 *** Keywords ***
 Start_BGP_Speaker
@@ -38,7 +38,7 @@ Start_BGP_Speaker
     ...    so it can be dumped into the logs later, when stopping it. This also avoids polluting the
     ...    output seen by "Read Until Prompt" with false propmpts so it won't stop prematurely
     ...    leading to a spurious test failure, messy log content or other misbehavior.
-    ${command} =    BuiltIn.Set_Variable    python play.py ${arguments} &> ${BGPSpeaker__OUTPUT_LOG}
+    ${command} =    BuiltIn.Set_Variable    python3 play.py ${arguments} &> ${BGPSpeaker__OUTPUT_LOG}
     BuiltIn.Log    ${command}
     ${output} =    SSHLibrary.Write    ${command}
 
@@ -55,7 +55,7 @@ Verify_BGP_Speaker_Connection
     [Arguments]    ${session}    ${ip}    ${connected}=${True}
     [Documentation]    Verifies peer's presence in bgp rib.
     ${exp_status_code}    BuiltIn.Set_Variable_If    ${connected}    ${200}    ${404}
-    ${url}    BuiltIn.Set_Variable    ${PEER_URL}${ip}
+    ${url}=    BuiltIn.Set_Variable    ${REST_API}/bgp-rib:bgp-rib/rib=example-bgp-rib/peer=bgp:%2F%2F${ip}?content=nonconfig
     ${response}    RequestsLibrary.Get_Request    ${session}    ${url}
     BuiltIn.Should_Be_Equal_As_Numbers    ${exp_status_code}    ${response.status_code}
     [Return]    ${response.content}
@@ -63,7 +63,7 @@ Verify_BGP_Speaker_Connection
 Start_BGP_Manager
     [Arguments]    ${arguments}
     [Documentation]    Start the BGP manager python utility. Redirect its error output to a log file.
-    ${command}=    BuiltIn.Set_Variable    python play.py ${arguments} &> ${BGPSpeaker__OUTPUT_LOG}
+    ${command}=    BuiltIn.Set_Variable    python3 play.py ${arguments} &> ${BGPSpeaker__OUTPUT_LOG}
     BuiltIn.Log    ${command}
     ${output}=    SSHLibrary.Write    ${command}
 
@@ -86,3 +86,10 @@ Kill_BGP_Speaker
     BuiltIn.Return_From_Keyword_If    '${status}' == 'PASS'
     BuiltIn.Log    ${message}
     BuiltIn.Fail    The prompt was not seen within timeout period.
+
+Kill_All_BGP_Speakers
+    [Documentation]    Kill all play.py processes.
+    ${command}=    BuiltIn.Set_Variable    ps axf | grep play.py | grep -v grep | awk '{print \"kill -9 \" $1}' | sh
+    SSHLibrary.Write    ${command}
+    ${output}=    SSHLibrary.Read_Until_Prompt
+    BuiltIn.Log    ${output}