Bgp HA, code refactoring 21/67721/9
authorTomas Markovic <tomas.markovic@pantheon.tech>
Thu, 1 Feb 2018 14:19:58 +0000 (15:19 +0100)
committerLuis Gomez <ecelgp@gmail.com>
Thu, 1 Feb 2018 17:43:11 +0000 (17:43 +0000)
Used BGPcliKeywords to remove some replication.
Fixed Variables.robot path Error.

Change-Id: Iab60063ef46192bb847d102d093105068bbcb7ae
Signed-off-by: Tomas Markovic <tomas.markovic@pantheon.tech>
12 files changed:
csit/libraries/BGPcliKeywords.robot
csit/libraries/BgpOperations.robot
csit/libraries/ExaBgpLib.robot
csit/libraries/PcepOperations.robot
csit/suites/bgpcep/bgpclustering/040_bgp_ha_karaf_restart.robot
csit/suites/bgpcep/bgpclustering/050_bgp_ha_karaf_stop.robot
csit/suites/bgpcep/bgpclustering/060_bmp_ha_karaf_restart.robot
csit/suites/bgpcep/bgpclustering/070_bmp_ha_karaf_stop.robot
csit/suites/bgpcep/bgpclustering/080_pcep_ha_karaf_restart.robot
csit/suites/bgpcep/bgpclustering/090_pcep_ha_karaf_stop.robot
csit/suites/bgpcep/bgpclustering/bgp_ha_karaf_isolation.robot
csit/suites/bgpcep/bgpfunct/050_bmp_basic.robot

index 6242ef9b6a4ab35ed8b80dddd7e4e9c50bc1b6c5..a9568b3f5989cf2eef2661c1717243ddc90d94f7 100644 (file)
@@ -15,13 +15,24 @@ Library           SSHLibrary    timeout=10s
 Library           RequestsLibrary
 Variables         ${CURDIR}/../variables/Variables.py
 Resource          ${CURDIR}/RemoteBash.robot
+Resource          ${CURDIR}/NexusKeywords.robot
 
 *** Keywords ***
 Start_Console_Tool
     [Arguments]    ${command}    ${tool_opt}
     [Documentation]    Start the tool ${command} ${tool_opt}
-    BuiltIn.Log    ${command}
-    ${output}=    SSHLibrary.Write    ${command} ${tool_opt}
+    ${start_cmd}    BuiltIn.Set_Variable    ${command} ${tool_opt}
+    BuiltIn.Log    ${start_cmd}
+    ${output}=    SSHLibrary.Write    ${start_cmd}
+    BuiltIn.Log    ${output}
+
+Start_Java_Tool_And_Verify_Connection
+    [Arguments]    ${command}    ${until_phrase}
+    ${start_cmd}    NexusKeywords.Compose_Full_Java_Command    ${command}
+    BuiltIn.Log    ${start_cmd}
+    SSHLibrary.Set_Client_Configuration    timeout=30s
+    SSHLibrary.Write    ${start_cmd}
+    ${output}=    SSHLibrary.Read_Until    ${until_phrase}
     BuiltIn.Log    ${output}
 
 Wait_Until_Console_Tool_Finish
@@ -35,6 +46,14 @@ Stop_Console_Tool
     ${output}=    SSHLibrary.Read    delay=1s
     BuiltIn.Log    ${output}
 
+Stop_Console_Tool_And_Wait_Until_Prompt
+    [Documentation]    Stops the tool by sending ctrl+c
+    ${output}=    SSHLibrary.Read
+    BuiltIn.Log    ${output}
+    RemoteBash.Write_Bare_Ctrl_C
+    ${output}=    SSHLibrary.Read_Until_Prompt
+    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 '${ODL_SYSTEM_PROMPT}' in *.    Read_Text_Before_Prompt
index cc632137b81875b26e9219920405bbd9dcb1cd7a..8d4f717f87d741564419b051212a6db4156606e0 100644 (file)
@@ -3,9 +3,12 @@ Documentation     This library contains keywords related to the BGP functionalit
 Library           SSHLibrary
 Resource          Utils.robot
 Resource          ../variables/Variables.robot
+Resource          TemplatedRequests.robot
 
 *** Variables ***
 ${VAR_BASE_BGP}    ${CURDIR}/../variables/bgpfunctional
+${BGP_BMP_DIR}    ${CURDIR}/../variables/bgpfunctional/bmp_basic/filled_structure
+${BGP_BMP_FEAT_DIR}    ${CURDIR}/../variables/bgpfunctional/bmp_basic/empty_structure
 
 *** Keywords ***
 Start Quagga Processes On ODL
@@ -222,3 +225,18 @@ Check_Example_IPv4_Topology_Does_Not_Contain
     BuiltIn.Log    ${response.status_code}
     BuiltIn.Log    ${response.text}
     BuiltIn.Should_Not_Contain    ${response.text}    ${string_to_check}
+
+Bmp_Monitor_Precondition
+    [Arguments]    ${session}
+    [Documentation]    Verify example-bmp-monitor presence in bmp-monitors
+    &{mapping}    BuiltIn.Create_Dictionary    TOOL_IP=${TOOLS_SYSTEM_IP}
+    BuiltIn.Wait_Until_Keyword_Succeeds    6x    10s    TemplatedRequests.Get_As_Json_Templated    folder=${BGP_BMP_FEAT_DIR}    mapping=${mapping}    verify=True
+    ...    session=${session}
+
+Bmp_Monitor_Postcondition
+    [Arguments]    ${session}
+    [Documentation]    Verifies if example-bmp-monitor data contains one peer.
+    &{mapping}    BuiltIn.Create_Dictionary    TOOL_IP=${TOOLS_SYSTEM_IP}
+    ${output}    BuiltIn.Wait_Until_Keyword_Succeeds    10x    5s    TemplatedRequests.Get_As_Json_Templated    folder=${BGP_BMP_DIR}    mapping=${mapping}
+    ...    session=${session}    verify=True
+    BuiltIn.Log    ${output}
index 7d4269b52e82fdc4f604f421d1b51f7768ca4791..6173e89ae75d15a861933b87abc7f8dfffd55881 100644 (file)
@@ -53,9 +53,24 @@ Start_ExaBgp_And_Verify_Connected
     BuiltIn.Fail    Unable to connect ExaBgp to ODL
 
 Verify_ExaBgps_Connection
-    [Arguments]    ${session}    ${exabgp_ip}    ${connected}=${True}
+    [Arguments]    ${session}    ${exabgp_ip}=${TOOLS_SYSTEM_IP}    ${connected}=${True}
     [Documentation]    Checks peer presence in operational datastore
     ${exp_status_code}=    BuiltIn.Set_Variable_If    ${connected}    ${200}    ${404}
     ${rsp}=    RequestsLibrary.Get Request    ${session}    ${PEER_CHECK_URL}${exabgp_ip}
     BuiltIn.Log    ${rsp.content}
     BuiltIn.Should_Be_Equal_As_Numbers    ${exp_status_code}    ${rsp.status_code}
+
+Upload_ExaBgp_Cluster_Config_Files
+    [Arguments]    ${bgp_var_folder}    ${cfg_file}
+    [Documentation]    Uploads exabgp config files.
+    SSHLibrary.Put_File    ${bgp_var_folder}/${cfg_file}    .
+    @{cfgfiles}=    SSHLibrary.List_Files_In_Directory    .    *.cfg
+    : FOR    ${cfgfile}    IN    @{cfgfiles}
+    \    SSHLibrary.Execute_Command    sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
+    \    SSHLibrary.Execute_Command    sed -i -e 's/ODLIP1/${ODL_SYSTEM_1_IP}/g' ${cfgfile}
+    \    SSHLibrary.Execute_Command    sed -i -e 's/ODLIP2/${ODL_SYSTEM_2_IP}/g' ${cfgfile}
+    \    SSHLibrary.Execute_Command    sed -i -e 's/ODLIP3/${ODL_SYSTEM_3_IP}/g' ${cfgfile}
+    \    SSHLibrary.Execute_Command    sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
+    \    SSHLibrary.Execute_Command    sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
+    \    ${stdout}=    SSHLibrary.Execute_Command    cat ${cfgfile}
+    \    Log    ${stdout}
index bc54047184daa9db3faaac9b6f3f29666929bf34..23b8c628afbb9b69955eafeac5c797276cec30be 100644 (file)
@@ -6,9 +6,16 @@ Documentation     Robot keyword library (Resource) for performing PCEP operation
 ...               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
