Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / genius / ITM_Direct_Tunnels.robot
index e7eed43acdd4e907c9bbb1d1b5ee4cdbbd9da5c4..06673592e0f2fcaa4b1060623765b4b5d2f70003 100644 (file)
@@ -4,156 +4,109 @@ Suite Setup       ITM Direct Tunnels Start Suite
 Suite Teardown    ITM Direct Tunnels Stop Suite
 Test Setup        Genius Test Setup
 Test Teardown     Genius Test Teardown    ${data_models}
+Library           Collections
 Library           OperatingSystem
-Library           String
 Library           RequestsLibrary
-Variables         ../../variables/genius/Modules.py
-Resource          ../../libraries/DataModels.robot
-Library           Collections
-Resource          ../../libraries/Utils.robot
-Library           re
-Resource          ../../libraries/VpnOperations.robot
+Library           String
 Resource          ../../libraries/ClusterManagement.robot
-Resource          ../../libraries/KarafKeywords.robot
-Resource          ../../libraries/Utils.robot
+Resource          ../../libraries/DataModels.robot
 Resource          ../../libraries/Genius.robot
+Resource          ../../libraries/KarafKeywords.robot
 Resource          ../../variables/netvirt/Variables.robot
-Resource          ../../variables/Variables.robot
 Resource          ../../libraries/OVSDB.robot
+Resource          ../../libraries/ToolsSystem.robot
+Resource          ../../libraries/Utils.robot
+Resource          ../../libraries/VpnOperations.robot
+Resource          ../../variables/Variables.robot
+Variables         ../../variables/genius/Modules.py
 
 *** Variables ***
-${VLAN}           0
 
 *** Test Cases ***
 Create and Verify VTEP
     [Documentation]    This testcase creates a Internal Transport Manager - ITM tunnel between 2 DPNs
-    ${Dpn_id_1}    Genius.Get Dpn Ids    ${conn_id_1}
-    ${Dpn_id_2}    Genius.Get Dpn Ids    ${conn_id_2}
-    ${gateway-ip}=    Set Variable    0.0.0.0
-    Genius.Create Vteps    ${Dpn_id_1}    ${Dpn_id_2}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${VLAN}    ${gateway-ip}
-    Wait Until Keyword Succeeds    40    10    Get ITM    ${itm_created[0]}    ${subnet}    ${VLAN}
-    ...    ${Dpn_id_1}    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}    ${TOOLS_SYSTEM_2_IP}
-    ${type}    Set Variable    odl-interface:tunnel-type-vxlan
-    ${tunnel-1}    Wait Until Keyword Succeeds    40    20    Get_Tunnel    ${Dpn_id_1}    ${Dpn_id_2}
-    ${tunnel-2}    Wait Until Keyword Succeeds    40    20    Get_Tunnel    ${Dpn_id_2}    ${Dpn_id_1}
-    ${tunnel-type}=    Set Variable    type: vxlan
-    Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
-    Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
-    Wait Until Keyword Succeeds    40    10    Ovs Verification For 2 Dpn    ${conn_id_1}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}
-    ...    ${tunnel-1}    ${tunnel-type}
-    Wait Until Keyword Succeeds    40    10    Ovs Verification For 2 Dpn    ${conn_id_2}    ${TOOLS_SYSTEM_2_IP}    ${TOOLS_SYSTEM_IP}
-    ...    ${tunnel-2}    ${tunnel-type}
-    ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/itm-state:tunnels_state/
-    ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
-    Should Be Equal As Strings    ${resp.status_code}    200
-    Should Contain    ${resp.content}    ${Dpn_id_1}    ${tunnel-1}
-    Should Contain    ${resp.content}    ${Dpn_id_2}    ${tunnel-2}
-    ${Port_num1}    Get Port Number    ${conn_id_1}    ${Bridge}    ${tunnel-1}
-    ${Port_num2}    Get Port Number    ${conn_id_2}    ${Bridge}    ${tunnel-2}
-    ${check-3}    Wait Until Keyword Succeeds    40    10    Genius.Check Table0 Entry For 2 Dpn    ${conn_id_1}    ${Bridge}
-    ...    ${Port_num1}
-    ${check-4}    Wait Until Keyword Succeeds    40    10    Genius.Check Table0 Entry For 2 Dpn    ${conn_id_2}    ${Bridge}
-    ...    ${Port_num2}
+    Genius.Create Vteps    ${NO_VLAN}    ${gateway_ip}
+    BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Get ITM    ${itm_created[0]}
+    ${type} =    BuiltIn.Set Variable    odl-interface:tunnel-type-vxlan
+    Genius.Update Dpn id list and get tunnels    ${type}    dpn-teps-state
+    Genius.Verify Response Code Of Dpn Endpointconfig API
+    BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Ovs Interface Verification
+    ${resp} =    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/itm-state:tunnels_state/
+    BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
+    BuiltIn.Wait Until Keyword Succeeds    60    5    Genius.Verify Tunnel Status As Up
+    BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Verify Table0 Entry After fetching Port Number
 
 Verify VTEP After Restarting OVS
     [Documentation]    Verify Testcase, Verifying tunnel state by restarting OVS
