Fix empty uri for functional tests
[integration/test.git] / csit / suites / bgpcep / bgpfunct / 090_bgp_functional_rt_constrain_validation.robot
index 02fdc00cf300f37ce161da8c55ff5f9b2b4d74d6..c18254ad6b597ffcb0468deb105c84f9a9d59908 100644 (file)
@@ -36,20 +36,18 @@ Resource          ../../../variables/Variables.robot
 ${HOLDTIME}       180
 ${CONFIG_SESSION}    config-session
 ${RT_CONSTRAIN_DIR}    ${CURDIR}/../../../variables/bgpfunctional/rt_constrain
-${L3VPN_RIB_URI}    ${CURDIR}/../../../variables/bgpfunctional/rt_constrain/ext_l3vpn_rt_arg/rib
-${L3VPN_IPV4_DIR}    ${CURDIR}/../../../variables/bgpfunctional/l3vpn_ipv4
-${L3VPN_RSPEMPTY}    ${L3VPN_IPV4_DIR}/bgp-l3vpn-ipv4-empty.json
 ${EBGP_DIR}       ${CURDIR}/../../../variables/bgpfunctional/ebgp_peer
 ${PLAY_SCRIPT}    ${CURDIR}/../../../../tools/fastbgp/play.py
 ${RIB_NAME}       example-bgp-rib
 ${ODL_2_IP}       127.0.0.2
 ${ODL_3_IP}       127.0.0.3
 ${ODL_4_IP}       127.0.0.4
+${OLD_AS_PATH}    \n"as-path": {},
+${NEW_AS_PATH}    ${EMPTY}
 @{BGP_PEER_TYPES}    external    internal    internal
 @{BGP_PEER_AS_NUMBERS}    65000    64496    64496
 @{ODL_IP_INDICES_ALL}    2    3    4
 @{L3VPN_RT_CHECK}    false    true    false
-&{LOC_RIB}        PATH=loc-rib    BGP_RIB=${RIB_NAME}
 &{RT_CONSTRAIN_APP_PEER}    IP=${ODL_SYSTEM_IP}    BGP_RIB=${RIB_NAME}
 &{ADJ_RIB_OUT}    PATH=peer/bgp:%2F%2F${ODL_3_IP}/adj-rib-out    BGP_RIB=${RIB_NAME}
 
@@ -58,7 +56,7 @@ Reconfigure_ODL_To_Accept_Connection
     [Documentation]    Configures BGP peer module with initiate-connection set to false.
     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
     : FOR    ${i}    ${type}    IN ZIP    ${ODL_IP_INDICES_ALL}    ${BGP_PEER_TYPES}
-    \    &{ODL_CONFIG}=    BuiltIn.Create Dictionary    IP=${ODL_${i}_IP}    TYPE=${type}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}
+    \    &{ODL_CONFIG}=    BuiltIn.Create_Dictionary    IP=${ODL_${i}_IP}    TYPE=${type}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}
     \    ...    INITIATE=false    BGP_RIB=${RIB_NAME}    PASSIVE_MODE=true
     \    TemplatedRequests.Put_As_Xml_Templated    ${EBGP_DIR}    mapping=${ODL_CONFIG}    session=${CONFIG_SESSION}
 
@@ -68,21 +66,22 @@ Start_Bgp_Peers
     [Tags]    local_run
     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
     : FOR    ${i}    ${as_number}    IN ZIP    ${ODL_IP_INDICES_ALL}    ${BGP_PEER_AS_NUMBERS}
-    \    BuiltIn.Log Many    IP: ${ODL_${i}_IP}    as_number: ${as_number}
+    \    BuiltIn.Log_Many    IP: ${ODL_${i}_IP}    as_number: ${as_number}
     \    Start_Bgp_Peer    ${ODL_${i}_IP}    ${as_number}    800${i}    play.py.090.${i}
 
 Play_To_Odl_ext_l3vpn_rt_arg
     [Documentation]    This TC sends route-target route containing route-target argument from node 1 to odl
     ...    so odl can identify this peer as appropriate for advertizement when it recieves such route.
     Play_To_Odl_Non_Removal_BgpRpcClient2    ext_l3vpn_rt_arg    ${RT_CONSTRAIN_DIR}
