Create common resource for handling CLI tools
[integration/test.git] / csit / suites / bgpcep / bgpuser / bgp_app_peer_basic.robot
index ff13ba4dfc6de72f3d0be6fc222a4c9e6213c4b0..7aca78e9a279180446be6419591054576902a6f1 100644 (file)
@@ -8,12 +8,45 @@ Documentation     Basic tests for BGP application peer.
 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
 ...
 ...               Test suite performs basic BGP functional test cases for
-...               BGP application peer.
+...               BGP application peer operations and checks for IP4 topology updates
+...               and updates towards BGP peer as follows:
+...
+...               Test case 1: Initial BGP peer connection with pre-filled topology (Bug 4714),
+...               POST and simple DELETE requests used.
+...               BGP_Application_Peer_Post_3_Initial_Routes,
+...               Check_Example-IPv4-Topology_Is_Filled_With_3_Routes,
+...               Connect_BGP_Peer,
+...               BGP_Peer_Check_Incomming_Updates_For_3_Introduced_Prefixes,
+...               BGP_Application_Peer_Delete_3_Initial_Routes,
+...               Check_Example-IPv4-Topology_Is_Empty,
+...               Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes,
+...               Stop_BGP_Peer.
+...
+...               Test case 2: PUT and DELETE all routes requests while BGP peer is connected.
+...               Reconnect_BGP_Peer,
+...               BGP_Application_Peer_Put_3_Routes,
+...               Check_Example-IPv4-Topology_Is_Filled_With_3_Routes,
+...               BGP_Peer_Check_Incomming_Updates_For_3_Introduced_Prefixes,
+...               BGP_Application_Peer_Delete_All_Routes,
+...               Check_Example-IPv4-Topology_Is_Empty,
+...               BGP_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes,
+...               Stop_BGP_Peer.
+...
+...               Test case 3: Repeated BGP peer re-connection with pre-filled topology.
+...               BGP_Application_Peer_Put_3_Routes,
+...               Check_Example-IPv4-Topology_Is_Filled_With_3_Routes,
+...               Reconnect_BGP_Peer_And_Check_Incomming_Updates_For_3_Introduced_Prefixes,
+...               BGP_Application_Peer_Delete_All_Routes,
+...               Check_Example-IPv4-Topology_Is_Empty,
+...               BGP_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes,
+...               Stop_BGP_Peer.
 ...
 ...               Brief description how to configure BGP application peer and
 ...               how to use restconf application peer interface:
 ...               https://wiki.opendaylight.org/view/BGP_LS_PCEP:User_Guide#BGP_Application_Peer
 ...               https://wiki.opendaylight.org/view/BGP_LS_PCEP:Programmer_Guide#BGP
+...               Covered bugs:
+...               Bug 4714 - No routes from loc-rib are advertised to newly connected peer
 Suite Setup       Setup_Everything
 Suite Teardown    Teardown_Everything
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
@@ -24,6 +57,7 @@ Library           RequestsLibrary
 Library           ${CURDIR}/../../../libraries/HsfJson/hsf_json.py
 Variables         ${CURDIR}/../../../variables/Variables.py
 Variables         ${CURDIR}/../../../variables/bgpuser/variables.py    ${TOOLS_SYSTEM_IP}
+Resource          ${CURDIR}/../../../libraries/BGPcliKeywords.robot
 Resource          ${CURDIR}/../../../libraries/BGPSpeaker.robot
 Resource          ${CURDIR}/../../../libraries/ConfigViaRestconf.robot
 Resource          ${CURDIR}/../../../libraries/FailFast.robot
@@ -73,15 +107,6 @@ Check_For_Empty_Example-IPv4-Topology
     [Tags]    critical
     Wait_For_Topology_To_Change_To    ${empty_json}    000_Empty.json    timeout=120s
 
-TC1_Connect_BGP_Peer
-    [Documentation]    Start BGP peer tool
-    [Tags]    critical
-    Switch_To_BGP_Peer_Console
-    Start_Console_Tool    ${BGP_PEER_COMMAND}    ${BGP_PEER_OPTIONS}
-    Read_And_Fail_If_Prompt_Is_Seen
-    Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    0
-    Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received:    0
-
 TC1_BGP_Application_Peer_Post_3_Initial_Routes
     [Documentation]    Start BGP application peer tool and give it ${BGP_APP_PEER_TIMEOUT}
     [Tags]    critical
@@ -95,6 +120,13 @@ TC1_Check_Example-IPv4-Topology_Is_Filled_With_3_Routes
     [Tags]    critical
     Wait_For_Topology_To_Change_To    ${filled_json}    010_Filled.json
 
+TC1_Connect_BGP_Peer
+    [Documentation]    Start BGP peer tool
+    [Tags]    critical
+    Switch_To_BGP_Peer_Console
+    Start_Console_Tool    ${BGP_PEER_COMMAND}    ${BGP_PEER_OPTIONS}
+    Read_And_Fail_If_Prompt_Is_Seen
+
 TC1_BGP_Peer_Check_Incomming_Updates_For_3_Introduced_Prefixes
     [Documentation]    Check incomming updates for new routes
     [Tags]    critical
@@ -104,6 +136,7 @@ TC1_BGP_Peer_Check_Incomming_Updates_For_3_Introduced_Prefixes
     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.16/28    1
     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.32/28    1
     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received:    0
+    [Teardown]    Report_Failure_Due_To_Bug    4714
 
 TC1_BGP_Application_Peer_Delete_3_Initial_Routes
     [Documentation]    Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
@@ -127,6 +160,7 @@ TC1_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes
     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.16/28    1
     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.32/28    1
     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    3
+    [Teardown]    Report_Failure_Due_To_Bug    4714
 
 TC1_Stop_BGP_Peer
     [Documentation]    Stop BGP peer tool
@@ -135,7 +169,7 @@ TC1_Stop_BGP_Peer
     Stop_Console_Tool
     Store_File_To_Workspace    bgp_peer.log    bgp_peer_tc1.log
 
-TC2_Connect_BGP_Peer
+TC2_Reconnect_BGP_Peer
     [Documentation]    Start BGP peer tool
     [Tags]    critical
     Switch_To_BGP_Peer_Console
@@ -314,24 +348,6 @@ Switch_To_BGP_Peer_Console
 Switch_To_BGP_Application_Peer_Console
     SSHLibrary.Switch Connection    bgp_app_peer_console
 
-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}
-
 Wait_For_Topology_To_Change_To
     [Arguments]    ${json_topology}    ${filename}    ${timeout}=10s    ${refresh}=1s
     [Documentation]    Normalize the expected json topology and save it to ${EXPECTED_RESPONSES_FOLDER}.
@@ -365,30 +381,3 @@ Normalize_And_Save_Expected_Json
     OperatingSystem.Create_File    ${directory}${/}${filename}    ${json_normalized}
     # TODO: Should we prepend .json to the filename? When we detect it is not already prepended?
     [Return]    ${json_normalized}
-
-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}