-    Wait Until Keyword Succeeds    20    2    Genius.Verify Tunnel Status as UP    TZA
+    BuiltIn.Wait Until Keyword Succeeds    20    2    Genius.Verify Tunnel Status As Up
     OVSDB.Restart OVSDB    ${TOOLS_SYSTEM_IP}
-    Wait Until Keyword Succeeds    20    2    Genius.Verify Tunnel Status as UP    TZA
 
 Verify VTEP After Restarting Controller
     [Documentation]    Verify Testcase, Verifying tunnel state by restarting CONTROLLER
-    Genius.Verify Tunnel Status as UP    TZA
+    BuiltIn.Wait Until Keyword Succeeds    30    3    Genius.Verify Tunnel Status As Up
     ClusterManagement.Stop_Members_From_List_Or_All
     ClusterManagement.Start_Members_From_List_Or_All
-    Wait Until Keyword Succeeds    60    3    ClusterManagement.Check Status Of Services Is OPERATIONAL
-    Wait Until Keyword Succeeds    30    3    Genius.Verify Tunnel Status as UP    TZA
-
-Verify Tunnels By Disabling BFD
-    [Documentation]    This test case will verify tunnels after disabling BFD and verifies tunnel status as unknown after stopping OVS.
-    ${result} =    Run Keyword And Return Status    Verify Tunnel Monitoring is on
-    Run Keyword If    '${result}' == 'True'    Disable_Tunnel_Monitoring
-    ${tunnels_on_OVS} =    Genius.Get Tunnels On OVS    ${conn_id_1}
-    OVSDB.Stop OVS    ${TOOLS_SYSTEM_IP}
-    Genius.Verify Tunnel Status    ${tunnels_on_OVS}    UNKNOWN
-    OVSDB.Start OVS    ${TOOLS_SYSTEM_IP}
-    Wait Until Keyword Succeeds    20    2    Genius.Verify Tunnel Status as UP    TZA
+    BuiltIn.Wait Until Keyword Succeeds    60    3    ClusterManagement.Check Status Of Services Is OPERATIONAL    @{GENIUS_DIAG_SERVICES}
+    BuiltIn.Wait Until Keyword Succeeds    30    3    Genius.Verify Tunnel Status As Up
 