-    &{EFFECTIVE_RIB_IN}=    BuiltIn.Create Dictionary    PATH=peer/bgp:%2F%2F${ODL_2_IP}/effective-rib-in    BGP_RIB=${RIB_NAME}
-    BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    TemplatedRequests.Get_As_Json_Templated    ${RT_CONSTRAIN_DIR}/ext_l3vpn_rt_arg/rib    mapping=${EFFECTIVE_RIB_IN}    session=${CONFIG_SESSION}
+    &{effective_rib_in}    BuiltIn.Create_Dictionary    PATH=peer/bgp:%2F%2F${ODL_2_IP}/effective-rib-in    BGP_RIB=${RIB_NAME}    AS_PATH=${AS_PATH}
+    BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    TemplatedRequests.Get_As_Json_Templated    ${RT_CONSTRAIN_DIR}/ext_l3vpn_rt_arg/rib    mapping=${effective_rib_in}    session=${CONFIG_SESSION}
     ...    verify=True
 
 Play_To_Odl_rt_constrain_type_0
     [Documentation]    Sends RT route from node 2 to odl and then checks that odl advertizes l3vpn route from previous TC.
     Play_To_Odl_Non_Removal_BgpRpcClient3    rt_constrain_type_0    ${RT_CONSTRAIN_DIR}
-    BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    TemplatedRequests.Get_As_Json_Templated    ${RT_CONSTRAIN_DIR}/rt_constrain_type_0/rib    mapping=${LOC_RIB}    session=${CONFIG_SESSION}
+    &{loc_rib}    BuiltIn.Create_Dictionary    PATH=loc-rib    BGP_RIB=${RIB_NAME}    AS_PATH=${AS_PATH}
+    BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    TemplatedRequests.Get_As_Json_Templated    ${RT_CONSTRAIN_DIR}/rt_constrain_type_0/rib    mapping=${loc_rib}    session=${CONFIG_SESSION}
     ...    verify=True
 
 Check_Presence_Of_l3vpn_Route_In_Node_2_Effective_Rib_In_Table
@@ -92,27 +91,26 @@ Check_Presence_Of_l3vpn_Route_In_Node_2_Effective_Rib_In_Table
 
 Check_l3vpn_Route_Advertisement_On_Each_Node
     [Documentation]    Checks that each node received or did not receive update message containing given hex message.
-    ${announce}=    OperatingSystem.Get_File    ${RT_CONSTRAIN_DIR}/ext_l3vpn_rt_arg/announce_ext_l3vpn_rt_arg.hex
-    ${announce_hex}=    String.Remove_String    ${announce}    \n
+    ${announce} =    OperatingSystem.Get_File    ${RT_CONSTRAIN_DIR}/ext_l3vpn_rt_arg/announce_ext_l3vpn_rt_arg.hex
+    ${announce_hex} =    String.Remove_String    ${announce}    \n
     Check_For_L3VPN_Odl_Avertisement    ${announce_hex}
 
 Play_To_Odl_rt_constrain_type_1
     [Documentation]    Sends RT route from node 3 to odl and then checks that odl does not advertize l3vpn route from previous TC,
     ...    that is that update message is empty.
     Play_To_Odl_Non_Removal_BgpRpcClient4    rt_constrain_type_1    ${RT_CONSTRAIN_DIR}
-    &{EFFECTIVE_RIB_IN}=    BuiltIn.Create Dictionary    PATH=peer/bgp:%2F%2F${ODL_4_IP}/effective-rib-in    BGP_RIB=${RIB_NAME}
-    BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    TemplatedRequests.Get_As_Json_Templated    ${RT_CONSTRAIN_DIR}/rt_constrain_type_1/rib    mapping=${EFFECTIVE_RIB_IN}    session=${CONFIG_SESSION}
+    &{effective_rib_in} =    BuiltIn.Create_Dictionary    PATH=peer/bgp:%2F%2F${ODL_4_IP}/effective-rib-in    BGP_RIB=${RIB_NAME}    AS_PATH=${AS_PATH}
+    BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    TemplatedRequests.Get_As_Json_Templated    ${RT_CONSTRAIN_DIR}/rt_constrain_type_1/rib    mapping=${effective_rib_in}    session=${CONFIG_SESSION}
     ...    verify=True
-    ${update}=    BgpRpcClient4.play_get
+    ${update} =    BgpRpcClient4.play_get
     BuiltIn.Should_Be_Equal    ${update}    ${Empty}
 
 Play_To_Odl_remove_rt
     [Documentation]    Removes RT from odl and then checks that second node withdrew l3vpn route and third node did not receive any message.
     BgpRpcClient3.play_clean
     Play_To_Odl_Routes_Removal_Template_BgpRpcClient3    rt_constrain_type_0    ${RT_CONSTRAIN_DIR}
-    ${uri}=    Resolve_Text_From_File    ${L3VPN_RIB_URI}    location.uri    mapping=${ADJ_RIB_OUT}
-    BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    Verify_Reported_Data    ${uri}    ${L3VPN_RSPEMPTY}
-    ${update}=    BgpRpcClient4.play_get
+    BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    Verify_Empty_Reported_Data
+    ${update} =    BgpRpcClient4.play_get
     BuiltIn.Should_Be_Equal    ${update}    ${Empty}
 
 Play_To_Odl_remove_routes
