Bgp ingest app peer fix 43/73143/4
authorTomas Markovic <tomas.markovic@pantheon.tech>
Mon, 18 Jun 2018 15:53:22 +0000 (17:53 +0200)
committerTomas Markovic <tomas.markovic@pantheon.tech>
Tue, 19 Jun 2018 04:27:50 +0000 (06:27 +0200)
Currently, play.py is reporting into the log nlri
prefix counts every 3 seconds.
But the test is checking for the specific count
of occurences of the count in the log, which is 2.
But after 30 minutes, there can be up to 200.

Change-Id: I8a0d6e0c0e4b72f0343b6e086ae94f36300435de
Signed-off-by: Tomas Markovic <tomas.markovic@pantheon.tech>
csit/suites/bgpcep/bgpingest/bgp_app_peer_prefixcount.robot

index cad18db6d9828fbe8db6493bd50a07e1b313ce05..2daebb645e87a95a39d3ea1de74c585d0dd3ac35 100644 (file)
@@ -34,8 +34,6 @@ Force Tags        critical
 Library           SSHLibrary    timeout=10s
 Library           RequestsLibrary
 Resource          ../../../libraries/BGPcliKeywords.robot
-Resource          ../../../libraries/BGPSpeaker.robot
-Resource          ../../../libraries/FailFast.robot
 Resource          ../../../libraries/KarafKeywords.robot
 Resource          ../../../libraries/KillPythonTool.robot
 Resource          ../../../libraries/PrefixCounting.robot
@@ -93,15 +91,15 @@ Reconfigure_ODL_To_Accept_BGP_Application_Peer
 Connect_BGP_Peer
     [Documentation]    Start BGP peer tool
     SSHLibrary.Switch Connection    bgp_peer_console
-    Start_Console_Tool    ${BGP_PEER_COMMAND}    ${BGP_PEER_OPTIONS}
-    Read_And_Fail_If_Prompt_Is_Seen
+    BGPcliKeywords.Start_Console_Tool    ${BGP_PEER_COMMAND}    ${BGP_PEER_OPTIONS}
+    BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
 
 BGP_Application_Peer_Prefill_Routes
     [Documentation]    Start BGP application peer tool and prefill routes.
     SSHLibrary.Switch Connection    bgp_app_peer_console
-    Start_Console_Tool    ${BGP_APP_PEER_INITIAL_COMMAND} ${script_uri_opt}    ${BGP_APP_PEER_OPTIONS}
-    Wait_Until_Console_Tool_Finish    ${bgp_filling_timeout}
-    Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_prefill.log
+    BGPcliKeywords.Start_Console_Tool    ${BGP_APP_PEER_INITIAL_COMMAND} ${script_uri_opt}    ${BGP_APP_PEER_OPTIONS}
+    BGPcliKeywords.Wait_Until_Console_Tool_Finish    ${bgp_filling_timeout}
+    BGPcliKeywords.Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_prefill.log
 
 Wait_For_Ipv4_Topology_Is_Prefilled
     [Documentation]    Wait until example-ipv4-topology reaches the target prfix count.
@@ -110,14 +108,15 @@ Wait_For_Ipv4_Topology_Is_Prefilled
 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
+    ${count}    BuiltIn.Wait Until Keyword Succeeds    ${bgp_filling_timeout}    3s    Check_For_String_In_File    bgp_peer.log    total_received_nlri_prefix_counter: ${PREFILL}
+    BuiltIn.Log    ${count}
 
 BGP_Application_Peer_Introduce_Single_Routes
     [Documentation]    Start BGP application peer tool and introduce routes.
     SSHLibrary.Switch Connection    bgp_app_peer_console
-    Start_Console_Tool    python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command add --count ${remaining_prefixes} --prefix 12.0.0.0 --prefixlen 28 --${BGP_APP_PEER_LOG_LEVEL} --stream=${ODL_STREAM} ${script_uri_opt}    ${BGP_APP_PEER_OPTIONS}
-    Wait_Until_Console_Tool_Finish    ${bgp_filling_timeout}
-    Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_singles.log
+    BGPcliKeywords.Start_Console_Tool    python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command add --count ${remaining_prefixes} --prefix 12.0.0.0 --prefixlen 28 --${BGP_APP_PEER_LOG_LEVEL} --stream=${ODL_STREAM} ${script_uri_opt}    ${BGP_APP_PEER_OPTIONS}
+    BGPcliKeywords.Wait_Until_Console_Tool_Finish    ${bgp_filling_timeout}
+    BGPcliKeywords.Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_singles.log
 
 Wait_For_Ipv4_Topology_Is_Filled
     [Documentation]    Wait until example-ipv4-topology reaches the target prfix count.