+...
+...               TODO: Remove all old keywords, update pcepuser.robot accordingly
+...               TODO: Add new KWs, update all pcep tests to use them.
 Library           RequestsLibrary
-Library           ${CURDIR}/norm_json.py
-Variables         ${CURDIR}/../variables/Variables.py
+Library           norm_json.py
+Resource          ../variables/Variables.robot
+Resource          TemplatedRequests.robot
+
+*** Variables ***
+${PCEP_VAR_FOLDER}    ${CURDIR}/../variables/tcpmd5user
 
 *** Keywords ***
 Setup_Pcep_Operations
@@ -64,3 +71,9 @@ Pcep_Json_Is_Refused
     ${actual_normalized}=    norm_json.normalize_json_text    ${actual_raw}
     BuiltIn.Should_Be_Equal    ${actual_normalized}    ${expected_normalized}
     # TODO: Would the diff approach be more useful?
+
+Pcep_Topology_Precondition
+    [Arguments]    ${session}
+    [Documentation]    Compare current pcep-topology to empty one.
+    ...    Timeout is long enough to see that pcep is ready.
+    BuiltIn.Wait_Until_Keyword_Succeeds    300s    1s    TemplatedRequests.Get_As_Json_Templated    ${PCEP_VAR_FOLDER}/default_off    session=${session}    verify=True
index 123d4fea32192bd4559964a69c4115e0349257b4..31bd9e2aa9cd85374c473cd0d62bfece29d6dba2 100644 (file)
@@ -12,30 +12,31 @@ Documentation     BGP functional HA testing with one exabgp peer.
 ...               logs will show that one peer will be connected and two will fail.
 ...               After killing karaf which owned connection new owner should be elected and
 ...               this new owner should accept incomming bgp connection.
+...               TODO: Add similar keywords from all bgpclustering-ha tests into same libraries
 Suite Setup       Setup_Everything
 Suite Teardown    Teardown_Everything
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
 Library           SSHLibrary    timeout=10s
 Library           RequestsLibrary
-Variables         ${CURDIR}/../../../variables/Variables.robot
-Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
-Resource          ${CURDIR}/../../../libraries/ClusterManagement.robot
-Resource          ${CURDIR}/../../../libraries/RemoteBash.robot
-Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
-Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
+Resource          ../../../variables/Variables.robot
+Resource          ../../../libraries/SetupUtils.robot
+Resource          ../../../libraries/ClusterManagement.robot
+Resource          ../../../libraries/SSHKeywords.robot
+Resource          ../../../libraries/TemplatedRequests.robot
+Resource          ../../../libraries/BGPcliKeywords.robot
+Resource          ../../../libraries/ExaBgpLib.robot
 
 *** Variables ***
 ${BGP_VAR_FOLDER}    ${CURDIR}/../../../variables/bgpclustering
 ${BGP_PEER_FOLDER}    ${CURDIR}/../../../variables/bgpclustering/bgp_peer_openconf
-${DEFAUTL_EXA_CFG}    exa.cfg
+${DEFAULT_EXA_CFG}    exa.cfg
 ${EXA_CMD}        env exabgp.tcp.port=1790 exabgp
-${PEER_CHECK_URL}    /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/peer/bgp:%2F%2F
 ${HOLDTIME}       180
 ${RIB_INSTANCE}    example-bgp-rib
 
 *** Test Cases ***
-Get Example Bgp Rib Owner
+Get_Example_Bgp_Rib_Owner
     [Documentation]    Find an odl node which is able to accept incomming connection. To this node netconf connector should be configured.
     ${rib_owner}    ${rib_candidates}=    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    ClusterManagement.Get_Owner_And_Successors_For_Device    example-bgp-rib
     ...    org.opendaylight.mdsal.ServiceEntityType    1
@@ -55,11 +56,12 @@ Reconfigure_ODL_To_Accept_Connection
 
 Start_ExaBgp_Peer
     [Documentation]    Starts exabgp
-    Start_Tool    ${DEFAUTL_EXA_CFG}
+    SSHKeywords.Virtual_Env_Activate_On_Current_Session    log_output=${True}
+    BGPcliKeywords.Start_Console_Tool    ${EXA_CMD}    ${DEFAULT_EXA_CFG}
 
 Verify ExaBgp Connected
     [Documentation]    Verifies exabgp's presence in operational ds.
-    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    Verify_Tools_Connection    ${living_session}
+    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    ExaBgpLib.Verify_ExaBgps_Connection    ${living_session}
 
 Kill_Current_Owner_Member
     [Documentation]    Killing karaf which is connected with exabgp.
@@ -77,7 +79,7 @@ Verify_New_Rib_Owner
 
 Verify_ExaBgp_Reconnected
     [Documentation]    Verifies exabgp's presence in operational ds.
-    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    Verify_Tools_Connection    ${living_session}
+    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    ExaBgpLib.Verify_ExaBgps_Connection    ${living_session}
 
 Start_Stopped_Member
     [Documentation]    Starting stopped node
@@ -87,13 +89,14 @@ Verify_New_Candidate
     [Documentation]    Verifies started node become candidate for example-bgp-rib
     BuiltIn.Wait_Until_Keyword_Succeeds    10x    5s    Verify_New_Rib_Candidate_Present    ${old_rib_owner}    ${living_node}
 
-Verify ExaBgp Still Connected
+Verify_ExaBgp_Still_Connected
     [Documentation]    Verifies exabgp's presence in operational ds
-    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    Verify_Tools_Connection    ${living_session}
+    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    ExaBgpLib.Verify_ExaBgps_Connection    ${living_session}
 
 Stop_ExaBgp_Peer
-    [Documentation]    Stops exabgp
-    Stop_Tool
+    [Documentation]    Stops exabgp tool by sending ctrl+c
+    BGPcliKeywords.Stop_Console_Tool_And_Wait_Until_Prompt
+    SSHKeywords.Virtual_Env_Deactivate_On_Current_Session    log_output=${True}
 
 Delete_Bgp_Peer_Configuration
     [Documentation]    Revert the BGP configuration to the original state: without any configured peers
@@ -110,7 +113,7 @@ Setup_Everything
     SSHKeywords.Flexible_Mininet_Login    ${TOOLS_SYSTEM_USER}
     SSHKeywords.Virtual_Env_Create
     SSHKeywords.Virtual_Env_Install_Package    exabgp==3.4.16
-    Upload_Config_Files
+    ExaBgpLib.Upload_ExaBgp_Cluster_Config_Files    ${BGP_VAR_FOLDER}    ${DEFAULT_EXA_CFG}
 
 Teardown_Everything
     [Documentation]    Suite cleanup
@@ -118,38 +121,6 @@ Teardown_Everything
     RequestsLibrary.Delete_All_Sessions
     SSHLibrary.Close_All_Connections
 