@@ -132,7 +130,7 @@ Delete_Bgp_Peers_Configuration
     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
     : FOR    ${i}    ${type}    IN ZIP    ${ODL_IP_INDICES_ALL}    ${BGP_PEER_TYPES}
-    \    &{ODL_CONFIG}=    BuiltIn.Create Dictionary    IP=${ODL_${i}_IP}    TYPE=${type}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}
+    \    &{ODL_CONFIG} =    BuiltIn.Create_Dictionary    IP=${ODL_${i}_IP}    TYPE=${type}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}
     \    ...    INITIATE=false    BGP_RIB=${RIB_NAME}    PASSIVE_MODE=true
     \    TemplatedRequests.Delete_Templated    ${EBGP_DIR}    mapping=${ODL_CONFIG}    session=${CONFIG_SESSION}
 
@@ -146,6 +144,8 @@ Start_Suite
     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
     SSHLibrary.Put_File    ${PLAY_SCRIPT}    .
     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
+    ${AS_PATH} =    CompareStream.Set_Variable_If_At_Least_Neon    ${NEW_AS_PATH}    ${OLD_AS_PATH}
+    BuiltIn.Set_Suite_Variable    ${AS_PATH}
 
 Stop_Suite
     [Documentation]    Suite teardown keyword
@@ -155,26 +155,26 @@ Stop_Suite
 Start_Bgp_Peer
     [Arguments]    ${ip}    ${as_number}    ${port}    ${filename}
     [Documentation]    Starts bgp peer.
-    ${command}=    BuiltIn.Set_Variable    python play.py --amount 0 --myip=${ip} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --asnumber=${as_number} --peerport=${ODL_BGP_PORT} --port=${port} --usepeerip --debug --allf --wfr 1 &> ${filename} &
+    ${command} =    BuiltIn.Set_Variable    python play.py --amount 0 --myip=${ip} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --asnumber=${as_number} --peerport=${ODL_BGP_PORT} --port=${port} --usepeerip --debug --allf --wfr 1 &> ${filename} &
     BuiltIn.Log    ${command}
-    ${output}=    SSHLibrary.Write    ${command}
+    ${output} =    SSHLibrary.Write    ${command}
 
 Play_To_Odl_Non_Removal_BgpRpcClient2
     [Arguments]    ${totest}    ${dir}    ${ipv}=ipv4
     [Documentation]    Read contents of file ${dir}/${totest}/announce_${totest}.hex and send it to odl.
-    ${announce_hex}=    OperatingSystem.Get_File    ${dir}/${totest}/announce_${totest}.hex
+    ${announce_hex} =    OperatingSystem.Get_File    ${dir}/${totest}/announce_${totest}.hex
     BgpRpcClient2.play_send    ${announce_hex}
 
 Play_To_Odl_Non_Removal_BgpRpcClient3
     [Arguments]    ${totest}    ${dir}    ${ipv}=ipv4
     [Documentation]    Read contents of file ${dir}/${totest}/announce_${totest}.hex and send it to odl.
-    ${announce_hex}=    OperatingSystem.Get_File    ${dir}/${totest}/announce_${totest}.hex
+    ${announce_hex} =    OperatingSystem.Get_File    ${dir}/${totest}/announce_${totest}.hex
     BgpRpcClient3.play_send    ${announce_hex}
 
 Play_To_Odl_Non_Removal_BgpRpcClient4
     [Arguments]    ${totest}    ${dir}    ${ipv}=ipv4
     [Documentation]    Read contents of file ${dir}/${totest}/announce_${totest}.hex and send it to odl.
-    ${announce_hex}=    OperatingSystem.Get_File    ${dir}/${totest}/announce_${totest}.hex
+    ${announce_hex} =    OperatingSystem.Get_File    ${dir}/${totest}/announce_${totest}.hex
     BgpRpcClient4.play_send    ${announce_hex}
 
 Play_To_Odl_Routes_Removal_Template_BgpRpcClient2
@@ -201,23 +201,23 @@ Play_To_Odl_Routes_Removal_Template_BgpRpcClient4
 Get_Update_Message_And_Compare_With_Hex_BgpRpcClient2
     [Arguments]    ${hex}    ${option}
     [Documentation]    Returns hex update message and compares it to hex.
-    ${update}=    BgpRpcClient2.play_get
-    BuiltIn.Run_Keyword_If    "${option}"=="true"    BuiltIn.Should_Be_Equal_As_Strings    ${update}    ${hex}
-    BuiltIn.Run_Keyword_If    "${option}"=="false"    BuiltIn.Should_Not_Be_Equal_As_Strings    ${update}    ${hex}
+    ${update} =    BgpRpcClient2.play_get
+    BuiltIn.Run_Keyword_If    "${option}" == "true"    BuiltIn.Should_Be_Equal_As_Strings    ${update}    ${hex}
+    BuiltIn.Run_Keyword_If    "${option}" == "false"    BuiltIn.Should_Not_Be_Equal_As_Strings    ${update}    ${hex}
 
 Get_Update_Message_And_Compare_With_Hex_BgpRpcClient3
     [Arguments]    ${hex}    ${option}
     [Documentation]    Returns hex update message and compares it to hex.
