Fix bgpcep-1node-userfeatures tests
[integration/test.git] / csit / libraries / BgpOperations.robot
index 97ba03c3e91052b0751968b8ac66aa608134bebd..62d3290b39447b0468b849dd3ebd4183361c1a7a 100644 (file)
@@ -12,8 +12,8 @@ Resource          TemplatedRequests.robot
 *** Variables ***
 ${BGP_BMP_DIR}    ${CURDIR}/../variables/bgpfunctional/bmp_basic/filled_structure
 ${BGP_BMP_FEAT_DIR}    ${CURDIR}/../variables/bgpfunctional/bmp_basic/empty_structure
-${BGP_RIB_URI}    ${OPERATIONAL_API}/bgp-rib:bgp-rib/rib/example-bgp-rib
-${BGP_TOPOLOGY_URI}    ${OPERATIONAL_TOPO_API}/topology/example-ipv4-topology
+${BGP_RIB_URI}    bgp-rib:bgp-rib/rib=example-bgp-rib
+${BGP_TOPOLOGY_URI}    ${TOPOLOGY_URL}=example-ipv4-topology
 ${VAR_BASE_BGP}    ${CURDIR}/../variables/bgpfunctional
 ${RIB_NAME}       example-bgp-rib
 ${OLD_AS_PATH}    \n"as-path": {},
@@ -22,6 +22,8 @@ ${NEW_AS_PATH}    ${EMPTY}
 ${NEW_IPV4_ROUTES_LINE}    ${EMPTY}
 ${OLD_IPV4_ROUTES_LINE}    \n"bgp-inet:ipv4-routes": {},
 ${BGP_CONFIG_SERVER_CMD}    bgp-connect -h ${ODL_SYSTEM_IP} -p 7644 add
+${VPNV4_ADDR_FAMILY}    vpnv4
+${DISPLAY_VPN4_ALL}    show-bgp --cmd "ip bgp ${VPNV4_ADDR_FAMILY} all"
 
 *** Keywords ***
 Start Quagga Processes On ODL
@@ -186,8 +188,9 @@ Verify Routes On Quagga
     [Documentation]    Verify routes on quagga
     ${output} =    Execute Show Command On quagga    ${dcgw_ip}    show ip bgp vrf ${rd}
     Log    ${output}
-    : FOR    ${ip}    IN    @{ip_list}
-    \    Should Contain    ${output}    ${ip}
+    FOR    ${ip}    IN    @{ip_list}
+        Should Contain    ${output}    ${ip}
+    END
 
 Delete BGP Config On Quagga
     [Arguments]    ${dcgw_ip}    ${bgp_id}    ${user}=bgpd    ${password}=sdncbgpc
@@ -218,8 +221,9 @@ Delete L3VPN on DCGW
     BgpOperations.Create Quagga Telnet Session    ${dcgw_ip}    bgpd    sdncbgpc
     BgpOperations.Execute Command On Quagga Telnet Session    configure terminal
     BgpOperations.Execute Command On Quagga Telnet Session    router bgp ${as_id}
-    : FOR    ${vpn}    IN    @{vpns}
-    \    BgpOperations.Execute Command On Quagga Telnet Session    no vrf ${vpn}
+    FOR    ${vpn}    IN    @{vpns}
+        BgpOperations.Execute Command On Quagga Telnet Session    no vrf ${vpn}
+    END
     BgpOperations.Execute Command On Quagga Telnet Session    end
 
 Verify L3VPN On DCGW
@@ -247,22 +251,23 @@ Create BGP Configuration On ODL
 AddNeighbor To BGP Configuration On ODL
     [Arguments]    &{Kwargs}
     [Documentation]    Associate the created L3VPN to a network-id received as dictionary argument
-    TemplatedRequests.Post_As_Json_Templated    folder=${VAR_BASE_BGP}/addNeighbor_bgp    mapping=${Kwargs}    session=session
+    CompareStream.Run_Keyword_If_Less_Than_Magnesium    TemplatedRequests.Post_As_Json_Templated    folder=${VAR_BASE_BGP}/addNeighbor_bgp    mapping=${Kwargs}    session=session
+    CompareStream.Run_Keyword_If_At_Least_Magnesium    TemplatedRequests.Post_As_Json_Templated    folder=${VAR_BASE_BGP}/addNeighborsContainer_bgp    mapping=${Kwargs}    session=session
 
 Get BGP Configuration On ODL
     [Arguments]    ${odl_session}
     [Documentation]    Get bgp configuration
     ${resp} =    RequestsLibrary.Get Request    ${odl_session}    ${CONFIG_API}/ebgp:bgp/
