Include needed Assure_* keywords in BGP tests
[integration/test.git] / csit / suites / bgpcep / bgpingest / bgp_app_peer_prefixcount.robot
index 891a20bb720cc7e380c67cc7b34c667475cefa11..b6a8e90394b8252d6f1e3bd18228f3803fe91ab7 100644 (file)
@@ -26,18 +26,20 @@ Documentation     BGP performance of ingesting from 1 BGP application peer
 ...               Bug 4791 - BGPSessionImpl: Failed to send message Update logged even all UPDATE mesages received by iBGP peer
 Suite Setup       Setup_Everything
 Suite Teardown    Teardown_Everything
-Test Setup        Setup_Test_With_Logging_And_Without_Fast_Failing
-Test Teardown     FailFast.Start_Failing_Fast_If_This_Failed
+Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
+Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed
 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          ${CURDIR}/../../../libraries/SSHKeywords.robot
 
 *** Variables ***
 ${BGP_VARIABLES_FOLDER}    ${CURDIR}/../../../variables/bgpuser/
@@ -95,13 +97,11 @@ BGP_Application_Peer_Prefill_Routes
 Wait_For_Ipv4_Topology_Is_Prefilled
     [Documentation]    Wait until example-ipv4-topology reaches the target prfix count.
     BuiltIn.Wait Until Keyword Succeeds    ${bgp_filling_timeout}    10s    PrefixCounting.Check_Ipv4_Topology_Count    ${PREFILL}
-    [Teardown]    Report_Failure_Due_To_Bug    4689
 
 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
-    [Teardown]    Report_Failure_Due_To_Bug    4689
 
 BGP_Application_Peer_Introduce_Single_Routes
     [Documentation]    Start BGP application peer tool and introduce routes.
@@ -113,13 +113,11 @@ BGP_Application_Peer_Introduce_Single_Routes
 Wait_For_Ipv4_Topology_Is_Filled
     [Documentation]    Wait until example-ipv4-topology reaches the target prfix count.
     BuiltIn.Wait Until Keyword Succeeds    ${bgp_filling_timeout}    10s    PrefixCounting.Check_Ipv4_Topology_Count    ${COUNT_APP_PEER_PREFIX_COUNT}
-    [Teardown]    Report_Failure_Due_To_Bug    4689
 
 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
-    [Teardown]    Report_Failure_Due_To_Bug    4689
 
 Disconnect_BGP_Peer
     [Documentation]    Stop BGP peer tool
@@ -135,6 +133,7 @@ Reconnect_BGP_Peer
 
 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
 
 BGP_Application_Peer_Delete_All_Routes
@@ -156,7 +155,6 @@ 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
-    [Teardown]    Report_Failure_Due_To_Bug    4689
 
 Stop_BGP_Peer
     [Documentation]    Stop BGP peer tool
@@ -174,10 +172,9 @@ Delete_Bgp_Application_Peer_Configuration
     ${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_Controller_Logs
+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
-    [Teardown]    Report_Failure_Due_To_Bug    4791
 
 *** Keywords ***
 Setup_Everything
@@ -193,6 +190,8 @@ Setup_Everything
     # 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
@@ -225,48 +224,3 @@ 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
-
-Start_Console_Tool
-    [Arguments]    ${command}    ${tool_opt}
-    [Documentation]    Start the tool ${command} ${tool_opt}
-    BuiltIn.Log    ${command}
-    ${output}=    SSHLibrary.Write    ${command} ${tool_opt}
-    BuiltIn.Log    ${output}
-
-Wait_Until_Console_Tool_Finish
-    [Arguments]    ${timeout}
-    [Documentation]    Wait ${timeout} for the tool exit.
-    BuiltIn.Wait Until Keyword Succeeds    ${timeout}    1s    SSHLibrary.Read Until Prompt
-
-Stop_Console_Tool
-    [Documentation]    Stop the tool if still running.
-    Utils.Write_Bare_Ctrl_C
-    ${output}=    SSHLibrary.Read    delay=1s
-    BuiltIn.Log    ${output}
-
-Read_And_Fail_If_Prompt_Is_Seen
-    [Documentation]    Try to read SSH to see prompt, but expect to see no prompt within SSHLibrary's timeout.
-    ${passed}=    BuiltIn.Run_Keyword_And_Return_Status    BuiltIn.Run_Keyword_And_Expect_Error    No match found for '${TOOLS_SYSTEM_PROMPT}' in *.    Read_Text_Before_Prompt
-    BuiltIn.Return_From_Keyword_If    ${passed}
-    BGPSpeaker.Dump_BGP_Speaker_Logs
-    Builtin.Fail    The prompt was seen but it was not expected yet
-
-Read_Text_Before_Prompt
-    [Documentation]    Log text gathered by SSHLibrary.Read_Until_Prompt.
-    ...    This needs to be a separate keyword just because how Read_And_Fail_If_Prompt_Is_Seen is implemented.
-    ${text}=    SSHLibrary.Read_Until_Prompt
-    BuiltIn.Log    ${text}
-
-Store_File_To_Workspace
-    [Arguments]    ${source_file_name}    ${target_file_name}
-    [Documentation]    Store the ${source_file_name} to the workspace as ${target_file_name}.
-    ${output_log}=    SSHLibrary.Execute_Command    cat ${source_file_name}
-    BuiltIn.Log    ${output_log}
-    Create File    ${target_file_name}    ${output_log}
-
-Check_File_For_Word_Count
-    [Arguments]    ${file_name}    ${word}    ${expected_count}
-    [Documentation]    Count ${word} in ${file_name}. Expect ${expected_count} occurence(s)
-    ${output_log}=    SSHLibrary.Execute_Command    grep -o '${word}' ${file_name} | wc -l
-    BuiltIn.Log    ${output_log}
-    BuiltIn.Should_Be_Equal_As_Strings    ${output_log}    ${expected_count}