-Verify Tunnels By Enabling BFD
-    [Documentation]    This test case will check the tunnel exists by bringing up/down a switch and check tunnels exist by enabling BFD
-    ${result}    Run Keyword And Return Status    Verify Tunnel Monitoring is on
-    Run Keyword If    '${result}' == 'False'    Enable_Tunnel_monitoring
-    Verify Tunnel State After OVS Restart    ${TOOLS_SYSTEM_IP}
-    Verify Tunnel State After OVS Restart    ${TOOLS_SYSTEM_2_IP}
+Verify Tunnels By Enabling/Disabling BFD
+    [Documentation]    Verify tunnel creation by enabling and disabling BFD one after another with respect to the branch in such a way default value is retained at last.
+    CompareStream.Run_Keyword_If_At_Least_Neon    Verify Tunnels By Enabling BFD
+    CompareStream.Run_Keyword_If_At_Least_Neon    Verify Tunnels By Disabling BFD
+    CompareStream.Run_Keyword_If_Less_Than_Neon    Verify Tunnels By Disabling BFD
+    CompareStream.Run_Keyword_If_Less_Than_Neon    Verify Tunnels By Enabling BFD
 
 Delete and Verify VTEP
     [Documentation]    This Delete testcase , deletes the ITM tunnel created between 2 dpns.
-    ${Dpn_id_1}    Genius.Get Dpn Ids    ${conn_id_1}
-    ${Dpn_id_2}    Genius.Get Dpn Ids    ${conn_id_2}
-    ${tunnel-1}    Get_Tunnel    ${Dpn_id_1}    ${Dpn_id_2}
-    ${tunnel-2}    Get_Tunnel    ${Dpn_id_2}    ${Dpn_id_1}
-    Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/subnets/${subnet}%2F24/vteps/${Dpn_id_1}/${port_name}
-    Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/subnets/${subnet}%2F24/vteps/${Dpn_id_2}/${port_name}
-    ${output}    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW}
+    ${tunnel_list} =    Genius.Get Tunnels List
+    FOR    ${dpn_id}    IN    @{DPN_ID_LIST}
+        CompareStream.Run_Keyword_If_Less_Than_Sodium    Utils.Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/subnets/${SUBNET}%2F16/vteps/${dpn_id}/${port_name}
+        CompareStream.Run_Keyword_If_At_Least_Sodium    Utils.Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/vteps/${dpn_id}
+    END
+    ${output} =    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW}
     BuiltIn.Should Not Contain    ${output}    ${itm_created[0]}
-    Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/
-    ${resp}    Utils.Get Data From URI    session    ${CONFIG_API}/itm:transport-zones/
+    Utils.Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/
+    ${resp}    Utils.Get Data From URI    session    ${CONFIG_API}/itm:transport-zones/
     BuiltIn.Should Not Contain    ${resp}    ${itm_created[0]}
-    ${Ovs-del-1}    Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${conn_id_1}    ${tunnel-1}
-    ${Ovs-del-2}    Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${conn_id_2}    ${tunnel-2}
+    BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Verify Deleted Tunnels On OVS    ${tunnel_list}    ${resp}
+    BuiltIn.Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${tunnel_list}
 
 *** Keywords ***
-Get_Tunnel
-    [Arguments]    ${src}    ${dst}
-    [Documentation]    This Keyword Gets the Tunnel Interface name which has been created between 2 DPNS by passing source , destination DPN Ids along with the type of tunnel which is configured.
-    ${resp}    RequestsLibrary.Get Request    session    ${CONFIG_API}/itm-state:dpn-teps-state/dpns-teps/${src}/remote-dpns/${dst}/
-    log    ${resp.content}
-    ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
-    Should Be Equal As Strings    ${resp.status_code}    200
-    Should Contain    ${resp.content}    ${dst}
-    ${json}=    evaluate    json.loads('''${resp.content}''')    json
-    ${return}    Run Keyword And Return Status    Should contain    ${resp.content}    tunnel-name
-    log    ${return}
-    ${ret}    Run Keyword If    '${return}'=='True'    Check_Interface_Name    ${json["remote-dpns"][0]}    tunnel-name
-    [Return]    ${ret}
-
-Check_Interface_Name
-    [Arguments]    ${json}    ${expected_tunnel_interface_name}
-    [Documentation]    This keyword Checks the Tunnel interface name is tunnel-interface-names in the output or not .
-    ${Tunnels}    Collections.Get From Dictionary    ${json}    ${expected_tunnel_interface_name}
-    Log    ${Tunnels}
-    [Return]    ${Tunnels}
-
 Enable_Tunnel_Monitoring
     [Documentation]    In this we will enable tunnel monitoring by tep:enable command running in karaf console