-    Log    ${resp.content}
-    [Return]    ${resp.content}
+    Log    ${resp.text}
+    [Return]    ${resp.text}
 
 Delete BGP Configuration On ODL
     [Arguments]    ${odl_session}
     [Documentation]    Delete BGP
     ${resp} =    RequestsLibrary.Delete Request    ${odl_session}    ${CONFIG_API}/ebgp:bgp/
-    Log    ${resp.content}
+    Log    ${resp.text}
     Should Be Equal As Strings    ${resp.status_code}    200
-    [Return]    ${resp.content}
+    [Return]    ${resp.text}
 
 Create External Tunnel Endpoint Configuration
     [Arguments]    &{Kwargs}
@@ -278,8 +283,8 @@ Get External Tunnel Endpoint Configuration
     [Arguments]    ${ip}
     [Documentation]    Get bgp configuration
     ${resp} =    RequestsLibrary.Get Request    session    ${CONFIG_API}/itm:dc-gateway-ip-list/dc-gateway-ip/${ip}/
-    Log    ${resp.content}
-    [Return]    ${resp.content}
+    Log    ${resp.text}
+    [Return]    ${resp.text}
 
 Teardown_Everything
     [Documentation]    Create and Log the diff between expected and actual responses, make sure Python tool was killed.
@@ -291,7 +296,7 @@ Teardown_Everything
 Check_Example_Bgp_Rib_Content
     [Arguments]    ${session}    ${substr}    ${error_message}=${JSONKEYSTR} not found, but expected.
     [Documentation]    Check the example-bgp-rib content for string
-    ${response}=    RequestsLibrary.Get Request    ${session}    ${BGP_RIB_URI}
+    ${response}=    RequestsLibrary.Get Request    ${session}    ${REST_API}/${BGP_RIB_URI}?content=nonconfig
     BuiltIn.Log    ${response.status_code}
     BuiltIn.Log    ${response.text}
     BuiltIn.Should_Contain    ${response.text}    ${substr}    ${error_message}    values=False
@@ -299,7 +304,7 @@ Check_Example_Bgp_Rib_Content
 Check_Example_Bgp_Rib_Does_Not_Contain
     [Arguments]    ${session}    ${substr}    ${error_message}=${JSONKEYSTR} found, but not expected.
     [Documentation]    Check the example-bgp-rib does not contain the string
-    ${response}=    RequestsLibrary.Get Request    ${session}    ${BGP_RIB_URI}
+    ${response}=    RequestsLibrary.Get Request    ${session}    ${REST_API}/${BGP_RIB_URI}?content=nonconfig
     BuiltIn.Log    ${response.status_code}
     BuiltIn.Log    ${response.text}
     BuiltIn.Should_Not_Contain    ${response.text}    ${substr}    ${error_message}    values=False
@@ -307,7 +312,7 @@ Check_Example_Bgp_Rib_Does_Not_Contain
 Check_Example_IPv4_Topology_Content
     [Arguments]    ${session}    ${string_to_check}=${EMPTY}
     [Documentation]    Check the example-ipv4-topology content for string
-    ${response}=    RequestsLibrary.Get Request    ${session}    ${BGP_TOPOLOGY_URI}
+    ${response}=    RequestsLibrary.Get Request    ${session}    ${REST_API}/${BGP_TOPOLOGY_URI}?content=nonconfig
     BuiltIn.Log    ${response.status_code}
     BuiltIn.Log    ${response.text}
     BuiltIn.Should_Contain    ${response.text}    ${string_to_check}
@@ -315,7 +320,7 @@ Check_Example_IPv4_Topology_Content
 Check_Example_IPv4_Topology_Does_Not_Contain
     [Arguments]    ${session}    ${string_to_check}
     [Documentation]    Check the example-ipv4-topology does not contain the string