-Start_Tool
-    [Arguments]    ${cfg_file}    ${mapping}={}
-    [Documentation]    Starts the tool
-    ${start_cmd}    BuiltIn.Set_Variable    ${EXA_CMD} ${cfg_file}
-    BuiltIn.Log    ${start_cmd}
-    SSHKeywords.Virtual_Env_Activate_On_Current_Session    log_output=${True}
-    ${output}=    SSHLibrary.Write    ${start_cmd}
-    BuiltIn.Log    ${output}
-
-Stop_Tool
-    [Documentation]    Stops the tool by sending ctrl+c
-    ${output}=    SSHLibrary.Read
-    BuiltIn.Log    ${output}
-    RemoteBash.Write_Bare_Ctrl_C
-    ${output}=    SSHLibrary.Read_Until_Prompt
-    BuiltIn.Log    ${output}
-    SSHKeywords.Virtual_Env_Deactivate_On_Current_Session    log_output=${True}
-
-Upload_Config_Files
-    [Documentation]    Uploads exabgp config files.
-    SSHLibrary.Put_File    ${BGP_VAR_FOLDER}/${DEFAUTL_EXA_CFG}    .
-    @{cfgfiles}=    SSHLibrary.List_Files_In_Directory    .    *.cfg
-    : FOR    ${cfgfile}    IN    @{cfgfiles}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/ODLIP1/${ODL_SYSTEM_1_IP}/g' ${cfgfile}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/ODLIP2/${ODL_SYSTEM_2_IP}/g' ${cfgfile}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/ODLIP3/${ODL_SYSTEM_3_IP}/g' ${cfgfile}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
-    \    ${stdout}=    SSHLibrary.Execute_Command    cat ${cfgfile}
-    \    Log    ${stdout}
-
 Verify_New_Rib_Owner_Elected
     [Arguments]    ${old_owner}    ${node_to_ask}
     [Documentation]    Verifies new owner was elected
