Fix ibgp peer lsp base64 encoding
[integration/test.git] / csit / suites / bgpcep / bgpuser / ibgp_peer_lsp.robot
index 62e9db79e044fe4091c83e8d95ee0e91d98ece59..bebef36e76e403017f25e16c9f9632156e1853d7 100644 (file)
@@ -11,23 +11,21 @@ Documentation     Basic tests for iBGP peers.
 ...               carrying LSP State Information in BGP as described in
 ...               http://tools.ietf.org/html/draft-ietf-idr-te-lsp-distribution-03
 Suite Setup       Setup_Everything
-Suite Teardown    Teardown_Everything
+Suite Teardown    BgpOperations.Teardown_Everything
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
 Library           OperatingSystem
 Library           RequestsLibrary
 Library           DateTime
-Variables         ${CURDIR}/../../../variables/Variables.py
-Variables         ${CURDIR}/../../../variables/bgpuser/variables.py    ${TOOLS_SYSTEM_IP}    ${ODL_STREAM}
-Resource          ${CURDIR}/../../../libraries/BGPcliKeywords.robot
-Resource          ${CURDIR}/../../../libraries/BGPSpeaker.robot
-Resource          ${CURDIR}/../../../libraries/FailFast.robot
-Resource          ${CURDIR}/../../../libraries/KillPythonTool.robot
-Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
-Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
-Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
-Resource          ${CURDIR}/../../../libraries/Utils.robot
-Resource          ${CURDIR}/../../../libraries/WaitForFailure.robot
+Resource          ../../../libraries/BGPcliKeywords.robot
+Resource          ../../../libraries/BgpOperations.robot
+Resource          ../../../libraries/CompareStream.robot
+Resource          ../../../libraries/KarafKeywords.robot
+Resource          ../../../libraries/SetupUtils.robot
+Resource          ../../../libraries/SSHKeywords.robot
+Resource          ../../../libraries/TemplatedRequests.robot
+Resource          ../../../libraries/WaitForFailure.robot
+Resource          ../../../variables/Variables.robot
 
 *** Variables ***
 ${BGP_VARIABLES_FOLDER}    ${CURDIR}/../../../variables/bgpuser/
@@ -39,8 +37,6 @@ ${BGP_PEER_OPTIONS}    &>${BGP_PEER_LOG_FILE}
 ${DEFAULT_RIB_CHECK_PERIOD}    1s
 ${DEFAULT_RIB_CHECK_TIMEOUT}    10s
 ${BGP_PEER_LOG_LEVEL}    debug
-${ODL_LOG_LEVEL}    INFO
-${ODL_BGP_LOG_LEVEL}    DEFAULT
 ${JSONKEYSTR}     "linkstate-route"
 ${BGP_PEER_NAME}    example-bgp-peer
 ${DEVICE_NAME}    controller-config
@@ -48,6 +44,8 @@ ${CONFIG_SESSION}    config-session
 ${SKIP_PARAMS}    --skipattr
 ${RIB_INSTANCE}    example-bgp-rib
 ${PROTOCOL_OPENCONFIG}    ${RIB_INSTANCE}
+${OLD_ROUTE_KEY}    [0, 5, 0, 21, 7, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 0, 1, 0, 1, 5, 6, 7, 8]
+${NEW_ROUTE_KEY}    AAUAFQcAAAAAAAAAAQECAwQAAQABBQYHCA==
 
 *** Test Cases ***
 TC1_Configure_iBGP_Peer
@@ -60,26 +58,23 @@ TC1_Configure_iBGP_Peer
 TC1_Check_Example_Bgp_Rib_Is_Empty
     [Documentation]    Check RIB for none linkstate-routes
     [Tags]    critical
-    SSHLibrary.Switch Connection    bgp_peer_console
-    Check_Example_Bgp_Rib_Does_Not_Contain    ${JSONKEYSTR}
+    BgpOperations.Check_Example_Bgp_Rib_Does_Not_Contain    ${CONFIG_SESSION}    ${JSONKEYSTR}
 
 TC1_Connect_BGP_Peer
     [Documentation]    Connect BGP peer with advertising the routes without mandatory params like LOC_PREF.
     [Tags]    critical
-    SSHLibrary.Switch Connection    bgp_peer_console
+    BuiltIn.Run_Keyword_And_Ignore_Error    KarafKeywords.Log_Message_To_Controller_Karaf    Error = WELL_KNOWN_ATTR_MISSING is EXPECTED in this test case, and should be thrown when missing mandatory attributes.
     BGPcliKeywords.Start_Console_Tool    ${BGP_PEER_COMMAND} ${SKIP_PARAMS}    ${BGP_PEER_OPTIONS}
     BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
 
 TC1_Check_Example_Bgp_Rib
     [Documentation]    Check RIB for not containig linkstate-route(s), because update messages were not good.
     [Tags]    critical
-    SSHLibrary.Switch Connection    bgp_peer_console
-    WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout    ${DEFAULT_RIB_CHECK_TIMEOUT}    ${DEFAULT_RIB_CHECK_PERIOD}    Check_Example_Bgp_Rib_Does_Not_Contain    ${JSONKEYSTR}
+    WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout    ${DEFAULT_RIB_CHECK_TIMEOUT}    ${DEFAULT_RIB_CHECK_PERIOD}    BgpOperations.Check_Example_Bgp_Rib_Does_Not_Contain    ${CONFIG_SESSION}    ${JSONKEYSTR}
 
 TC1_Disconnect_BGP_Peer
     [Documentation]    Stop BGP peer & store logs
     [Tags]    critical
