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