-    ${response}=    RequestsLibrary.Get Request    ${session}    ${BGP_TOPOLOGY_URI}
+    ${response}=    RequestsLibrary.Get Request    ${session}    ${REST_API}/${BGP_TOPOLOGY_URI}?content=nonconfig
     BuiltIn.Log    ${response.status_code}
     BuiltIn.Log    ${response.text}
     BuiltIn.Should_Not_Contain    ${response.text}    ${string_to_check}
@@ -355,8 +360,8 @@ Odl_To_Play_Template
 Play_To_Odl_Template
     [Arguments]    ${totest}    ${dir}    ${ipv}=ipv4
     ${as_path} =    CompareStream.Set_Variable_If_At_Least_Neon    ${NEW_AS_PATH}    ${OLD_AS_PATH}
-    &{adj_rib_in}    BuiltIn.Create_Dictionary    PATH=peer/bgp:%2F%2F${TOOLS_SYSTEM_IP}/adj-rib-in    BGP_RIB=${RIB_NAME}    AS_PATH=${as_path}
-    &{effective_rib_in}    BuiltIn.Create_Dictionary    PATH=peer/bgp:%2F%2F${TOOLS_SYSTEM_IP}/effective-rib-in    BGP_RIB=${RIB_NAME}    AS_PATH=${as_path}
+    &{adj_rib_in}    BuiltIn.Create_Dictionary    PATH=peer\=bgp:%2F%2F${TOOLS_SYSTEM_IP}/adj-rib-in    BGP_RIB=${RIB_NAME}    AS_PATH=${as_path}
+    &{effective_rib_in}    BuiltIn.Create_Dictionary    PATH=peer\=bgp:%2F%2F${TOOLS_SYSTEM_IP}/effective-rib-in    BGP_RIB=${RIB_NAME}    AS_PATH=${as_path}
     &{loc_rib}    BuiltIn.Create_Dictionary    PATH=loc-rib    BGP_RIB=${RIB_NAME}    AS_PATH=${as_path}
     ${announce_hex} =    OperatingSystem.Get_File    ${dir}/${totest}/announce_${totest}.hex
     ${withdraw_hex} =    OperatingSystem.Get_File    ${dir}/${totest}/withdraw_${totest}.hex
@@ -401,12 +406,15 @@ Verify_Two_Hex_Messages_Are_Equal
     ${len_1} =    BuiltIn.Get_Length    ${hex_1}
     ${len_2} =    BuiltIn.Get_Length    ${hex_2}
     BuiltIn.Should_Be_Equal    ${len_1}    ${len_2}
-    ${sum_1} =    Sum_Hex_Message_Arguments_To_Integer    ${hex_1}
-    ${sum_2} =    Sum_Hex_Message_Arguments_To_Integer    ${hex_2}
+    ${sum_1} =    BgpRpcClient.Sum_Hex_Message    ${hex_1}
+    ${sum_2} =    BgpRpcClient.Sum_Hex_Message    ${hex_2}
     BuiltIn.Should_Be_Equal    ${sum_1}    ${sum_2}
 
-Sum_Hex_Message_Arguments_To_Integer
-    [Arguments]    ${hex_string}
-    [Documentation]    Converts hex message arguments to integers and sums them up and returns the sum.
-    ${final_sum} =    BuiltIn.Evaluate    sum(map(lambda x: int(x, 16), re.compile('[a-f\d]{2}').findall('${hex_string}'[32:])))    modules=re
-    [Return]    ${final_sum}
+Check BGP VPNv4 Nbr On ODL
+    [Arguments]    ${dcgw_count}    ${flag}=True    ${start}=${START_VALUE}
+    [Documentation]    Check all BGP VPNv4 neighbor on ODL
+    ${output} =    KarafKeywords.Issue Command On Karaf Console    ${DISPLAY_VPN4_ALL}
+    FOR    ${index}    IN RANGE    ${start}    ${dcgw_count}
+        BuiltIn.Run Keyword If    ${flag}==True    BuiltIn.Should Contain    ${output}    ${DCGW_IP_LIST[${index}]}
+        ...    ELSE    BuiltIn.Should Not Contain    ${output}    ${DCGW_IP_LIST[${index}]}
+    END