GENIUS-157: Fix typo in OF-Tunnels CSIT
[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     OFT Create Vteps using Auto Tunnels    @{TOOLS_SYSTEM_ALL_IPS}
32     OFT Verify Vteps Created    ${DPN_ID_LIST}    ${TOOLS_SYSTEM_ALL_IPS}
33
34 Delete and Verify OFT TEPs
35     [Documentation]    Delete TEPs set to use OF based Tunnels and verify.
36     OFT Delete Vteps using Auto Tunnels    @{TOOLS_SYSTEM_ALL_IPS}
37     OFT Verify Vteps Deleted    ${DPN_ID_LIST}    ${TOOLS_SYSTEM_ALL_IPS}
38
39 Create and Verify single OFT TEPs
40     [Documentation]    Create single TEPs set to use OF based Tunnels and verify.
41     ${tools_ips} =    BuiltIn.Create List    @{TOOLS_SYSTEM_ALL_IPS}
42     Collections.Remove From List    ${tools_ips}    -1
43     ${dpn_ids} =    BuiltIn.CreateList    @{DPN_ID_LIST}
44     Collections.Remove From List    ${dpn_ids}    -1
45     OFT Create Vteps using Auto Tunnels    @{tools_ips}
46     OFT Verify Vteps Created    ${dpn_ids}    ${tools_ips}
47     OFT Create Vteps using Auto Tunnels    @{TOOLS_SYSTEM_ALL_IPS}[-1]
48     OFT Verify Vteps Created    ${DPN_ID_LIST}    ${TOOLS_SYSTEM_ALL_IPS}
49
50 Delete and Verify single OFT TEPs
51     [Documentation]    Delete single TEPs set to use OF based Tunnels and verify.
52     ${deleted_tools_ip_list} =    BuiltIn.Create List    @{TOOLS_SYSTEM_ALL_IPS}[0]
53     OFT Delete Vteps using Auto Tunnels    @{deleted_tools_ip_list}
54     ${deleted_dpn_id_list} =    BuiltIn.CreateList    @{DPN_ID_LIST}[0]
55     OFT Verify Vteps Deleted    ${deleted_dpn_id_list}    ${deleted_tools_ip_list}
56
57 *** Keywords ***
58 OFT Create Vteps using Auto Tunnels
59     [Arguments]    @{tools_ip_list}
60     [Documentation]    Create VTEPs for selected tools systems in ODL using Auto Tunnels.
61     : FOR    ${tools_ip}    IN    @{tools_ip_list}
62     \    Utils.Run Command On Remote System And Log    ${tools_ip}    ${SET_LOCAL_IP}${tools_ip}
63
64 OFT Verify Vteps Created
65     [Arguments]    ${dpn_id_list}    ${tools_ip_list}
66     [Documentation]    Verify if OFT VTEPs are created successfully or not for given Tools IPs and DPN-IDs.
67     ${switch_data} =    BuiltIn.Create List    @{dpn_id_list}    @{tools_ip_list}
68     BuiltIn.Wait Until Keyword Succeeds    60    5    Genius.Get ITM    ${DEFAULT_TRANSPORT_ZONE}    255.255.255.255/32    ${NO_VLAN}
69     ...    ${switch_data}
70     ${tep_show_output} =    BuiltIn.Wait Until Keyword Succeeds    60    5    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW}
71     BuiltIn.Should Contain Any    ${tep_show_output}    ${DEFAULT_TRANSPORT_ZONE}    VXLAN    @{switch_data}
72     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}
73     BuiltIn.Wait Until Keyword Succeeds    60    5    Genius.Verify Response Code Of Dpn End Point Config API    ${dpn_id_list}
74     ${num_switches} =    BuiltIn.Get Length    ${dpn_id_list}
75     BuiltIn.Wait Until Keyword Succeeds    60    5    Genius.Verify Tunnel Status As Up    ${num_switches}
76     BuiltIn.Wait Until Keyword Succeeds    40    10    OFT OVS Verify Tunnels Created    @{tools_ip_list}
77     ${tools_system_len} =    BuiltIn.Get Length    ${tools_ip_list}
78     : FOR    ${tools_system_index}    IN RANGE    ${tools_system_len}
79     \    ${tun_ip_list} =    BuiltIn.CreateList    @{tools_ip_list}
80     \    Collections.Remove From List    ${tun_ip_list}    ${tools_system_index}
81     \    ${ports_output} =    Utils.Run Command On Remote System And Log    @{tools_ip_list}[${tools_system_index}]    sudo ovs-ofctl -Oopenflow13 dump-ports-desc ${Bridge}
82     \    ${port_numbers} =    String.Get Regexp Matches    ${ports_output}    (\\d+).tun.*    ${1}
83     \    BuiltIn.Wait Until Keyword Succeeds    40    10    OFT OVS Verify Ingress Flows Created per Switch    @{tools_ip_list}[${tools_system_index}]    ${tun_ip_list}
84     \    ...    ${port_numbers}
85     \    BuiltIn.Wait Until Keyword Succeeds    40    10    OFT OVS Verify Egress Flows Created per Switch    @{tools_ip_list}[${tools_system_index}]    ${tun_ip_list}
86     \    ...    ${port_numbers}
87
88 OFT OVS Verify Tunnels Created
89     [Arguments]    @{tools_ip_list}
90     [Documentation]    Verify if tunnels are created in OVS for selected tools systems.
91     : FOR    ${tools_ip}    IN    @{tools_ip_list}
92     \    ${output} =    Utils.Run Command On Remote System And Log    ${tools_ip}    sudo ovs-vsctl show
93     \    BuiltIn.Should Contain X Times    ${output}    local_ip="${tools_ip}", remote_ip=flow    ${1}
94
95 OFT OVS Verify Ingress Flows Created per Switch
96     [Arguments]    ${tools_ip}    ${tun_src_list}    ${port_numbers}
97     [Documentation]    Verify if Ingress flow rules are created in OVS for a given switch.
98     ${flows_table0_output} =    Utils.Run Command On Remote System And Log    ${tools_ip}    sudo ovs-ofctl -OOpenFlow13 dump-flows ${Bridge} ${FLOWS_FILTER_TABLE0}
99     : FOR    ${tun_src}    IN    @{tun_src_list}
100     \    BuiltIn.Should Contain    ${flows_table0_output}    tun_src=${tun_src}
101     : FOR    ${port_number}    IN    @{port_numbers}
102     \    BuiltIn.Should Contain    ${flows_table0_output}    in_port=${port_number}
103
104 OFT OVS Verify Egress Flows Created per Switch
105     [Arguments]    ${tools_ip}    ${tun_dst_list}    ${port_numbers}
106     [Documentation]    Verify if Egress flow rules are created in OVS for a given switch.
107     ${flows_table95_output} =    Utils.Run Command On Remote System And Log    ${tools_ip}    sudo ovs-ofctl -OOpenFlow13 dump-flows ${Bridge} ${FLOWS_FILTER_TABLE95}
108     : FOR    ${tun_dst}    IN    @{tun_dst_list}
109     \    ${tun_dst_hex} =    BuiltIn.Evaluate    '0x'+binascii.hexlify(socket.inet_aton('${tun_dst}'))    modules=socket,binascii
110     \    BuiltIn.Should Contain    ${flows_table95_output}    load:${tun_dst_hex}->NXM_NX_TUN_IPV4_DST[]
111     : FOR    ${port_number}    IN    @{port_numbers}
112     \    BuiltIn.Should Contain    ${flows_table95_output}    output:${port_number}
113
114 OFT Delete Vteps using Auto Tunnels
115     [Arguments]    @{tools_ip_list}
116     [Documentation]    Delete VTEPs for selected tools systems in ODL using Auto Tunnel.
117     : FOR    ${tools_ip}    IN    @{tools_ip_list}
118     \    Utils.Run Command On Remote System And Log    ${tools_ip}    ${REMOVE_LOCAL_IP}
119
120 OFT Verify Vteps Deleted
121     [Arguments]    ${dpn_id_list}    ${tools_ip_list}
122     [Documentation]    Verify if OFT Vteps are created successfully or not for given Tools IPs and DPN-IDs.
123     ${tools_system_len} =    BuiltIn.Get Length    ${dpn_id_list}
124     ${tep_show_output} =    BuiltIn.Wait Until Keyword Succeeds    60    5    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW}
125     ${tep_show_state_output} =    BuiltIn.Wait Until Keyword Succeeds    60    5    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW_STATE}
126     ${tunnel_state_resp_data} =    BuiltIn.Wait Until Keyword Succeeds    60    5    Utils.Get Data From URI    session    ${OPERATIONAL_API}/itm-state:tunnels_state
127     : FOR    ${tools_system_index}    IN RANGE    ${tools_system_len}
128     \    BuiltIn.Should Not Contain    ${tep_show_output}    @{tools_ip_list}[${tools_system_index}]
129     \    BuiltIn.Should Not Contain    ${tep_show_state_output}    @{tools_ip_list}[${tools_system_index}]
130     \    BuiltIn.Should Not Contain    ${tunnel_state_resp_data}    @{tools_ip_list}[${tools_system_index}]
131     \    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}]/
132     \    ${dst_dpn_id_list} =    BuiltIn.Create List    @{DPN_ID_LIST}
133     \    Collections.Remove From List    ${dst_dpn_id_list}    ${tools_system_index}
134     \    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}
135     \    ${ovs_vsctl_output} =    BuiltIn.Wait Until Keyword Succeeds    40    10    Utils.Run Command On Remote System And Log    @{tools_ip_list}[${tools_system_index}]
136     \    ...    sudo ovs-vsctl show
137     \    BuiltIn.Should Not Contain    ${ovs_vsctl_output}    remote_ip=flow
138     \    BuiltIn.Wait Until Keyword Succeeds    40    10    OFT OVS Verify Ingress Flows Deleted per Switch    @{tools_ip_list}[${tools_system_index}]
139     \    BuiltIn.Wait Until Keyword Succeeds    40    10    OFT OVS Verify Egress Flows Deleted per Switch    @{tools_ip_list}[${tools_system_index}]
140
141 OFT Verify Vteps Deleted at Dpn Teps State per Interface
142     [Arguments]    ${src_dpn_id}    ${dst_dpn_id_list}
143     [Documentation]    Verify if vteps are deleted for all src-dst intf pair at dpn-teps-state in ODL for a given src intf.
144     : FOR    ${dst_dpn_id}    IN    @{dst_dpn_id_list}
145     \    ${status} =    BuiltIn.Run Keyword And Return Status    Genius.Get Tunnel    ${src_dpn_id}    ${dst_dpn_id}    odl-interface:tunnel-type-vxlan
146     \    ...    dpn-teps-state
147     \    BuiltIn.Should Be True    ${status} == ${False}
148
149 OFT OVS Verify Ingress Flows Deleted per Switch
150     [Arguments]    ${tools_ip}
151     [Documentation]    Verify if Ingress flow rules are deleted in OVS for a given switch.
152     ${flows_table0_output} =    Utils.Run Command On Remote System And Log    ${tools_ip}    sudo ovs-ofctl -OOpenFlow13 dump-flows ${Bridge} ${FLOWS_FILTER_TABLE0}
153     BuiltIn.Should Not Contain    ${flows_table0_output}    tun_src=
154
155 OFT OVS Verify Egress Flows Deleted per Switch
156     [Arguments]    ${tools_ip}
157     [Documentation]    Verify if Egress flow rules are deleted in OVS for a given switch.
158     ${flows_table95_output} =    Utils.Run Command On Remote System And Log    ${tools_ip}    sudo ovs-ofctl -OOpenFlow13 dump-flows ${Bridge} ${FLOWS_FILTER_TABLE95}
159     BuiltIn.Should Not Contain    ${flows_table95_output}    output:
160
161 OF Tunnels Start Suite
162     [Documentation]    Start suite for OF Tunnels.
163     ClusterManagement.ClusterManagement_Setup
164     ClusterManagement.Stop_Members_From_List_Or_All
165     : FOR    ${controller_index}    IN RANGE    ${NUM_ODL_SYSTEM}
166     \    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}
167     \    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}
168     ClusterManagement.Start_Members_From_List_Or_All
169     Genius Suite Setup
170
171 OF Tunnels Stop Suite
172     [Documentation]    Stop suite for OF Tunnels.
173     : FOR    ${controller_index}    IN RANGE    ${NUM_ODL_SYSTEM}
174     \    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}
175     \    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}
176     ClusterManagement.Stop_Members_From_List_Or_All
177     ClusterManagement.Start_Members_From_List_Or_All
178     Genius Suite Teardown