@@ -126,31 +125,31 @@ Wait_For_Ipv4_Topology_Is_Filled
 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
+    BuiltIn.Wait Until Keyword Succeeds    ${bgp_filling_timeout}    3s    Check_For_String_In_File    bgp_peer.log    total_received_nlri_prefix_counter: ${COUNT_APP_PEER_PREFIX_COUNT}
 
 Disconnect_BGP_Peer
     [Documentation]    Stop BGP peer tool
     SSHLibrary.Switch Connection    bgp_peer_console
-    Stop_Console_Tool
-    Store_File_To_Workspace    bgp_peer.log    bgp_peer_reconnect.log
+    BGPcliKeywords.Stop_Console_Tool
+    BGPcliKeywords.Store_File_To_Workspace    bgp_peer.log    bgp_peer_reconnect.log
 
 Reconnect_BGP_Peer
     [Documentation]    Start BGP peer tool
     SSHLibrary.Switch Connection    bgp_peer_console
-    Start_Console_Tool    ${BGP_PEER_COMMAND}    ${BGP_PEER_OPTIONS}
-    Read_And_Fail_If_Prompt_Is_Seen
+    BGPcliKeywords.Start_Console_Tool    ${BGP_PEER_COMMAND}    ${BGP_PEER_OPTIONS}
+    BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
 
 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
+    BuiltIn.Wait Until Keyword Succeeds    ${bgp_filling_timeout}    3s    Check_For_String_In_File    bgp_peer.log    total_received_nlri_prefix_counter: ${COUNT_APP_PEER_PREFIX_COUNT}
 
 BGP_Application_Peer_Delete_All_Routes
     [Documentation]    Start BGP application peer tool and delete all routes.
     SSHLibrary.Switch Connection    bgp_app_peer_console
-    Start_Console_Tool    ${BGP_APP_PEER_DELETE_ALL_COMMAND} --stream=${ODL_STREAM} ${script_uri_opt}    ${BGP_APP_PEER_OPTIONS}
-    Wait_Until_Console_Tool_Finish    ${bgp_emptying_timeout}
-    Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_delete_all.log
+    BGPcliKeywords.Start_Console_Tool    ${BGP_APP_PEER_DELETE_ALL_COMMAND} --stream=${ODL_STREAM} ${script_uri_opt}    ${BGP_APP_PEER_OPTIONS}
+    BGPcliKeywords.Wait_Until_Console_Tool_Finish    ${bgp_emptying_timeout}
+    BGPcliKeywords.Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_delete_all.log
 
 Wait_For_Stable_Topology_After_Deletion
     [Documentation]    Wait until example-ipv4-topology becomes stable again.
@@ -163,13 +162,13 @@ Check_For_Empty_Ipv4_Topology_After_Deleting
 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
+    BuiltIn.Wait Until Keyword Succeeds    ${bgp_emptying_timeout}    3s    Check_For_String_In_File    bgp_peer.log    total_received_withdrawn_prefix_counter: ${COUNT_APP_PEER_PREFIX_COUNT}
 
 Stop_BGP_Peer
     [Documentation]    Stop BGP peer tool
     SSHLibrary.Switch Connection    bgp_peer_console
-    Stop_Console_Tool
-    Store_File_To_Workspace    bgp_peer.log    bgp_peer_reconnect.log
+    BGPcliKeywords.Stop_Console_Tool
+    BGPcliKeywords.Store_File_To_Workspace    bgp_peer.log    bgp_peer_reconnect.log
 
 Delete_Bgp_Peer_Configuration
     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
@@ -181,10 +180,6 @@ Delete_Bgp_Application_Peer_Configuration
     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    NAME=example-bgp-peer-app    IP=${BGP_APP_PEER_ID}    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
     TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_application_peer    mapping=${mapping}
 
-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
-
 *** Keywords ***
 Setup_Everything
     [Documentation]    Setup imported resources, SSH-login to tools system,
@@ -235,3 +230,10 @@ Open_BGP_Aplicationp_Peer_Console
     [Documentation]    Create a session for BGP peer.
     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}    alias=bgp_app_peer_console
     SSHKeywords.Flexible_Mininet_Login
+
+Check_For_String_In_File
+    [Arguments]    ${file_name}    ${string}    ${threshold}=2
+    [Documentation]    Check file for ${string} and returns number of occurences
+    ${matches} =    SSHLibrary.Execute_Command    grep -c '${string}' '${file_name}'
+    ${count} =    Convert To Integer    ${matches}
+    BuiltIn.Should_Be_True    ${count} >= ${threshold}