ef93f896ae561bc26e96d568c700d5d050beafa1
[integration/test.git] / csit / suites / genius / ITM_Direct_Tunnels.robot
1 *** Settings ***
2 Documentation     This test suite is to by-pass interface manager and create/delete the tunnels between the switches directly inorder for ITM to scale and build mesh among more number of switches.
3 Suite Setup       ITM Direct Tunnels Start Suite
4 Suite Teardown    ITM Direct Tunnels Stop Suite
5 Test Teardown     Genius Test Teardown    ${data_models}
6 Library           OperatingSystem
7 Library           String
8 Library           RequestsLibrary
9 Variables         ../../variables/genius/Modules.py
10 Resource          ../../libraries/DataModels.robot
11 Library           Collections
12 Resource          ../../libraries/Utils.robot
13 Library           re
14 Resource          ../../libraries/VpnOperations.robot
15 Resource          ../../libraries/ClusterManagement.robot
16 Resource          ../../libraries/KarafKeywords.robot
17 Resource          ../../libraries/Utils.robot
18 Resource          ../../libraries/Genius.robot
19 Resource          ../../variables/Variables.robot
20 Resource          ../../libraries/OVSDB.robot
21
22 *** Variables ***
23
24 *** Test Cases ***
25 Create and Verify VTEP
26     [Documentation]    This testcase creates a Internal Transport Manager - ITM tunnel between 2 DPNs
27     ${Dpn_id_1}    Genius.Get Dpn Ids    ${conn_id_1}
28     ${Dpn_id_2}    Genius.Get Dpn Ids    ${conn_id_2}
29     ${vlan}=    Set Variable    0
30     ${gateway-ip}=    Set Variable    0.0.0.0
31     Genius.Create Vteps    ${Dpn_id_1}    ${Dpn_id_2}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
32     Wait Until Keyword Succeeds    40    10    Get ITM    ${itm_created[0]}    ${subnet}    ${vlan}
33     ...    ${Dpn_id_1}    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}    ${TOOLS_SYSTEM_2_IP}
34     ${type}    Set Variable    odl-interface:tunnel-type-vxlan
35     ${tunnel-1}    Wait Until Keyword Succeeds    40    20    Get_Tunnel    ${Dpn_id_1}    ${Dpn_id_2}
36     ${tunnel-2}    Wait Until Keyword Succeeds    40    20    Get_Tunnel    ${Dpn_id_2}    ${Dpn_id_1}
37     ${tunnel-type}=    Set Variable    type: vxlan
38     Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
39     Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
40     Wait Until Keyword Succeeds    40    10    Ovs Verification For 2 Dpn    ${conn_id_1}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}
41     ...    ${tunnel-1}    ${tunnel-type}
42     Wait Until Keyword Succeeds    40    10    Ovs Verification For 2 Dpn    ${conn_id_2}    ${TOOLS_SYSTEM_2_IP}    ${TOOLS_SYSTEM_IP}
43     ...    ${tunnel-2}    ${tunnel-type}
44     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/itm-state:tunnels_state/
45     ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
46     Should Be Equal As Strings    ${resp.status_code}    200
47     Should Contain    ${resp.content}    ${Dpn_id_1}    ${tunnel-1}
48     Should Contain    ${resp.content}    ${Dpn_id_2}    ${tunnel-2}
49     ${Port_num1}    Get Port Number    ${conn_id_1}    ${Bridge-1}    ${tunnel-1}
50     ${Port_num2}    Get Port Number    ${conn_id_2}    ${Bridge-2}    ${tunnel-2}
51     ${check-3}    Wait Until Keyword Succeeds    40    10    Genius.Check Table0 Entry For 2 Dpn    ${conn_id_1}    ${Bridge-1}
52     ...    ${Port_num1}
53     ${check-4}    Wait Until Keyword Succeeds    40    10    Genius.Check Table0 Entry For 2 Dpn    ${conn_id_2}    ${Bridge-2}
54     ...    ${Port_num2}
55
56 Verify VTEP After Restarting OVS
57     [Documentation]    Verify Testcase, Verifying tunnel state by restarting OVS
58     Genius.Verify Tunnel Status as UP    TZA
59     OVSDB.Restart OVSDB    ${TOOLS_SYSTEM_IP}
60     Wait Until Keyword Succeeds    30    3    Genius.Verify Tunnel Status as UP    TZA
61
62 Verify VTEP After Restarting Controller
63     [Documentation]    Verify Testcase, Verifying tunnel state by restarting CONTROLLER
64     Genius.Verify Tunnel Status as UP    TZA
65     ClusterManagement.Stop_Members_From_List_Or_All
66     ClusterManagement.Start_Members_From_List_Or_All
67     Wait Until Keyword Succeeds    60    3    Genius.Check System Status
68     Wait Until Keyword Succeeds    30    3    Genius.Verify Tunnel Status as UP    TZA
69
70 Verify Tunnels By Disabling BFD
71     [Documentation]    This test case will verify tunnels after disabling BFD and verifies tunnel status as unknown after stopping OVS.
72     ${result} =    Run Keyword And Return Status    Verify Tunnel Monitoring is on
73     Run Keyword If    '${result}' == 'True'    Disable_Tunnel_Monitoring
74     ${tunnels_on_OVS} =    Genius.Get Tunnels On OVS    ${conn_id_1}
75     OVSDB.Stop OVS    ${TOOLS_SYSTEM_IP}
76     Genius.Verify Tunnel Status    ${tunnels_on_OVS}    UNKNOWN
77     OVSDB.Start OVS    ${TOOLS_SYSTEM_IP}
78     Genius.Verify Tunnel Status as UP    TZA
79
80 Verify Tunnels By Enabling BFD
81     [Documentation]    This test case will check the tunnel exists by bringing up/down a switch and check tunnels exist by enabling BFD
82     ${result}    Run Keyword And Return Status    Verify Tunnel Monitoring is on
83     Run Keyword If    '${result}' == 'False'    Enable_Tunnel_monitoring
84     Verify Tunnel State After OVS Restart    ${TOOLS_SYSTEM_IP}
85     Verify Tunnel State After OVS Restart    ${TOOLS_SYSTEM_2_IP}
86
87 Delete and Verify VTEP
88     [Documentation]    This Delete testcase , deletes the ITM tunnel created between 2 dpns.
89     ${Dpn_id_1}    Genius.Get Dpn Ids    ${conn_id_1}
90     ${Dpn_id_2}    Genius.Get Dpn Ids    ${conn_id_2}
91     ${tunnel-1}    Get_Tunnel    ${Dpn_id_1}    ${Dpn_id_2}
92     ${tunnel-2}    Get_Tunnel    ${Dpn_id_2}    ${Dpn_id_1}
93     Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/
94     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/itm-state:tunnels_state/
95     Should Not Contain    ${resp}    ${tunnel-1}    ${tunnel-2}
96     ${Ovs-del-1}    Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${conn_id_1}    ${tunnel-1}
97     ${Ovs-del-2}    Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${conn_id_2}    ${tunnel-2}
98
99 *** Keywords ***
100 Get_Tunnel
101     [Arguments]    ${src}    ${dst}
102     [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.
103     ${resp}    RequestsLibrary.Get Request    session    ${CONFIG_API}/itm-state:dpn-teps-state/dpns-teps/${src}/remote-dpns/${dst}/
104     log    ${resp.content}
105     ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
106     Should Be Equal As Strings    ${resp.status_code}    200
107     Should Contain    ${resp.content}    ${dst}
108     ${json}=    evaluate    json.loads('''${resp.content}''')    json
109     ${return}    Run Keyword And Return Status    Should contain    ${resp.content}    tunnel-name
110     log    ${return}
111     ${ret}    Run Keyword If    '${return}'=='True'    Check_Interface_Name    ${json["remote-dpns"][0]}    tunnel-name
112     [Return]    ${ret}
113
114 Check_Interface_Name
115     [Arguments]    ${json}    ${expected_tunnel_interface_name}
116     [Documentation]    This keyword Checks the Tunnel interface name is tunnel-interface-names in the output or not .
117     ${Tunnels}    Collections.Get From Dictionary    ${json}    ${expected_tunnel_interface_name}
118     Log    ${Tunnels}
119     [Return]    ${Tunnels}
120
121 Enable_Tunnel_Monitoring
122     [Documentation]    In this we will enable tunnel monitoring by tep:enable command running in karaf console
123     ${output}    Issue_Command_On_Karaf_Console    tep:enable-tunnel-monitor true
124
125 Verify Tunnel State After OVS Restart
126     [Arguments]    ${TOOLS_SYSTEM_IP}
127     [Documentation]    In this we will Verify Tunnel State by Stopping/Starting Switch
128     OVSDB.Stop OVS    ${TOOLS_SYSTEM_IP}
129     Wait Until Keyword Succeeds    2min    20 sec    Verify Tunnel Down
130     OVSDB.Start OVS    ${TOOLS_SYSTEM_IP}
131     Wait Until Keyword Succeeds    2min    20 sec    Genius.Verify Tunnel Status as UP    TZA
132
133 Verify Tunnel Down
134     [Documentation]    In this we will check whether tunnel is in down or not
135     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW_STATE}
136     Should Contain    ${output}    DOWN
137
138 Get Port Number
139     [Arguments]    ${connection_id}    ${Bridgename}    ${tunnel}
140     [Documentation]    In this we get Port Number to check table0 entry for 2 Dpn
141     Switch Connection    ${connection_id}
142     ${check-1}    Execute Command    sudo ovs-ofctl -O OpenFlow13 show ${Bridgename}
143     Log    ${check-1}
144     ${lines}    Get Lines Containing String    ${check-1}    ${tunnel}
145     Log    ${lines}
146     ${port}    Get Regexp Matches    ${lines}    \\d+
147     ${port_num}    Get From List    ${port}    0
148     Should Contain    ${check-1}    ${port_num}
149     [Return]    ${port_num}
150
151 Disable_Tunnel_Monitoring
152     [Documentation]    In this we will disable tunnel monitoring by tep:enable command running in karaf console
153     ${output}    Issue_Command_On_Karaf_Console    tep:enable-tunnel-monitor false