-    ${update}=    BgpRpcClient3.play_get
-    BuiltIn.Run_Keyword_If    "${option}"=="true"    BuiltIn.Should_Be_Equal_As_Strings    ${update}    ${hex}
-    BuiltIn.Run_Keyword_If    "${option}"=="false"    BuiltIn.Should_Not_Be_Equal_As_Strings    ${update}    ${hex}
+    ${update} =    BgpRpcClient3.play_get
+    BuiltIn.Run_Keyword_If    "${option}" == "true"    BuiltIn.Should_Be_Equal_As_Strings    ${update}    ${hex}
+    BuiltIn.Run_Keyword_If    "${option}" == "false"    BuiltIn.Should_Not_Be_Equal_As_Strings    ${update}    ${hex}
 
 Get_Update_Message_And_Compare_With_Hex_BgpRpcClient4
     [Arguments]    ${hex}    ${option}
     [Documentation]    Returns hex update message and compares it to hex.
-    ${update}=    BgpRpcClient4.play_get
-    BuiltIn.Run_Keyword_If    "${option}"=="true"    BuiltIn.Should_Be_Equal_As_Strings    ${update}    ${hex}
-    BuiltIn.Run_Keyword_If    "${option}"=="false"    BuiltIn.Should_Not_Be_Equal_As_Strings    ${update}    ${hex}
+    ${update} =    BgpRpcClient4.play_get
+    BuiltIn.Run_Keyword_If    "${option}" == "true"    BuiltIn.Should_Be_Equal_As_Strings    ${update}    ${hex}
+    BuiltIn.Run_Keyword_If    "${option}" == "false"    BuiltIn.Should_Not_Be_Equal_As_Strings    ${update}    ${hex}
 
 Check_For_L3VPN_Odl_Avertisement
     [Arguments]    ${announce_hex}
@@ -226,22 +226,21 @@ Check_For_L3VPN_Odl_Avertisement
     \    ${keyword_name}=    BuiltIn.Set_Variable    Get_Update_Message_And_Compare_With_Hex_BgpRpcClient${i}
     \    BuiltIn.Run_Keyword    ${keyword_name}    ${announce_hex}    ${option}
 
-Resolve_Text_From_File
-    [Arguments]    ${folder}    ${file_name}    ${mapping}={}
-    [Documentation]    Read and Log contents of file ${folder}/${file_name}, remove endline,
-    ...    perform safe substitution, return result.
-    ${file_path}=    BuiltIn.Set_Variable    ${folder}${/}${file_name}
-    ${template} =    OperatingSystem.Get_File    ${file_path}
-    BuiltIn.Log    ${template}
-    ${final_text} =    BuiltIn.Evaluate    string.Template('''${template}'''.rstrip()).safe_substitute(${mapping})    modules=string
-    [Return]    ${final_text}
-
 Verify_Reported_Data
     [Arguments]    ${url}    ${exprspfile}
     [Documentation]    Verifies expected response
-    ${expresponse}=    OperatingSystem.Get File    ${exprspfile}
+    ${expresponse} =    OperatingSystem.Get File    ${exprspfile}
     BuiltIn.Log    expected_response: ${expresponse}
-    ${rsp}=    RequestsLibrary.Get_Request    ${CONFIG_SESSION}    ${url}
+    ${rsp} =    RequestsLibrary.Get_Request    ${CONFIG_SESSION}    ${url}
     BuiltIn.Log    actual_response: ${rsp}
     BuiltIn.Log    actual_response_content: ${rsp.content}
     TemplatedRequests.Normalize_Jsons_And_Compare    ${expresponse}    ${rsp.content}
+
+Verify_Empty_Reported_Data
+    [Documentation]    Verify empty data response
+    CompareStream.Run_Keyword_If_At_Most_Fluorine    TemplatedRequests.Get_As_Json_Templated    ${RT_CONSTRAIN_DIR}${/}empty_l3vpn    session=${CONFIG_SESSION}    mapping=${ADJ_RIB_OUT}    verify=True
+    CompareStream.Run_Keyword_If_At_Least_Neon    Verify_Empty_Data_Neon
+
+Verify_Empty_Data_Neon
+    [Documentation]    Verify empty data on neon
+    TemplatedRequests.Get_As_Json_Templated    ${RT_CONSTRAIN_DIR}${/}empty_route    session=${CONFIG_SESSION}    mapping=${ADJ_RIB_OUT}    verify=True