@@ -161,11 +132,3 @@ Verify_New_Rib_Candidate_Present
     [Documentation]    Verifies candidate's presence.
     ${owner}    ${candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device    example-bgp-rib    org.opendaylight.mdsal.ServiceEntityType    ${node_to_ask}
     BuiltIn.Should_Contain    ${candidates}    ${candidate}
-
-Verify_Tools_Connection
-    [Arguments]    ${session}    ${connected}=${True}
-    [Documentation]    Checks peer presence in operational datastore
-    ${exp_status_code}=    BuiltIn.Set_Variable_If    ${connected}    ${200}    ${404}
-    ${rsp}=    RequestsLibrary.Get Request    ${session}    ${PEER_CHECK_URL}${TOOLS_SYSTEM_IP}
-    BuiltIn.Log    ${rsp.content}
-    BuiltIn.Should_Be_Equal_As_Numbers    ${exp_status_code}    ${rsp.status_code}
index 105e86e99f46d644339dad34ee265d7db6ebd978..f4a7de081144cb8575b27316693e03fc7e28d4ba 100644 (file)
@@ -12,30 +12,31 @@ Documentation     BGP functional HA testing with one exabgp peer.
 ...               logs will show that one peer will be connected and two will fail.
 ...               After stopping karaf which owned connection new owner should be elected and
 ...               this new owner should accept incomming bgp connection.
+...               TODO: Add similar keywords from all bgpclustering-ha tests into same libraries
 Suite Setup       Setup_Everything
 Suite Teardown    Teardown_Everything
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
 Library           SSHLibrary    timeout=10s
 Library           RequestsLibrary
-Variables         ${CURDIR}/../../../variables/Variables.robot
-Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
-Resource          ${CURDIR}/../../../libraries/ClusterManagement.robot
-Resource          ${CURDIR}/../../../libraries/RemoteBash.robot
-Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
-Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
+Resource          ../../../variables/Variables.robot
+Resource          ../../../libraries/SetupUtils.robot
+Resource          ../../../libraries/ClusterManagement.robot
+Resource          ../../../libraries/SSHKeywords.robot
+Resource          ../../../libraries/TemplatedRequests.robot
+Resource          ../../../libraries/BGPcliKeywords.robot
+Resource          ../../../libraries/ExaBgpLib.robot
 
 *** Variables ***
 ${BGP_VAR_FOLDER}    ${CURDIR}/../../../variables/bgpclustering
 ${BGP_PEER_FOLDER}    ${CURDIR}/../../../variables/bgpclustering/bgp_peer_openconf
-${DEFAUTL_EXA_CFG}    exa.cfg
+${DEFAULT_EXA_CFG}    exa.cfg
 ${EXA_CMD}        env exabgp.tcp.port=1790 exabgp
-${PEER_CHECK_URL}    /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/peer/bgp:%2F%2F
 ${HOLDTIME}       180
 ${RIB_INSTANCE}    example-bgp-rib
 
 *** Test Cases ***
-Get Example Bgp Rib Owner
+Get_Example_Bgp_Rib_Owner
     [Documentation]    Find an odl node which is able to accept incomming connection. To this node netconf connector should be configured.
     ${rib_owner}    ${rib_candidates}=    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    ClusterManagement.Get_Owner_And_Successors_For_Device    example-bgp-rib
     ...    org.opendaylight.mdsal.ServiceEntityType    1
@@ -55,11 +56,12 @@ Reconfigure_ODL_To_Accept_Connection
 
 Start_ExaBgp_Peer
     [Documentation]    Starts exabgp
-    Start_Tool    ${DEFAUTL_EXA_CFG}
+    SSHKeywords.Virtual_Env_Activate_On_Current_Session    log_output=${True}
+    BGPcliKeywords.Start_Console_Tool    ${EXA_CMD}    ${DEFAULT_EXA_CFG}
 
-Verify ExaBgp Connected
+Verify_ExaBgp_Connected
     [Documentation]    Verifies exabgp's presence in operational ds.
-    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    Verify_Tools_Connection    ${living_session}
+    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    ExaBgpLib.Verify_ExaBgps_Connection    ${living_session}
 
 Stop_Current_Owner_Member
     [Documentation]    Stopping karaf which is connected with exabgp.
@@ -77,7 +79,7 @@ Verify_New_Rib_Owner
 
 Verify_ExaBgp_Reconnected
     [Documentation]    Verifies exabgp's presence in operational ds.
-    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    Verify_Tools_Connection    ${living_session}
+    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    ExaBgpLib.Verify_ExaBgps_Connection    ${living_session}
 
 Start_Stopped_Member
     [Documentation]    Starting stopped node
@@ -87,13 +89,14 @@ Verify_New_Candidate
     [Documentation]    Verifies started node become candidate for example-bgp-rib
     BuiltIn.Wait_Until_Keyword_Succeeds    10x    5s    Verify_New_Rib_Candidate_Present    ${old_rib_owner}    ${living_node}
 
-Verify ExaBgp Still Connected
+Verify_ExaBgp_Still_Connected
     [Documentation]    Verifies exabgp's presence in operational ds
-    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    Verify_Tools_Connection    ${living_session}
+    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    ExaBgpLib.Verify_ExaBgps_Connection    ${living_session}
 
 Stop_ExaBgp_Peer
-    [Documentation]    Stops exabgp
-    Stop_Tool
+    [Documentation]    Stops exabgp tool by sending ctrl+c
+    BGPcliKeywords.Stop_Console_Tool_And_Wait_Until_Prompt
+    SSHKeywords.Virtual_Env_Deactivate_On_Current_Session    log_output=${True}
 
 Delete_Bgp_Peer_Configuration
     [Documentation]    Revert the BGP configuration to the original state: without any configured peers
@@ -110,7 +113,7 @@ Setup_Everything
     SSHKeywords.Flexible_Mininet_Login    ${TOOLS_SYSTEM_USER}
     SSHKeywords.Virtual_Env_Create
     SSHKeywords.Virtual_Env_Install_Package    exabgp==3.4.16
-    Upload_Config_Files
+    ExaBgpLib.Upload_ExaBgp_Cluster_Config_Files    ${BGP_VAR_FOLDER}    ${DEFAULT_EXA_CFG}
 
 Teardown_Everything
     [Documentation]    Suite cleanup
@@ -118,38 +121,6 @@ Teardown_Everything
     RequestsLibrary.Delete_All_Sessions
     SSHLibrary.Close_All_Connections
 
-Start_Tool
-    [Arguments]    ${cfg_file}    ${mapping}={}
-    [Documentation]    Starts the tool
-    ${start_cmd}    BuiltIn.Set_Variable    ${EXA_CMD} ${cfg_file}
-    BuiltIn.Log    ${start_cmd}
-    SSHKeywords.Virtual_Env_Activate_On_Current_Session    log_output=${True}
-    ${output}=    SSHLibrary.Write    ${start_cmd}
-    BuiltIn.Log    ${output}
-
-Stop_Tool
-    [Documentation]    Stops the tool by sending ctrl+c
-    ${output}=    SSHLibrary.Read
-    BuiltIn.Log    ${output}
-    RemoteBash.Write_Bare_Ctrl_C
-    ${output}=    SSHLibrary.Read_Until_Prompt
-    BuiltIn.Log    ${output}
-    SSHKeywords.Virtual_Env_Deactivate_On_Current_Session    log_output=${True}
-
-Upload_Config_Files
-    [Documentation]    Uploads exabgp config files.
-    SSHLibrary.Put_File    ${BGP_VAR_FOLDER}/${DEFAUTL_EXA_CFG}    .
-    @{cfgfiles}=    SSHLibrary.List_Files_In_Directory    .    *.cfg
-    : FOR    ${cfgfile}    IN    @{cfgfiles}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/ODLIP1/${ODL_SYSTEM_1_IP}/g' ${cfgfile}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/ODLIP2/${ODL_SYSTEM_2_IP}/g' ${cfgfile}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/ODLIP3/${ODL_SYSTEM_3_IP}/g' ${cfgfile}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
-    \    ${stdout}=    SSHLibrary.Execute_Command    cat ${cfgfile}
-    \    Log    ${stdout}
-
 Verify_New_Rib_Owner_Elected
     [Arguments]    ${old_owner}    ${node_to_ask}
     [Documentation]    Verifies new owner was elected
@@ -161,11 +132,3 @@ Verify_New_Rib_Candidate_Present
     [Documentation]    Verifies candidate's presence.
     ${owner}    ${candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device    example-bgp-rib    org.opendaylight.mdsal.ServiceEntityType    ${node_to_ask}
     BuiltIn.Should_Contain    ${candidates}    ${candidate}
-
-Verify_Tools_Connection
-    [Arguments]    ${session}    ${connected}=${True}
-    [Documentation]    Checks peer presence in operational datastore
-    ${exp_status_code}=    BuiltIn.Set_Variable_If    ${connected}    ${200}    ${404}
-    ${rsp}=    RequestsLibrary.Get Request    ${session}    ${PEER_CHECK_URL}${TOOLS_SYSTEM_IP}
-    BuiltIn.Log    ${rsp.content}
-    BuiltIn.Should_Be_Equal_As_Numbers    ${exp_status_code}    ${rsp.status_code}
index 86a6046885f1920cf324039788e578a872ba11fe..9b2babc8b301e80be3725b45a55c678e2956084c 100644 (file)
@@ -12,6 +12,7 @@ Documentation     BMP functional HA testing with BMP mock.
 ...               logs will show that one peer will be connected and two will fail.
 ...               After killing karaf which owned connection new owner should be elected and
 ...               this new owner should accept incomming BMP connection.
+...               TODO: Add similar keywords from all bgpclustering-ha tests into same libraries
 Suite Setup       Setup_Everything
 Suite Teardown    Teardown_Everything
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
@@ -22,16 +23,14 @@ Library           OperatingSystem
 Resource          ../../../variables/Variables.robot
 Resource          ../../../libraries/SetupUtils.robot
 Resource          ../../../libraries/ClusterManagement.robot
-Resource          ../../../libraries/RemoteBash.robot
-Resource          ../../../libraries/TemplatedRequests.robot
 Resource          ../../../libraries/NexusKeywords.robot
+Resource          ../../../libraries/BGPcliKeywords.robot
+Resource          ../../../libraries/BgpOperations.robot
 
 *** Variables ***
-${BGP_VAR_FOLDER}    ${CURDIR}/../../../variables/bgpclustering
 ${HOLDTIME}       180
-${BGP_BMP_DIR}    ${CURDIR}/../../../variables/bgpfunctional/bmp_basic/filled_structure
-${BGP_BMP_FEAT_DIR}    ${CURDIR}/../../../variables/bgpfunctional/bmp_basic/empty_structure
-${BMP_LOG_FILE}    bmpmock.log
+${BMP_LOG_FILE}    bmpmock.restart.log
+${CONFIG_SESSION}    session
 
 *** Test Cases ***
 Get_Example_Bm_Owner
@@ -47,24 +46,9 @@ Get_Example_Bm_Owner
     BuiltIn.Log    ${living_session}
     BuiltIn.Set_Suite_Variable    ${living_node}    ${bm_owner}
 
-Verify_Bmp_Feature
-    [Documentation]    Verify example-bmp-monitor presence in bmp-monitors
-    &{mapping}    BuiltIn.Create_Dictionary    TOOL_IP=${TOOLS_SYSTEM_IP}
-    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    TemplatedRequests.Get_As_Json_Templated    folder=${BGP_BMP_FEAT_DIR}    mapping=${mapping}    verify=True
-    ...    session=${living_session}
-
-Start_Bmp_Mock
-    [Documentation]    Starts bmp mock
-    ${command}=    NexusKeywords.Compose_Full_Java_Command    -jar ${filename} --local_address ${TOOLS_SYSTEM_IP} --remote_address ${ODL_SYSTEM_1_IP}:12345,${ODL_SYSTEM_2_IP}:12345,${ODL_SYSTEM_3_IP}:12345 --routers_count 1 --peers_count 1 --log_level TRACE 2>&1 | tee ${BMP_LOG_FILE}
-    BuiltIn.Log    ${command}
-    SSHLibrary.Set_Client_Configuration    timeout=30s
-    SSHLibrary.Write    ${command}
-    ${output}=    SSHLibrary.Read_Until    successfully established.
-    BuiltIn.Log    ${output}
-
 Verify_Data_Reported_1
     [Documentation]    Verifies if example-bmp-monitor reported expected data
-    Verify_Data_Reported
+    BgpOperations.Bmp_Monitor_Postcondition    ${living_session}
 
 Kill_Current_Owner_Member
     [Documentation]    Killing cluster node which is connected with bmp mock.
@@ -82,7 +66,7 @@ Verify_New_Bm_Owner
 
 Verify_Data_Reported_2
     [Documentation]    Verifies if example-bmp-monitor reported expected data
-    Verify_Data_Reported
+    BgpOperations.Bmp_Monitor_Postcondition    ${living_session}
 
 Start_Old_Owner_Member
     [Documentation]    Start killed node
@@ -94,13 +78,11 @@ Verify_New_Candidate
 
 Verify_Data_Reported_3
     [Documentation]    Verifies if example-bmp-monitor reported expected data
-    Verify_Data_Reported
+    BgpOperations.Bmp_Monitor_Postcondition    ${living_session}
 
 Stop_Bmp_Mock
     [Documentation]    Send ctrl+c to bmp-mock to stop it
-    RemoteBash.Write_Bare_Ctrl_C
-    ${output}=    SSHLibrary.Read_Until_Prompt
-    BuiltIn.Log    ${output}
+    BGPcliKeywords.Stop_Console_Tool_And_Wait_Until_Prompt
 
 *** Keywords ***
 Setup_Everything
@@ -108,34 +90,33 @@ Setup_Everything
     SetupUtils.Setup_Utils_For_Setup_And_Teardown
     ClusterManagement.ClusterManagement_Setup
     NexusKeywords.Initialize_Artifact_Deployment_And_Usage
-    #ClusterManagement.Cluster_Setup_For_Artifact_Deployment_And_Usage
+    RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
     ${name}=    NexusKeywords.Deploy_Test_Tool    bgpcep    bgp-bmp-mock
     BuiltIn.Set_Suite_Variable    ${filename}    ${name}
+    BgpOperations.Bmp_Monitor_Precondition    ${CONFIG_SESSION}
+    Start_Bmp_Mock
 
 Teardown_Everything
     [Documentation]    Suite cleanup
-    SSHLibrary.Get_File    ${BMP_LOG_FILE}
-    ${cnt}=    OperatingSystem.Get_File    ${BMP_LOG_FILE}
-    Log    ${cnt}
+    BGPcliKeywords.Store_File_To_Workspace    ${BMP_LOG_FILE}    ${BMP_LOG_FILE}
     RequestsLibrary.Delete_All_Sessions
     SSHLibrary.Close_All_Connections
 
-Verify_Data_Reported
-    [Arguments]    ${ip}=${TOOLS_SYSTEM_IP}
-    [Documentation]    Verifies if the tool reported expected data
-    &{mapping}    BuiltIn.Create_Dictionary    TOOL_IP=${ip}
-    ${output}=    Wait Until Keyword Succeeds    10x    5s    TemplatedRequests.Get_As_Json_Templated    folder=${BGP_BMP_DIR}    mapping=${mapping}
-    ...    session=${living_session}    verify=True
-    Log    ${output}
+Start_Bmp_Mock
+    [Documentation]    Starts bmp mock
+    ${command}=    BuiltIn.Set_Variable    -jar ${filename} --local_address ${TOOLS_SYSTEM_IP} --remote_address ${ODL_SYSTEM_1_IP}:12345,${ODL_SYSTEM_2_IP}:12345,${ODL_SYSTEM_3_IP}:12345 --routers_count 1 --peers_count 1 --log_level INFO 2>&1 | tee ${BMP_LOG_FILE}
+    BGPcliKeywords.Start_Java_Tool_And_Verify_Connection    ${command}    successfully established.
 
 Verify_New_Bm_Owner_Elected
     [Arguments]    ${old_owner}    ${node_to_ask}
     [Documentation]    Verifies new owner was elected
     ${owner}    ${candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device    bmp-monitors    Bgpcep    ${node_to_ask}
+    BuiltIn.Log    ${owner}
     BuiltIn.Should_Not_Be_Equal    ${old_owner}    ${owner}
 
 Verify_New_Bm_Candidate_Present
     [Arguments]    ${candidate}    ${node_to_ask}
     [Documentation]    Verifies candidate's presence.
     ${owner}    ${candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device    bmp-monitors    Bgpcep    ${node_to_ask}
+    BuiltIn.Log    ${owner}
     BuiltIn.Should_Contain    ${candidates}    ${candidate}
index 9ac3ff670e266447157fed23bfe3ca1f7433cd30..36a9921aef128876aedc4c77a695621d47521984 100644 (file)
@@ -12,6 +12,7 @@ Documentation     BMP functional HA testing with one BMP mock.
 ...               logs will show that one peer will be connected and two will fail.
 ...               After stopping karaf which owned connection new owner should be elected and
 ...               this new owner should accept incomming BMP connection.
+...               TODO: Add similar keywords from all bgpclustering-ha tests into same libraries
 Suite Setup       Setup_Everything
 Suite Teardown    Teardown_Everything
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
@@ -22,16 +23,14 @@ Library           OperatingSystem
 Resource          ../../../variables/Variables.robot
 Resource          ../../../libraries/SetupUtils.robot
 Resource          ../../../libraries/ClusterManagement.robot
-Resource          ../../../libraries/RemoteBash.robot
-Resource          ../../../libraries/TemplatedRequests.robot
 Resource          ../../../libraries/NexusKeywords.robot
+Resource          ../../../libraries/BGPcliKeywords.robot
+Resource          ../../../libraries/BgpOperations.robot
 
 *** Variables ***
-${BGP_VAR_FOLDER}    ${CURDIR}/../../../variables/bgpclustering
 ${HOLDTIME}       180
-${BGP_BMP_DIR}    ${CURDIR}/../../../variables/bgpfunctional/bmp_basic/filled_structure
-${BGP_BMP_FEAT_DIR}    ${CURDIR}/../../../variables/bgpfunctional/bmp_basic/empty_structure
-${BMP_LOG_FILE}    bmpmock.log
+${BMP_LOG_FILE}    bmpmock.stop.log
+${CONFIG_SESSION}    session
 
 *** Test Cases ***
 Get_Example_Bm_Owner
@@ -47,24 +46,9 @@ Get_Example_Bm_Owner
     BuiltIn.Log    ${living_session}
     BuiltIn.Set_Suite_Variable    ${living_node}    ${bm_owner}
 
-Verify_Bmp_Feature
-    [Documentation]    Verify example-bmp-monitor presence in bmp-monitors
-    &{mapping}    BuiltIn.Create_Dictionary    TOOL_IP=${TOOLS_SYSTEM_IP}
-    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    TemplatedRequests.Get_As_Json_Templated    folder=${BGP_BMP_FEAT_DIR}    mapping=${mapping}    verify=True
-    ...    session=${living_session}
-
-Start_Bmp_Mock
-    [Documentation]    Starts bmp mock
-    ${command}=    NexusKeywords.Compose_Full_Java_Command    -jar ${filename} --local_address ${TOOLS_SYSTEM_IP} --remote_address ${ODL_SYSTEM_1_IP}:12345,${ODL_SYSTEM_2_IP}:12345,${ODL_SYSTEM_3_IP}:12345 --routers_count 1 --peers_count 1 --log_level TRACE 2>&1 | tee ${BMP_LOG_FILE}
-    BuiltIn.Log    ${command}
-    SSHLibrary.Set_Client_Configuration    timeout=30s
-    SSHLibrary.Write    ${command}
-    ${output}=    SSHLibrary.Read_Until    successfully established.
-    BuiltIn.Log    ${output}
-
 Verify_Data_Reported_1
     [Documentation]    Verifies if example-bmp-monitor reported expected data
-    Verify_Data_Reported
+    BgpOperations.Bmp_Monitor_Postcondition    ${living_session}
 
 Stop_Current_Owner_Member
     [Documentation]    Stop cluster node which is connected with bmp mock.
@@ -82,7 +66,7 @@ Verify_New_Bm_Owner
 
 Verify_Data_Reported_2
     [Documentation]    Verifies if example-bmp-monitor reported expected data
-    Verify_Data_Reported
+    BgpOperations.Bmp_Monitor_Postcondition    ${living_session}
 
 Start_Old_Owner_Member
     [Documentation]    Restart old owner node with bin/start
@@ -94,13 +78,11 @@ Verify_New_Candidate
 
 Verify_Data_Reported_3
     [Documentation]    Verifies if example-bmp-monitor reported expected data
-    Verify_Data_Reported
+    BgpOperations.Bmp_Monitor_Postcondition    ${living_session}
 
 Stop_Bmp_Mock
     [Documentation]    Send ctrl+c to bmp-mock to stop it
-    RemoteBash.Write_Bare_Ctrl_C
-    ${output}=    SSHLibrary.Read_Until_Prompt
-    BuiltIn.Log    ${output}
+    BGPcliKeywords.Stop_Console_Tool_And_Wait_Until_Prompt
 
 *** Keywords ***
 Setup_Everything
@@ -108,34 +90,33 @@ Setup_Everything
     SetupUtils.Setup_Utils_For_Setup_And_Teardown
     ClusterManagement.ClusterManagement_Setup
     NexusKeywords.Initialize_Artifact_Deployment_And_Usage
-    #ClusterManagement.Cluster_Setup_For_Artifact_Deployment_And_Usage
+    RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
     ${name}=    NexusKeywords.Deploy_Test_Tool    bgpcep    bgp-bmp-mock
     BuiltIn.Set_Suite_Variable    ${filename}    ${name}
+    BgpOperations.Bmp_Monitor_Precondition    ${CONFIG_SESSION}
+    Start_Bmp_Mock
 
 Teardown_Everything
     [Documentation]    Suite cleanup
-    SSHLibrary.Get_File    ${BMP_LOG_FILE}
-    ${cnt}=    OperatingSystem.Get_File    ${BMP_LOG_FILE}
-    Log    ${cnt}
+    BGPcliKeywords.Store_File_To_Workspace    ${BMP_LOG_FILE}    ${BMP_LOG_FILE}
     RequestsLibrary.Delete_All_Sessions
     SSHLibrary.Close_All_Connections
 
-Verify_Data_Reported
-    [Arguments]    ${ip}=${TOOLS_SYSTEM_IP}
-    [Documentation]    Verifies if the tool reported expected data
-    &{mapping}    BuiltIn.Create_Dictionary    TOOL_IP=${ip}
-    ${output}=    Wait Until Keyword Succeeds    10x    5s    TemplatedRequests.Get_As_Json_Templated    folder=${BGP_BMP_DIR}    mapping=${mapping}
-    ...    session=${living_session}    verify=True
-    Log    ${output}
+Start_Bmp_Mock
+    [Documentation]    Starts bmp mock
+    ${command}=    BuiltIn.Set_Variable    -jar ${filename} --local_address ${TOOLS_SYSTEM_IP} --remote_address ${ODL_SYSTEM_1_IP}:12345,${ODL_SYSTEM_2_IP}:12345,${ODL_SYSTEM_3_IP}:12345 --routers_count 1 --peers_count 1 --log_level INFO 2>&1 | tee ${BMP_LOG_FILE}
+    BGPcliKeywords.Start_Java_Tool_And_Verify_Connection    ${command}    successfully established.
 
 Verify_New_Bm_Owner_Elected
     [Arguments]    ${old_owner}    ${node_to_ask}
     [Documentation]    Verifies new owner was elected
     ${owner}    ${candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device    bmp-monitors    Bgpcep    ${node_to_ask}
+    BuiltIn.Log    ${owner}
     BuiltIn.Should_Not_Be_Equal    ${old_owner}    ${owner}
 
 Verify_New_Bm_Candidate_Present
     [Arguments]    ${candidate}    ${node_to_ask}
     [Documentation]    Verifies candidate's presence.
     ${owner}    ${candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device    bmp-monitors    Bgpcep    ${node_to_ask}
+    BuiltIn.Log    ${owner}
     BuiltIn.Should_Contain    ${candidates}    ${candidate}
index 3d716d726fa715c9b399e40f133ef95201a5789e..f2989b456574ffa5e4757639c0bf8bfea39312c9 100644 (file)
@@ -12,6 +12,7 @@ Documentation     PCEP functional HA testing with one pcep peer.
 ...               logs will show that one peer will be connected and two will fail.
 ...               After killing karaf which owned connection new owner should be elected and
 ...               this new owner should accept incomming PCC connection.
+...               TODO: Add similar keywords from all bgpclustering-ha tests into same libraries
 Suite Setup       Setup_Everything
 Suite Teardown    Teardown_Everything
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
@@ -22,13 +23,16 @@ Library           OperatingSystem
 Resource          ../../../variables/Variables.robot
 Resource          ../../../libraries/SetupUtils.robot
 Resource          ../../../libraries/ClusterManagement.robot
-Resource          ../../../libraries/RemoteBash.robot
 Resource          ../../../libraries/TemplatedRequests.robot
 Resource          ../../../libraries/NexusKeywords.robot
+Resource          ../../../libraries/BGPcliKeywords.robot
+Resource          ../../../libraries/PcepOperations.robot
 
 *** Variables ***
 ${HOLDTIME}       180
 ${DIR_WITH_TEMPLATES}    ${CURDIR}/../../../variables/bgpclustering/
+${PCC_LOG_FILE}    pccmock.restart.log
+${CONFIG_SESSION}    session
 
 *** Test Cases ***
 Get_Example_Pcep_Owner
@@ -46,7 +50,7 @@ Get_Example_Pcep_Owner
 Verify_Data_Reported_1
     [Documentation]    Verifies if pcep-topology reported expected data
     ...    Expects pcep-topology not be empty/filled path-computation.
-    Verify_Data_Reported
+    Pcep_Topology_Postcondition
 
 Kill_Current_Owner_Member
     [Documentation]    Killing cluster node which is connected with pcc-mock.
@@ -65,7 +69,7 @@ Verify_New_Pcep_Owner
 Verify_Data_Reported_2
     [Documentation]    Verifies if pcep-topology reports expected data
     ...    Expects pcep-topology not be empty/filled path-computation.
-    Verify_Data_Reported
+    Pcep_Topology_Postcondition
 
 Start_Stopped_Member
     [Documentation]    Starting stopped node
@@ -78,13 +82,11 @@ Verify_New_Candidate
 Verify_Data_Reported_3
     [Documentation]    Verifies if pcep-topology reported expected data
     ...    Expects pcep-topology not be empty/filled path-computation.
-    Verify_Data_Reported
+    Pcep_Topology_Postcondition
 
 Stop_Pcc_Mock
     [Documentation]    Send ctrl+c to pcc-mock to stop it.
-    RemoteBash.Write_Bare_Ctrl_C
-    ${output}=    SSHLibrary.Read_Until_Prompt
-    BuiltIn.Log    ${output}
+    BGPcliKeywords.Stop_Console_Tool_And_Wait_Until_Prompt
 
 *** Keywords ***
 Setup_Everything
@@ -92,32 +94,29 @@ Setup_Everything
     SetupUtils.Setup_Utils_For_Setup_And_Teardown
     ClusterManagement.ClusterManagement_Setup
     NexusKeywords.Initialize_Artifact_Deployment_And_Usage
+    RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
     ${name}=    NexusKeywords.Deploy_Test_Tool    bgpcep    pcep-pcc-mock
     BuiltIn.Set_Suite_Variable    ${filename}    ${name}
     #Setting Pcc Name and its code for mapping for templates
+    #TODO: Move variable definitions into PcepOperations setup after its update
     BuiltIn.Set_Suite_Variable    ${pcc_name}    pcc_${TOOLS_SYSTEM_IP}_tunnel_1
     ${code}=    Evaluate    binascii.b2a_base64('${pcc_name}')[:-1]    modules=binascii
     BuiltIn.Set_Suite_Variable    ${pcc_name_code}    ${code}
+    PcepOperations.Pcep_Topology_Precondition    ${CONFIG_SESSION}
     Start_Pcc_Mock
 
 Teardown_Everything
     [Documentation]    Suite cleanup
-    SSHLibrary.Get_File    pccmock.log
-    ${cnt}=    OperatingSystem.Get_File    pccmock.log
-    Log    ${cnt}
+    BGPcliKeywords.Store_File_To_Workspace    ${PCC_LOG_FILE}    ${PCC_LOG_FILE}
     RequestsLibrary.Delete_All_Sessions
     SSHLibrary.Close_All_Connections
 
 Start_Pcc_Mock
     [Documentation]    Starts pcc mock
-    ${command}=    NexusKeywords.Compose_Full_Java_Command    -jar ${filename} --reconnect 1 --local-address ${TOOLS_SYSTEM_IP} --remote-address ${ODL_SYSTEM_1_IP}:4189,${ODL_SYSTEM_2_IP}:4189,${ODL_SYSTEM_3_IP}:4189 --log-level INFO 2>&1 | tee pccmock.log
-    BuiltIn.Log    ${command}
-    SSHLibrary.Set_Client_Configuration    timeout=30s
-    SSHLibrary.Write    ${command}
-    ${output}=    SSHLibrary.Read_Until    started
-    BuiltIn.Log    ${output}
-
-Verify_Data_Reported
+    ${command}=    BuiltIn.Set_Variable    -jar ${filename} --reconnect 1 --local-address ${TOOLS_SYSTEM_IP} --remote-address ${ODL_SYSTEM_1_IP}:4189,${ODL_SYSTEM_2_IP}:4189,${ODL_SYSTEM_3_IP}:4189 --log-level INFO 2>&1 | tee ${PCC_LOG_FILE}
+    BGPcliKeywords.Start_Java_Tool_And_Verify_Connection    ${command}    started
+
+Pcep_Topology_Postcondition
     [Documentation]    Verifies if the tool reported expected data
     &{mapping}    BuiltIn.Create_Dictionary    IP=${TOOLS_SYSTEM_IP}    CODE=${pcc_name_code}    NAME=${pcc_name}    IP_ODL=${ODL_SYSTEM_${pcep_owner}_IP}
     BuiltIn.Wait_Until_Keyword_Succeeds    10x    5s    TemplatedRequests.Get_As_Json_Templated    ${DIR_WITH_TEMPLATES}${/}pcep_on_state    ${mapping}    ${living_session}
index c18d486bf9f9d02bae74eeacae73098a56f99dd9..4094b4f017a443b4937033d768beac561f6a117f 100644 (file)
@@ -12,6 +12,7 @@ Documentation     PCEP functional HA testing with one pcep peer.
 ...               logs will show that one peer will be connected and two will fail.
 ...               After stopping karaf which owned connection new owner should be elected and
 ...               this new owner should accept incomming PCC connection.
+...               TODO: Add similar keywords from all bgpclustering-ha tests into same libraries
 Suite Setup       Setup_Everything
 Suite Teardown    Teardown_Everything
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
@@ -22,13 +23,16 @@ Library           OperatingSystem
 Resource          ../../../variables/Variables.robot
 Resource          ../../../libraries/SetupUtils.robot
 Resource          ../../../libraries/ClusterManagement.robot
-Resource          ../../../libraries/RemoteBash.robot
 Resource          ../../../libraries/TemplatedRequests.robot
 Resource          ../../../libraries/NexusKeywords.robot
+Resource          ../../../libraries/BGPcliKeywords.robot
+Resource          ../../../libraries/PcepOperations.robot
 
 *** Variables ***
 ${HOLDTIME}       180
 ${DIR_WITH_TEMPLATES}    ${CURDIR}/../../../variables/bgpclustering/
+${PCC_LOG_FILE}    pccmock.stop.log
+${CONFIG_SESSION}    session
 
 *** Test Cases ***
 Get_Example_Pcep_Owner
@@ -46,7 +50,7 @@ Get_Example_Pcep_Owner
 Verify_Data_Reported_1
     [Documentation]    Verifies if pcep-topology reported expected data
     ...    Expects pcep-topology not be empty/filled path-computation.
-    Verify_Data_Reported
+    Pcep_Topology_Postcondition
 
 Stop_Current_Owner_Member
     [Documentation]    Stopping cluster node which is connected with pcc-mock.
@@ -65,7 +69,7 @@ Verify_New_Pcep_Owner
 Verify_Data_Reported_2
     [Documentation]    Verifies if pcep-topology reports expected data
     ...    Expects pcep-topology not be empty/filled path-computation.
-    Verify_Data_Reported
+    Pcep_Topology_Postcondition
 
 Start_Stopped_Member
     [Documentation]    Starting stopped node
@@ -78,13 +82,11 @@ Verify_New_Candidate
 Verify_Data_Reported_3
     [Documentation]    Verifies if pcep-topology reported expected data
     ...    Expects pcep-topology not be empty/filled path-computation.
-    Verify_Data_Reported
+    Pcep_Topology_Postcondition
 
 Stop_Pcc_Mock
     [Documentation]    Send ctrl+c to pcc-mock to stop it.
-    RemoteBash.Write_Bare_Ctrl_C
-    ${output}=    SSHLibrary.Read_Until_Prompt
-    BuiltIn.Log    ${output}
+    BGPcliKeywords.Stop_Console_Tool_And_Wait_Until_Prompt
 
 *** Keywords ***
 Setup_Everything
@@ -92,32 +94,28 @@ Setup_Everything
     SetupUtils.Setup_Utils_For_Setup_And_Teardown
     ClusterManagement.ClusterManagement_Setup
     NexusKeywords.Initialize_Artifact_Deployment_And_Usage
+    RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
     ${name}=    NexusKeywords.Deploy_Test_Tool    bgpcep    pcep-pcc-mock
     BuiltIn.Set_Suite_Variable    ${filename}    ${name}
     #Setting Pcc Name and its code for mapping for templates
     BuiltIn.Set_Suite_Variable    ${pcc_name}    pcc_${TOOLS_SYSTEM_IP}_tunnel_1
     ${code}=    Evaluate    binascii.b2a_base64('${pcc_name}')[:-1]    modules=binascii
     BuiltIn.Set_Suite_Variable    ${pcc_name_code}    ${code}
+    PcepOperations.Pcep_Topology_Precondition    ${CONFIG_SESSION}
     Start_Pcc_Mock
 
 Teardown_Everything
     [Documentation]    Suite cleanup
-    SSHLibrary.Get_File    pccmock.log
-    ${cnt}=    OperatingSystem.Get_File    pccmock.log
-    Log    ${cnt}
+    BGPcliKeywords.Store_File_To_Workspace    ${PCC_LOG_FILE}    ${PCC_LOG_FILE}
     RequestsLibrary.Delete_All_Sessions
     SSHLibrary.Close_All_Connections
 
 Start_Pcc_Mock
     [Documentation]    Starts pcc mock
-    ${command}=    NexusKeywords.Compose_Full_Java_Command    -jar ${filename} --reconnect 5 --local-address ${TOOLS_SYSTEM_IP} --remote-address ${ODL_SYSTEM_1_IP}:4189,${ODL_SYSTEM_2_IP}:4189,${ODL_SYSTEM_3_IP}:4189 --log-level INFO 2>&1 | tee pccmock.log
-    BuiltIn.Log    ${command}
-    SSHLibrary.Set_Client_Configuration    timeout=30s
-    SSHLibrary.Write    ${command}
-    ${output}=    SSHLibrary.Read_Until    started
-    BuiltIn.Log    ${output}
-
-Verify_Data_Reported
+    ${command}=    BuiltIn.Set_Variable    -jar ${filename} --reconnect 5 --local-address ${TOOLS_SYSTEM_IP} --remote-address ${ODL_SYSTEM_1_IP}:4189,${ODL_SYSTEM_2_IP}:4189,${ODL_SYSTEM_3_IP}:4189 --log-level INFO 2>&1 | tee ${PCC_LOG_FILE}
+    BGPcliKeywords.Start_Java_Tool_And_Verify_Connection    ${command}    started
+
+Pcep_Topology_Postcondition
     [Documentation]    Verifies if the tool reported expected data
     &{mapping}    BuiltIn.Create_Dictionary    IP=${TOOLS_SYSTEM_IP}    CODE=${pcc_name_code}    NAME=${pcc_name}    IP_ODL=${ODL_SYSTEM_${pcep_owner}_IP}
     BuiltIn.Wait_Until_Keyword_Succeeds    10x    5s    TemplatedRequests.Get_As_Json_Templated    ${DIR_WITH_TEMPLATES}${/}pcep_on_state    ${mapping}    ${living_session}
index f7b061b7bc3f960f56064e13930dfbaeedf8dece..47563ceeaf0029f1790bc881c18db9ed1cb7365a 100644 (file)
@@ -18,27 +18,27 @@ Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
 Library           SSHLibrary    timeout=10s
 Library           RequestsLibrary
-Variables         ${CURDIR}/../../../variables/Variables.py
-Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
-Resource          ${CURDIR}/../../../libraries/ClusterManagement.robot
-Resource          ${CURDIR}/../../../libraries/RemoteBash.robot
-Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
-Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
+Resource          ../../../variables/Variables.robot
+Resource          ../../../libraries/SetupUtils.robot
+Resource          ../../../libraries/ClusterManagement.robot
+Resource          ../../../libraries/SSHKeywords.robot
+Resource          ../../../libraries/TemplatedRequests.robot
+Resource          ../../../libraries/BGPcliKeywords.robot
+Resource          ../../../libraries/ExaBgpLib.robot
 
 *** Variables ***
 ${BGP_VAR_FOLDER}    ${CURDIR}/../../../variables/bgpclustering
 ${BGP_PEER_FOLDER}    ${CURDIR}/../../../variables/bgpclustering/bgp_peer_openconf
-${DEFAUTL_EXA_CFG}    exa.cfg
+${DEFAULT_EXA_CFG}    exa.cfg
 ${EXA_CMD}        env exabgp.tcp.port=1790 exabgp
-${PEER_CHECK_URL}    /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/peer/bgp:%2F%2F
 ${HOLDTIME}       180
 ${RIB_INSTANCE}    example-bgp-rib
 
 *** Test Cases ***
-Get Example Bgp Rib Owner
+Get_Example_Bgp_Rib_Owner
     [Documentation]    Find an odl node which is able to accept incomming connection. To this node netconf connector should be configured.
     ${rib_owner}    ${rib_candidates}=    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    ClusterManagement.Get_Owner_And_Successors_For_Device    example-bgp-rib
-    ...    Bgpcep    1
+    ...    org.opendaylight.mdsal.ServiceEntityType    1
     BuiltIn.Set Suite variable    ${rib_owner}
     BuiltIn.Log    ${ODL_SYSTEM_${rib_owner}_IP}
     BuiltIn.Set Suite variable    ${rib_candidates}
@@ -55,11 +55,12 @@ Reconfigure_ODL_To_Accept_Connection
 
 Start_ExaBgp_Peer
     [Documentation]    Starts exabgp
-    Start_Tool    ${DEFAUTL_EXA_CFG}
+    SSHKeywords.Virtual_Env_Activate_On_Current_Session    log_output=${True}
+    BGPcliKeywords.Start_Console_Tool    ${EXA_CMD}    ${DEFAULT_EXA_CFG}
 
-Verify ExaBgp Connected
+Verify_ExaBgp_Connected
     [Documentation]    Verifies exabgp's presence in operational ds.
-    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    Verify_Tools_Connection    ${living_session}
+    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    ExaBgpLib.Verify_ExaBgps_Connection    ${living_session}
 
 Isolate_Current_Owner_Member
     [Documentation]    Isolating cluster node which is connected with exabgp.
@@ -77,7 +78,7 @@ Verify_New_Rib_Owner
 
 Verify_ExaBgp_Reconnected
     [Documentation]    Verifies exabgp's presence in operational ds.
-    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    Verify_Tools_Connection    ${living_session}
+    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    ExaBgpLib.Verify_ExaBgps_Connection    ${living_session}
 
 Rejoin_Isolated_Member
     [Documentation]    Rejoin isolated node
@@ -87,13 +88,14 @@ Verify_New_Candidate
     [Documentation]    Verifies started node become candidate for example-bgp-rib
     BuiltIn.Wait_Until_Keyword_Succeeds    10x    5s    Verify_New_Rib_Candidate_Present    ${old_rib_owner}    ${living_node}
 
-Verify ExaBgp Still Connected
+Verify_ExaBgp_Still_Connected
     [Documentation]    Verifies exabgp's presence in operational ds
-    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    Verify_Tools_Connection    ${living_session}
+    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    ExaBgpLib.Verify_ExaBgps_Connection    ${living_session}
 
 Stop_ExaBgp_Peer
     [Documentation]    Stops exabgp
-    Stop_Tool
+    BGPcliKeywords.Stop_Console_Tool_And_Wait_Until_Prompt
+    SSHKeywords.Virtual_Env_Deactivate_On_Current_Session    log_output=${True}
 
 Delete_Bgp_Peer_Configuration
     [Documentation]    Revert the BGP configuration to the original state: without any configured peers
@@ -110,7 +112,7 @@ Setup_Everything
     SSHKeywords.Flexible_Mininet_Login    ${TOOLS_SYSTEM_USER}
     SSHKeywords.Virtual_Env_Create
     SSHKeywords.Virtual_Env_Install_Package    exabgp==3.4.16
-    Upload_Config_Files
+    ExaBgpLib.Upload_ExaBgp_Cluster_Config_Files    ${BGP_VAR_FOLDER}    ${DEFAULT_EXA_CFG}
 
 Teardown_Everything
     [Documentation]    Suite cleanup
@@ -118,54 +120,14 @@ Teardown_Everything
     RequestsLibrary.Delete_All_Sessions
     SSHLibrary.Close_All_Connections
 
-Start_Tool
-    [Arguments]    ${cfg_file}    ${mapping}={}
-    [Documentation]    Starts the tool
-    ${start_cmd}    BuiltIn.Set_Variable    ${EXA_CMD} ${cfg_file}
-    BuiltIn.Log    ${start_cmd}
-    SSHKeywords.Virtual_Env_Activate_On_Current_Session    log_output=${True}
-    ${output}=    SSHLibrary.Write    ${start_cmd}
-    BuiltIn.Log    ${output}
-
-Stop_Tool
-    [Documentation]    Stops the tool by sending ctrl+c
-    ${output}=    SSHLibrary.Read
-    BuiltIn.Log    ${output}
-    RemoteBash.Write_Bare_Ctrl_C
-    ${output}=    SSHLibrary.Read_Until_Prompt
-    BuiltIn.Log    ${output}
-    SSHKeywords.Virtual_Env_Deactivate_On_Current_Session    log_output=${True}
-
-Upload_Config_Files
-    [Documentation]    Uploads exabgp config files.
-    SSHLibrary.Put_File    ${BGP_VAR_FOLDER}/${DEFAUTL_EXA_CFG}    .
-    @{cfgfiles}=    SSHLibrary.List_Files_In_Directory    .    *.cfg
-    : FOR    ${cfgfile}    IN    @{cfgfiles}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/ODLIP1/${ODL_SYSTEM_1_IP}/g' ${cfgfile}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/ODLIP2/${ODL_SYSTEM_2_IP}/g' ${cfgfile}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/ODLIP3/${ODL_SYSTEM_3_IP}/g' ${cfgfile}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
-    \    SSHLibrary.Execute_Command    sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
-    \    ${stdout}=    SSHLibrary.Execute_Command    cat ${cfgfile}
-    \    Log    ${stdout}
-
 Verify_New_Rib_Owner_Elected
     [Arguments]    ${old_owner}    ${node_to_ask}
     [Documentation]    Verifies new owner was elected
-    ${owner}    ${candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device    example-bgp-rib    Bgpcep    ${node_to_ask}
+    ${owner}    ${candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device    example-bgp-rib    org.opendaylight.mdsal.ServiceEntityType    ${node_to_ask}
     BuiltIn.Should_Not_Be_Equal    ${old_owner}    ${owner}
 
 Verify_New_Rib_Candidate_Present
     [Arguments]    ${candidate}    ${node_to_ask}
     [Documentation]    Verifies candidate's presence.
-    ${owner}    ${candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device    example-bgp-rib    Bgpcep    ${node_to_ask}
+    ${owner}    ${candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device    example-bgp-rib    org.opendaylight.mdsal.ServiceEntityType    ${node_to_ask}
     BuiltIn.Should_Contain    ${candidates}    ${candidate}
-
-Verify_Tools_Connection
-    [Arguments]    ${session}    ${connected}=${True}
-    [Documentation]    Checks peer presence in operational datastore
-    ${exp_status_code}=    BuiltIn.Set_Variable_If    ${connected}    ${200}    ${404}
-    ${rsp}=    RequestsLibrary.Get Request    ${session}    ${PEER_CHECK_URL}${TOOLS_SYSTEM_IP}    timeout=10
-    BuiltIn.Log    ${rsp.content}
-    BuiltIn.Should_Be_Equal_As_Numbers    ${exp_status_code}    ${rsp.status_code}
index 6e21faf564226e10f89f4cb073b4d327cf6c8faf..bad7ac99fae8698a9c31a76331ba738151c37d6e 100644 (file)
@@ -69,7 +69,7 @@ Set_It_Up
     BuiltIn.Set_Suite_Variable    ${filename}    ${name}
 
 Tear_It_Down
-    [Documentation]    Download pccmock.log and Log its contents.
+    [Documentation]    Download bmpmock.log and Log its contents.
     ...    Compute and Log the diff between expected and actual normalized responses.
     ...    Close both HTTP client session and SSH connection to Mininet.
     SSHLibrary.Get_File    ${BMP_LOG_FILE}