22714b10bc23409d9529721573f8f9542ccd2476
[integration/test.git] / csit / suites / genius / OF_Tunnels.robot
1 *** Settings ***
2 Documentation     This test suite is to verify working of OF based Tunnels
3 Suite Setup       OF Tunnels Start Suite
4 Suite Teardown    OF Tunnels Stop Suite
5 Test Setup        Genius Test Setup
6 Test Teardown     Genius Test Teardown    ${data_models}
7 Library           Collections
8 Library           OperatingSystem
9 Library           RequestsLibrary
10 Library           SSHLibrary
11 Library           String
12 Resource          ../../libraries/ClusterManagement.robot
13 Resource          ../../libraries/DataModels.robot
14 Resource          ../../libraries/Genius.robot
15 Resource          ../../libraries/KarafKeywords.robot
16 Resource          ../../libraries/ODLTools.robot
17 Resource          ../../libraries/OVSDB.robot
18 Resource          ../../libraries/Utils.robot
19 Resource          ../../libraries/VpnOperations.robot
20 Resource          ../../variables/Variables.robot
21 Variables         ../../variables/genius/Modules.py
22 Resource          ../../variables/netvirt/Variables.robot
23
24 *** Variables ***
25 ${FLOWS_FILTER_TABLE0}    | grep table=0
26 ${FLOWS_FILTER_TABLE95}    | grep table=95
27
28 *** Test Cases ***
29 Create and Verify OFT TEPs
30     [Documentation]    Create TEPs set to use OF based Tunnels and verify.
31     CompareStream.Run_Keyword_If_Less_Than_Sodium    BuiltIn.Pass Execution    Test case valid only for versions Sodium and above
32     OFT Create Vteps using Auto Tunnels    @{TOOLS_SYSTEM_ALL_IPS}
33     OFT Verify Vteps Created    ${DPN_ID_LIST}    ${TOOLS_SYSTEM_ALL_IPS}
34
35 Delete and Verify OFT TEPs
36     [Documentation]    Delete TEPs set to use OF based Tunnels and verify.
37     CompareStream.Run_Keyword_If_Less_Than_Sodium    BuiltIn.Pass Execution    Test case valid only for versions Sodium and above
38     OFT Delete Vteps using Auto Tunnels    @{TOOLS_SYSTEM_ALL_IPS}
39     OFT Verify Vteps Deleted    ${DPN_ID_LIST}    ${TOOLS_SYSTEM_ALL_IPS}
40     BuiltIn.Wait Until Keyword Succeeds    60    5    Utils.No Content From URI    session    ${OPERATIONAL_API}/itm-state:tunnels_state
41
42 Create and Verify single OFT TEPs
43     [Documentation]    Create single TEPs set to use OF based Tunnels and verify.
44     CompareStream.Run_Keyword_If_Less_Than_Sodium    BuiltIn.Pass Execution    Test case valid only for versions Sodium and above
45     ${tools_ips} =    BuiltIn.Create List    @{TOOLS_SYSTEM_ALL_IPS}
46     Collections.Remove From List    ${tools_ips}    -1
47     ${dpn_ids} =    BuiltIn.CreateList    @{DPN_ID_LIST}
48     Collections.Remove From List    ${dpn_ids}    -1
49     OFT Create Vteps using Auto Tunnels    @{tools_ips}
50     OFT Verify Vteps Created    ${dpn_ids}    ${tools_ips}
51     OFT Create Vteps using Auto Tunnels    ${TOOLS_SYSTEM_ALL_IPS}[-1]
52     OFT Verify Vteps Created    ${DPN_ID_LIST}    ${TOOLS_SYSTEM_ALL_IPS}
53
54 Delete and Verify single OFT TEPs
55     [Documentation]    Delete single TEPs set to use OF based Tunnels and verify.
56     CompareStream.Run_Keyword_If_Less_Than_Sodium    BuiltIn.Pass Execution    Test case valid only for versions Sodium and above
57     ${deleted_tools_ip_list} =    BuiltIn.Set Variable    ${TOOLS_SYSTEM_ALL_IPS}[0]
58     OFT Delete Vteps using Auto Tunnels    ${deleted_tools_ip_list}
59     ${deleted_tools_ip_list} =    BuiltIn.CreateList    ${TOOLS_SYSTEM_ALL_IPS}[0]
60     ${deleted_dpn_id_list} =    BuiltIn.CreateList    ${DPN_ID_LIST}[0]
61     OFT Verify Vteps Deleted    ${deleted_dpn_id_list}    ${deleted_tools_ip_list}
62
63 *** Keywords ***
64 OFT Create Vteps using Auto Tunnels
65     [Arguments]    @{tools_ip_list}
66     [Documentation]    Create VTEPs for selected tools systems in ODL using Auto Tunnels.
67     FOR    ${tools_ip}    IN    @{tools_ip_list}
68         Utils.Run Command On Remote System And Log    ${tools_ip}    ${SET_LOCAL_IP}${tools_ip}
69     END
70
71 OFT Verify Vteps Created
72     [Arguments]    ${dpn_id_list}    ${tools_ip_list}
73     [Documentation]    Verify if OFT VTEPs are created successfully or not for given Tools IPs and DPN-IDs.
74     ${switch_data} =    BuiltIn.Create List    @{dpn_id_list}    @{tools_ip_list}
75     BuiltIn.Wait Until Keyword Succeeds    60    5    Genius.Get ITM    ${DEFAULT_TRANSPORT_ZONE}    ${switch_data}
76     ${tep_show_output} =    BuiltIn.Wait Until Keyword Succeeds    60    5    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW}
77     BuiltIn.Should Contain Any    ${tep_show_output}    ${DEFAULT_TRANSPORT_ZONE}    VXLAN    @{switch_data}
78     BuiltIn.Wait Until Keyword Succeeds    60    5    Genius.Update Dpn id List And Get Tunnels    odl-interface:tunnel-type-vxlan    dpn-teps-state    ${dpn_id_list}
79     BuiltIn.Wait Until Keyword Succeeds    60    5    Genius.Verify Response Code Of Dpn End Point Config API    ${dpn_id_list}
80     ${num_switches} =    BuiltIn.Get Length    ${dpn_id_list}
81     BuiltIn.Wait Until Keyword Succeeds    60    5    Genius.Verify Tunnel Status As Up    ${num_switches}
82     BuiltIn.Wait Until Keyword Succeeds    40    10    OFT OVS Verify Tunnels Created    @{tools_ip_list}
83     ${tools_system_len} =    BuiltIn.Get Length    ${tools_ip_list}
84     FOR    ${tools_system_index}    IN RANGE    ${tools_system_len}
85         ${tun_ip_list} =    BuiltIn.CreateList    @{tools_ip_list}
86         Collections.Remove From List    ${tun_ip_list}    ${tools_system_index}
87         ${ports_output} =    Utils.Run Command On Remote System And Log    ${tools_ip_list}[${tools_system_index}]    sudo ovs-ofctl -Oopenflow13 dump-ports-desc ${Bridge}
88         ${port_numbers} =    String.Get Regexp Matches    ${ports_output}    (\\d+).of.*    ${1}
89         BuiltIn.Wait Until Keyword Succeeds    40    10    OFT OVS Verify Ingress Flows Created per Switch    ${tools_ip_list}[${tools_system_index}]    ${tun_ip_list}
90         ...    ${port_numbers}
91         BuiltIn.Wait Until Keyword Succeeds    40    10    OFT OVS Verify Egress Flows Created per Switch    ${tools_ip_list}[${tools_system_index}]    ${tun_ip_list}
92         ...    ${port_numbers}
93     END
94
95 OFT OVS Verify Tunnels Created
96     [Arguments]    @{tools_ip_list}
97     [Documentation]    Verify if tunnels are created in OVS for selected tools systems.
98     FOR    ${tools_ip}    IN    @{tools_ip_list}
99         ${output} =    Utils.Run Command On Remote System And Log    ${tools_ip}    sudo ovs-vsctl show
100         BuiltIn.Should Contain X Times    ${output}    local_ip="${tools_ip}", remote_ip=flow    ${1}
101     END
102
103 OFT OVS Verify Ingress Flows Created per Switch
104     [Arguments]    ${tools_ip}    ${tun_src_list}    ${port_numbers}
105     [Documentation]    Verify if Ingress flow rules are created in OVS for a given switch.
106     ${flows_table0_output} =    Utils.Run Command On Remote System And Log    ${tools_ip}    sudo ovs-ofctl -OOpenFlow13 dump-flows ${Bridge} ${FLOWS_FILTER_TABLE0}
107     BuiltIn.Should Not Contain    ${flows_table0_output}    tun_src=${tools_ip},
108     FOR    ${tun_src}    IN    @{tun_src_list}
109         BuiltIn.Should Contain    ${flows_table0_output}    tun_src=${tun_src},
110     END
111     FOR    ${port_number}    IN    @{port_numbers}
112         BuiltIn.Should Contain    ${flows_table0_output}    in_port=${port_number}
113     END
114
115 OFT OVS Verify Egress Flows Created per Switch
116     [Arguments]    ${tools_ip}    ${tun_dst_list}    ${port_numbers}
117     [Documentation]    Verify if Egress flow rules are created in OVS for a given switch.
118     ${flows_table95_output} =    Utils.Run Command On Remote System And Log    ${tools_ip}    sudo ovs-ofctl -OOpenFlow13 dump-flows ${Bridge} ${FLOWS_FILTER_TABLE95}
119     FOR    ${tun_dst}    IN    @{tun_dst_list}
120         ${tun_dst_hex} =    BuiltIn.Evaluate    hex(struct.unpack('!I',socket.inet_aton('${tun_dst}'))[0])    modules=socket,struct
121         BuiltIn.Should Contain    ${flows_table95_output}    load:${tun_dst_hex}->NXM_NX_TUN_IPV4_DST[]
122     END
123     FOR    ${port_number}    IN    @{port_numbers}
124         BuiltIn.Should Contain    ${flows_table95_output}    output:${port_number}
125     END
126
127 OFT Delete Vteps using Auto Tunnels
128     [Arguments]    @{tools_ip_list}
129     [Documentation]    Delete VTEPs for selected tools systems in ODL using Auto Tunnel.
130     FOR    ${tools_ip}    IN    @{tools_ip_list}
131         Utils.Run Command On Remote System And Log    ${tools_ip}    ${REMOVE_LOCAL_IP}
132     END
133
134 OFT Verify Vteps Deleted
135     [Arguments]    ${dpn_id_list}    ${tools_ip_list}
136     [Documentation]    Verify if OFT Vteps are created successfully or not for given Tools IPs and DPN-IDs.
137     ${deleted_tep_len} =    BuiltIn.Get Length    ${dpn_id_list}
138     ${existing_tep_len} =    BuiltIn.Evaluate    ${NUM_TOOLS_SYSTEM}-${deleted_tep_len}
139     BuiltIn.Run Keyword If    ${existing_tep_len} > 0    BuiltIn.Wait Until Keyword Succeeds    60    5    Genius.Verify Tunnel Status As Up    ${existing_tep_len}
140     ${tep_show_output} =    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW}
141     ${tep_show_state_output} =    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW_STATE}
142     FOR    ${tools_system_index}    IN RANGE    ${deleted_tep_len}
143         ${tep_show_state_output_1} =    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW_STATE}
144         Log    ${tools_ip_list}
145         Log    ${tools_ip_list}[${tools_system_index}]
146         BuiltIn.Should Not Contain    ${tep_show_output}    ${tools_ip_list}[${tools_system_index}]
147         BuiltIn.Should Not Contain    ${tep_show_state_output}    ${tools_ip_list}[${tools_system_index}]
148         BuiltIn.Wait Until Keyword Succeeds    60    5    Utils.No Content From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${dpn_id_list}[${tools_system_index}]/
149         ${dst_dpn_id_list} =    BuiltIn.Create List    @{DPN_ID_LIST}
150         Collections.Remove From List    ${dst_dpn_id_list}    ${tools_system_index}
151         BuiltIn.Wait Until Keyword Succeeds    60    5    OFT Verify Vteps Deleted at Dpn Teps State per Interface    ${dpn_id_list}[${tools_system_index}]    ${dst_dpn_id_list}
152         ${ovs_vsctl_output} =    BuiltIn.Wait Until Keyword Succeeds    40    10    Utils.Run Command On Remote System And Log    ${tools_ip_list}[${tools_system_index}]
153         ...    sudo ovs-vsctl show
154         BuiltIn.Should Not Contain    ${ovs_vsctl_output}    remote_ip=flow
155         BuiltIn.Wait Until Keyword Succeeds    40    10    OFT OVS Verify Ingress Flows Deleted per Switch    ${tools_ip_list}[${tools_system_index}]
156         BuiltIn.Wait Until Keyword Succeeds    40    10    OFT OVS Verify Egress Flows Deleted per Switch    ${tools_ip_list}[${tools_system_index}]
157     END
158
159 OFT Verify Vteps Deleted at Dpn Teps State per Interface
160     [Arguments]    ${src_dpn_id}    ${dst_dpn_id_list}
161     [Documentation]    Verify if vteps are deleted for all src-dst intf pair at dpn-teps-state in ODL for a given src intf.
162     FOR    ${dst_dpn_id}    IN    @{dst_dpn_id_list}
163         ${status} =    BuiltIn.Run Keyword And Return Status    Genius.Get Tunnel    ${src_dpn_id}    ${dst_dpn_id}    odl-interface:tunnel-type-vxlan
164         ...    dpn-teps-state
165         BuiltIn.Should Be True    ${status} == ${False}
166     END
167
168 OFT OVS Verify Ingress Flows Deleted per Switch
169     [Arguments]    ${tools_ip}
170     [Documentation]    Verify if Ingress flow rules are deleted in OVS for a given switch.
171     ${flows_table0_output} =    Utils.Run Command On Remote System And Log    ${tools_ip}    sudo ovs-ofctl -OOpenFlow13 dump-flows ${Bridge} ${FLOWS_FILTER_TABLE0}
172     BuiltIn.Should Not Contain    ${flows_table0_output}    tun_src=
173
174 OFT OVS Verify Egress Flows Deleted per Switch
175     [Arguments]    ${tools_ip}
176     [Documentation]    Verify if Egress flow rules are deleted in OVS for a given switch.
177     ${flows_table95_output} =    Utils.Run Command On Remote System And Log    ${tools_ip}    sudo ovs-ofctl -OOpenFlow13 dump-flows ${Bridge} ${FLOWS_FILTER_TABLE95}
178     BuiltIn.Should Not Contain    ${flows_table95_output}    output:
179
180 OF Tunnels Start Suite
181     [Documentation]    Start suite for OF Tunnels.
182     ClusterManagement.ClusterManagement_Setup
183     ClusterManagement.Stop_Members_From_List_Or_All
184     FOR    ${controller_index}    IN RANGE    ${NUM_ODL_SYSTEM}
185         Run Command On Remote System And Log    ${ODL_SYSTEM_${controller_index+1}_IP}    sed -i -- 's/<itm-direct-tunnels>false/<itm-direct-tunnels>true/g' ${GENIUS_IFM_CONFIG_FLAG}
186         Run Command On Remote System And Log    ${ODL_SYSTEM_${controller_index+1}_IP}    sed -i -- 's/<use-of-tunnels>false/<use-of-tunnels>true/g' ${GENIUS_ITM_CONFIG_FLAG}
187     END
188     ClusterManagement.Start_Members_From_List_Or_All
189     Genius Suite Setup
190
191 OF Tunnels Stop Suite
192     [Documentation]    Stop suite for OF Tunnels.
193     FOR    ${controller_index}    IN RANGE    ${NUM_ODL_SYSTEM}
194         Run Command On Remote System And Log    ${ODL_SYSTEM_${controller_index+1}_IP}    sed -i -- 's/<itm-direct-tunnels>true/<itm-direct-tunnels>false/g' ${GENIUS_IFM_CONFIG_FLAG}
195         Run Command On Remote System And Log    ${ODL_SYSTEM_${controller_index+1}_IP}    sed -i -- 's/<use-of-tunnels>true/<use-of-tunnels>false/g' ${GENIUS_ITM_CONFIG_FLAG}
196     END
197     ClusterManagement.Stop_Members_From_List_Or_All
198     ClusterManagement.Start_Members_From_List_Or_All
199     Genius Suite Teardown