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