-    ${output}    Issue_Command_On_Karaf_Console    tep:enable-tunnel-monitor true
+    KarafKeywords.Issue_Command_On_Karaf_Console    tep:enable-tunnel-monitor true
 
 Verify Tunnel State After OVS Restart
     [Arguments]    ${TOOLS_SYSTEM_IP}
     [Documentation]    In this we will Verify Tunnel State by Stopping/Starting Switch
     OVSDB.Stop OVS    ${TOOLS_SYSTEM_IP}
-    Wait Until Keyword Succeeds    2min    20 sec    Verify Tunnel Down
+    BuiltIn.Wait Until Keyword Succeeds    2min    20 sec    Verify Tunnel Down
     OVSDB.Start OVS    ${TOOLS_SYSTEM_IP}
-    Wait Until Keyword Succeeds    2min    20 sec    Genius.Verify Tunnel Status as UP    TZA
+    BuiltIn.Wait Until Keyword Succeeds    2min    20 sec    Genius.Verify Tunnel Status As Up
 
 Verify Tunnel Down
     [Documentation]    In this we will check whether tunnel is in down or not
-    ${output}=    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW_STATE}
-    Should Contain    ${output}    DOWN
-
-Get Port Number
-    [Arguments]    ${connection_id}    ${Bridgename}    ${tunnel}
-    [Documentation]    In this we get Port Number to check table0 entry for 2 Dpn
-    Switch Connection    ${connection_id}
-    ${check-1}    Execute Command    sudo ovs-ofctl -O OpenFlow13 show ${Bridgename}
-    Log    ${check-1}
-    ${lines}    Get Lines Containing String    ${check-1}    ${tunnel}
-    Log    ${lines}
-    ${port}    Get Regexp Matches    ${lines}    \\d+
-    ${port_num}    Get From List    ${port}    0
-    Should Contain    ${check-1}    ${port_num}
-    [Return]    ${port_num}
+    ${output}=    KarafKeywords.Issue_Command_On_Karaf_Console    ${TEP_SHOW_STATE}
+    BuiltIn.Should Contain    ${output}    DOWN
 
 Disable_Tunnel_Monitoring
     [Documentation]    In this we will disable tunnel monitoring by tep:enable command running in karaf console
-    ${output}    Issue_Command_On_Karaf_Console    tep:enable-tunnel-monitor false
+    KarafKeywords.Issue_Command_On_Karaf_Console    tep:enable-tunnel-monitor false
+
+Verify Tunnels By Enabling BFD
+    [Documentation]    Verify tunnel creation by enabling BFD monitoring.
+    ${result} =    BuiltIn.Run Keyword And Return Status    Genius.Verify Tunnel Monitoring Status    ${TUNNEL_MONITOR_ON}
+    BuiltIn.Run Keyword If    '${result}' == 'False'    Enable_Tunnel_monitoring
+    FOR    ${tools_ip}    IN    @{TOOLS_SYSTEM_ALL_IPS}
+        Verify Tunnel State After OVS Restart    ${tools_ip}
+    END
+
+Verify Tunnels By Disabling BFD
+    [Documentation]    Verify tunnel creation by disabling BFD monitoring.
+    ${result} =    Run Keyword And Return Status    Genius.Verify Tunnel Monitoring Status    ${TUNNEL_MONITOR_ON}
+    BuiltIn.Run Keyword If    '${result}' == 'True'    Disable_Tunnel_Monitoring
+    ${tunnels_on_OVS} =    Genius.Get Tunnels On OVS    ${TOOLS_SYSTEM_ALL_CONN_IDS[0]}
+    OVSDB.Stop OVS    ${TOOLS_SYSTEM_IP}
+    Genius.Verify Tunnel Status    UNKNOWN    ${tunnels_on_OVS}
+    OVSDB.Start OVS    ${TOOLS_SYSTEM_IP}
+    BuiltIn.Wait Until Keyword Succeeds    10s    1s    Genius.Verify Tunnel Status As Up