-    SSHLibrary.Switch Connection    bgp_peer_console
     BGPcliKeywords.Stop_Console_Tool
     BGPcliKeywords.Store_File_To_Workspace    ${BGP_PEER_LOG_FILE}    tc1_${BGP_PEER_LOG_FILE}
 
@@ -97,26 +92,25 @@ TC2_Configure_iBGP_Peer
 TC2_Check_Example_Bgp_Rib_Is_Empty
     [Documentation]    Check RIB for none linkstate-routes
     [Tags]    critical
-    SSHLibrary.Switch Connection    bgp_peer_console
-    Check_Example_Bgp_Rib_Does_Not_Contain    ${JSONKEYSTR}
+    BgpOperations.Check_Example_Bgp_Rib_Does_Not_Contain    ${CONFIG_SESSION}    ${JSONKEYSTR}
 
 TC2_Connect_BGP_Peer
     [Documentation]    Connect BGP peer
     [Tags]    critical
-    SSHLibrary.Switch Connection    bgp_peer_console
     BGPcliKeywords.Start_Console_Tool    ${BGP_PEER_COMMAND}    ${BGP_PEER_OPTIONS}
     BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
 
 TC2_Check_Example_Bgp_Rib
-    [Documentation]    Check RIB for linkstate-route(s)
+    [Documentation]    Check RIB for linkstate-route(s) and check all of their attributes.
     [Tags]    critical
-    SSHLibrary.Switch Connection    bgp_peer_console
-    BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_RIB_CHECK_TIMEOUT}    ${DEFAULT_RIB_CHECK_PERIOD}    Check_Example_Bgp_Rib_Content    ${JSONKEYSTR}
+    ${route_key} =    CompareStream.Set_Variable_If_At_Least_Fluorine    ${NEW_ROUTE_KEY}    ${OLD_ROUTE_KEY}
+    &{mapping}    BuiltIn.Create_Dictionary    IP=${TOOLS_SYSTEM_IP}    ROUTE_KEY=${route_key}
+    BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_RIB_CHECK_TIMEOUT}    ${DEFAULT_RIB_CHECK_PERIOD}    TemplatedRequests.Get_As_Json_Templated    ${BGP_VARIABLES_FOLDER}/lsp/effective_rib_in    mapping=${mapping}    session=${CONFIG_SESSION}
+    ...    verify=True
 
 TC2_Disconnect_BGP_Peer
     [Documentation]    Stop BGP peer & store logs
     [Tags]    critical
-    SSHLibrary.Switch Connection    bgp_peer_console
     BGPcliKeywords.Stop_Console_Tool
     BGPcliKeywords.Store_File_To_Workspace    ${BGP_PEER_LOG_FILE}    tc2_${BGP_PEER_LOG_FILE}
 
@@ -131,36 +125,10 @@ Setup_Everything
     ...    prepare directories for responses, put Python tool to mininet machine, setup imported resources.
     SetupUtils.Setup_Utils_For_Setup_And_Teardown
     SSHLibrary.Set_Default_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
-    SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}    alias=bgp_peer_console
-    Utils.Flexible_Mininet_Login
+    SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}
+    SSHKeywords.Flexible_Mininet_Login
     SSHKeywords.Require_Python
     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/play.py
-    RequestsLibrary.Create_Session    operational    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}${OPERATIONAL_API}    auth=${AUTH}
     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
-    KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${ODL_LOG_LEVEL}
-    KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${ODL_BGP_LOG_LEVEL} org.opendaylight.bgpcep
-    KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${ODL_BGP_LOG_LEVEL} org.opendaylight.protocol
-
-Teardown_Everything
-    [Documentation]    Create and Log the diff between expected and actual responses, make sure Python tool was killed.
-    ...    Tear down imported Resources.
-    KillPythonTool.Search_And_Kill_Remote_Python    'play\.py'
-    RequestsLibrary.Delete_All_Sessions
-    SSHLibrary.Close_All_Connections
-
-Check_Example_Bgp_Rib_Content
-    [Arguments]    ${substr}    ${error_message}=${JSONKEYSTR} not found, but expected.
-    [Documentation]    Check the example-bgp-rib content for string
-    ${response}=    RequestsLibrary.Get Request    operational    bgp-rib:bgp-rib/rib/example-bgp-rib
-    BuiltIn.Log    ${response.status_code}
-    BuiltIn.Log    ${response.text}
-    BuiltIn.Should_Contain    ${response.text}    ${substr}    ${error_message}    values=False
-
-Check_Example_Bgp_Rib_Does_Not_Contain
-    [Arguments]    ${substr}    ${error_message}=${JSONKEYSTR} found, but not expected.
-    [Documentation]    Check the example-bgp-rib does not contain the string
-    ${response}=    RequestsLibrary.Get Request    operational    bgp-rib:bgp-rib/rib/example-bgp-rib
-    BuiltIn.Log    ${response.status_code}
-    BuiltIn.Log    ${response.text}
-    BuiltIn.Should_Not_Contain    ${response.text}    ${substr}    ${error_message}    values=False
+    KarafKeywords.Setup_Karaf_Keywords