Breakout complicated setup from suite setup
[integration/test.git] / csit / suites / netvirt / vpnservice / arp_learning.robot
1 *** Settings ***
2 Documentation     Test suite for ARP Request. More test cases to be added in subsequent patches.
3 Suite Setup       VpnOperations.Basic Suite Setup
4 Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
5 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
6 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
7 Library           RequestsLibrary
8 Library           SSHLibrary
9 Resource          ../../../libraries/OpenStackOperations.robot
10 Resource          ../../../libraries/DevstackUtils.robot
11 Resource          ../../../libraries/VpnOperations.robot
12 Resource          ../../../libraries/SetupUtils.robot
13 Resource          ../../../variables/netvirt/Variables.robot
14 Resource          ../../../variables/Variables.robot
15
16 *** Variables ***
17 ${SECURITY_GROUP}    vpna_sg
18 @{NETWORKS}       vpna_net_1    vpna_net_2    vpna_net_3
19 @{SUBNETS}        vpna_sub_1    vpna_sub_2    vpna_sub_3
20 @{SUBNET_CIDRS}    10.10.10.0/24    10.20.20.0/24    10.30.30.0/24
21 @{PORTS}          vpna_net_1_port_1    vpna_net_1_port_2    vpna_net_2_port_1    vpna_net_2_port_2    vpna_net_3_port_1    vpna_net_3_port_2
22 @{NET_1_VMS}      vpna_net_1_vm_1    vpna_net_1_vm_2
23 @{NET_2_VMS}      vpna_net_2_vm_1    vpna_net_2_vm_2
24 @{NET_3_VMS}      vpna_net_3_vm_1    vpna_net_3_vm_2
25 ${ROUTER}         vpna_router
26 @{VPN_INSTANCE_IDS}    4ae8cd92-48ca-49b5-94e1-b2921a261111
27 @{VPN_NAMES}      vpna_1
28 ${RD1}            ["2200:2"]
29 ${RD2}            ["2200:3"]
30 ${EXPORT_RT}      ["2200:2","2200:3"]
31 ${IMPORT_RT}      ["2200:2","2200:3"]
32 ${SUB_IF}         eth0:1
33 @{EXTRA_NW_IP}    192.168.10.110    192.168.20.110
34 ${FIB_ENTRY_2}    192.168.10.110
35 ${RPING_MIP_IP}    sudo arping -I eth0:1 -c 5 -b -s 192.168.10.110 192.168.10.110
36 ${RPING_MIP_IP_2}    sudo arping -I eth0:1 -c 5 -b -s 192.168.20.110 192.168.20.110
37 ${RPING_EXP_STR}    broadcast
38
39 *** Test Cases ***
40 Create Neutron Networks
41     : FOR    ${network}    IN    @{NETWORKS}
42     \    OpenStackOperations.Create Network    ${network}
43     ${neutron_networks} =    OpenStackOperations.List Networks
44     : FOR    ${network}    IN    @{NETWORKS}
45     \    BuiltIn.Should Contain    ${neutron_networks}    ${network}
46     ${NET_ID} =    OpenStackOperations.Get Net Id    @{NETWORKS}[0]
47     BuiltIn.Set Suite Variable    ${NET_ID}
48
49 Create Neutron Subnets
50     : FOR    ${i}    IN RANGE    0    3
51     \    OpenStackOperations.Create SubNet    @{NETWORKS}[${i}]    @{SUBNETS}[${i}]    @{SUBNET_CIDRS}[${i}]
52     ${neutron_subnets} =    OpenStackOperations.List Subnets
53     : FOR    ${subnet}    IN    @{SUBNETS}
54     \    BuiltIn.Should Contain    ${neutron_subnets}    ${subnet}
55
56 Add Ssh Allow All Rule
57     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
58
59 Create Neutron Ports
60     OpenStackOperations.Create Port    @{NETWORKS}[0]    @{PORTS}[0]    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
61     OpenStackOperations.Create Port    @{NETWORKS}[0]    @{PORTS}[1]    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
62     OpenStackOperations.Create Port    @{NETWORKS}[1]    @{PORTS}[2]    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
63     OpenStackOperations.Create Port    @{NETWORKS}[1]    @{PORTS}[3]    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
64     OpenStackOperations.Create Port    @{NETWORKS}[2]    @{PORTS}[4]    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
65     OpenStackOperations.Create Port    @{NETWORKS}[2]    @{PORTS}[5]    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
66     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${CONFIG_API}/neutron:neutron/ports/    ${PORTS}
67
68 Create Nova VMs
69     OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORTS}[0]    @{NET_1_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
70     OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORTS}[1]    @{NET_1_VMS}[1]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
71     OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORTS}[2]    @{NET_2_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
72     OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORTS}[3]    @{NET_2_VMS}[1]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
73     OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORTS}[4]    @{NET_3_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
74     OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORTS}[5]    @{NET_3_VMS}[1]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
75     @{NET_1_VM_IPS}    ${NET_1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
76     @{NET_2_VM_IPS}    ${NET_2_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
77     @{NET_3_VM_IPS}    ${NET_3_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_3_VMS}
78     BuiltIn.Set Suite Variable    @{NET_1_VM_IPS}
79     BuiltIn.Set Suite Variable    @{NET_2_VM_IPS}
80     BuiltIn.Set Suite Variable    @{NET_3_VM_IPS}
81     BuiltIn.Should Not Contain    ${NET_1_VM_IPS}    None
82     BuiltIn.Should Not Contain    ${NET_2_VM_IPS}    None
83     BuiltIn.Should Not Contain    ${NET_3_VM_IPS}    None
84     BuiltIn.Should Not Contain    ${NET_1_DHCP_IP}    None
85     BuiltIn.Should Not Contain    ${NET_2_DHCP_IP}    None
86     BuiltIn.Should Not Contain    ${NET_3_DHCP_IP}    None
87
88 Create Router
89     OpenStackOperations.Create Router    ${ROUTER}
90     OpenStackOperations.Add Router Interface    ${ROUTER}    @{SUBNETS}[1]
91     OpenStackOperations.Add Router Interface    ${ROUTER}    @{SUBNETS}[2]
92
93 Create L3VPN
94     ${tenant_id} =    OpenStackOperations.Get Tenant ID From Network    ${NET_ID}
95     VpnOperations.VPN Create L3VPN    vpnid=@{VPN_INSTANCE_IDS}[0]    name=${VPN_NAMES[0]}    rd=${RD1}    exportrt=${EXPORT_RT}    importrt=${IMPORT_RT}    tenantid=${tenant_id}
96     ${resp} =    VpnOperations.VPN Get L3VPN    vpnid=@{VPN_INSTANCE_IDS}[0]
97     BuiltIn.Should Contain    ${resp}    @{VPN_INSTANCE_IDS}[0]
98
99 Associate L3VPN To ROUTER
100     VpnOperations.Associate L3VPN To Network    networkid=${NET_ID}    vpnid=@{VPN_INSTANCE_IDS}[0]
101     ${resp} =    VpnOperations.VPN Get L3VPN    vpnid=@{VPN_INSTANCE_IDS}[0]
102     BuiltIn.Should Contain    ${resp}    ${NET_ID}
103     ${ROUTER_ID} =    OpenStackOperations.Get Router Id    ${ROUTER}
104     BuiltIn.Set Suite Variable    ${ROUTER_ID}
105     VpnOperations.Associate VPN to Router    routerid=${ROUTER_ID}    vpnid=@{VPN_INSTANCE_IDS}[0]
106     ${resp} =    VpnOperations.VPN Get L3VPN    vpnid=@{VPN_INSTANCE_IDS}[0]
107     BuiltIn.Should Contain    ${resp}    ${ROUTER_ID}
108
109 Verify Setup
110     [Documentation]    Verify that VMs received ip and ping is happening between different VM
111     ${vms} =    BuiltIn.Create List    @{NET_1_VM_IPS}    @{NET_2_VM_IPS}    @{NET_3_VM_IPS}
112     BuiltIn.Wait Until Keyword Succeeds    30s    10s    Utils.Check For Elements At URI    ${FIB_ENTRIES_URL}    ${vms}
113     Verify Ping On Same Networks
114     Verify Ping On Different Networks
115
116 Verify GARP Requests
117     [Documentation]    Verify that GARP request are sent to controller
118     BuiltIn.Set Test Variable    ${fib_entry_1}    @{NET_1_VM_IPS}[0]
119     BuiltIn.Set Test Variable    ${fib_entry_3}    @{NET_1_VM_IPS}[1]
120     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Flows Are Present    ${OS_COMPUTE_1_IP}
121     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Flows Are Present    ${OS_COMPUTE_2_IP}
122     ${output} =    VpnOperations.Get Fib Entries    session
123     ${resp} =    BuiltIn.Should Match Regexp    ${output}    destPrefix\\":\\"${fib_entry_3}\/32".*"${OS_COMPUTE_2_IP}\\"
124     ${resp} =    BuiltIn.Should Match Regexp    ${output}    destPrefix\\":\\"${fib_entry_1}\/32".*"${OS_COMPUTE_1_IP}\\"
125     ${rx_packet1_before} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ifconfig eth0
126     ${rx_packet0_before} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ifconfig eth0
127     ${config_extra_route_ip1} =    BuiltIn.Catenate    sudo ifconfig ${SUB_IF} @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
128     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ${config_extra_route_ip1}
129     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ifconfig
130     BuiltIn.Should Contain    ${output}    ${SUB_IF}
131     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ${RPING_MIP_IP}
132     BuiltIn.Should Contain    ${output}    broadcast
133     BuiltIn.Should Contain    ${output}    Received 0 reply
134     ${rx_packet1_after} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ifconfig eth0
135     ${rx_packet0_after} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ifconfig eth0
136     BuiltIn.Should Not Be Equal    ${rx_packet0_before}    ${rx_packet0_after}
137     BuiltIn.Should Not Be Equal    ${rx_packet1_before}    ${rx_packet1_after}
138     BuiltIn.Wait Until Keyword Succeeds    30s    10s    Verify Flows Are Present    ${OS_COMPUTE_1_IP}
139     BuiltIn.Wait Until Keyword Succeeds    30s    10s    Verify Flows Are Present    ${OS_COMPUTE_2_IP}
140     BuiltIn.Wait Until Keyword Succeeds    5s    1s    Verify Learnt IP    ${FIB_ENTRY_2}    session
141     ${output} =    VpnOperations.Get Fib Entries    session
142     ${resp} =    BuiltIn.Should Match Regexp    ${output}    destPrefix\\":\\"${fib_entry_3}\\/32".*"${OS_COMPUTE_2_IP}\\"
143     ${resp} =    BuiltIn.Should Match Regexp    ${output}    destPrefix\\":\\"${fib_entry_1}\\/32".*"${OS_COMPUTE_1_IP}\\"
144     ${resp} =    BuiltIn.Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_2}\\/32".*"${OS_COMPUTE_2_IP}\\"
145     Verify Ping To Sub Interface    ${FIB_ENTRY_2}
146
147 Verify MIP Migration
148     [Documentation]    Verify that after migration of movable ip across compute nodes, the controller updates the routes
149     ${unconfig_extra_route_ip1} =    BuiltIn.Catenate    sudo ifconfig ${SUB_IF} down
150     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ${unconfig_extra_route_ip1}
151     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ifconfig
152     BuiltIn.Should Not Contain    ${output}    ${SUB_IF}
153     ${config_extra_route_ip1} =    BuiltIn.Catenate    sudo ifconfig ${SUB_IF} @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
154     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ${config_extra_route_ip1}
155     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ifconfig
156     BuiltIn.Should Contain    ${output}    ${SUB_IF}
157     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ifconfig ${SUB_IF}
158     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ${RPING_MIP_IP}
159     BuiltIn.Should Contain    ${output}    Received 0 reply
160     BuiltIn.Should Contain    ${output}    broadcast
161     BuiltIn.Wait Until Keyword Succeeds    5s    1s    Verify Learnt IP    ${FIB_ENTRY_2}    session
162     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ${RPING_MIP_IP}
163     ${output}    VpnOperations.Get Fib Entries    session
164     ${resp}=    BuiltIn.Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_2}\\/32".*"${OS_COMPUTE_1_IP}\\"
165     Verify Ping To Sub Interface    ${FIB_ENTRY_2}
166     ${unconfig_extra_route_ip1} =    BuiltIn.Catenate    sudo ifconfig ${SUB_IF} down
167     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ${unconfig_extra_route_ip1}
168
169 Verify ping to subnet gateway
170     [Documentation]    Verify ping happens to subnet gateway. To be submitted in next patch
171     [Tags]    not-implemented    exclude
172     TODO
173
174 If anything other than subnet ip then no reply
175     [Documentation]    If anything other than subnet ip then no reply. To be submitted in next patch
176     [Tags]    not-implemented    exclude
177     TODO
178
179 Validate multiple mip migration
180     [Documentation]    Validate multiple mip migration. To be submitted in next patch
181     [Tags]    not-implemented    exclude
182     TODO
183
184 Same DPN MIP Migration
185     [Documentation]    Same DPN MIP Migration. To be submitted in next patch
186     [Tags]    not-implemented    exclude
187     TODO
188
189 Cleanup
190     [Documentation]    Delete the setup
191     VpnOperations.Dissociate L3VPN From Networks    networkid=${NET_ID}    vpnid=@{VPN_INSTANCE_IDS}[0]
192     VpnOperations.Dissociate VPN to Router    routerid=${ROUTER_ID}    vpnid=@{VPN_INSTANCE_IDS}[0]
193     VpnOperations.VPN Delete L3VPN    vpnid=@{VPN_INSTANCE_IDS}[0]
194     OpenStackOperations.Remove Interface    ${ROUTER}    @{SUBNETS}[1]
195     OpenStackOperations.Remove Interface    ${ROUTER}    @{SUBNETS}[2]
196     OpenStackOperations.Delete Router    ${ROUTER}
197     @{vms} =    BuiltIn.Create List    @{NET_1_VMS}    @{NET_2_VMS}    @{NET_3_VMS}
198     @{sgs} =    BuiltIn.Create List    ${SECURITY_GROUP}
199     OpenStackOperations.Neutron Cleanup    ${vms}    ${NETWORKS}    ${SUBNETS}    ${PORTS}    ${sgs}
200
201 *** Keywords ***
202 Start Suite
203     [Documentation]    Run at start of the suite
204     OpenStackOperations.OpenStack Suite Setup
205     TemplatedRequests.Create Default Session    timeout=10
206
207 Verify Ping On Same Networks
208     [Documentation]    Verify ping among VM of same network
209     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ping -c 3 @{NET_1_VM_IPS}[1]
210     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
211     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[1]    @{NET_2_VM_IPS}[0]    ping -c 3 @{NET_2_VM_IPS}[1]
212     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
213     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ping -c 3 @{NET_1_VM_IPS}[0]
214     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
215     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[1]    @{NET_2_VM_IPS}[1]    ping -c 3 @{NET_2_VM_IPS}[0]
216     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
217     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[2]    @{NET_3_VM_IPS}[0]    ping -c 3 @{NET_3_VM_IPS}[1]
218     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
219
220 Verify Ping On Different Networks
221     [Documentation]    Verify ping among VMs of different network
222     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ping -c 3 @{NET_2_VM_IPS}[0]
223     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
224     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[1]    @{NET_2_VM_IPS}[0]    ping -c 3 @{NET_3_VM_IPS}[0]
225     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
226     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ping -c 3 @{NET_2_VM_IPS}[1]
227     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
228     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[1]    @{NET_2_VM_IPS}[1]    ping -c 3 @{NET_3_VM_IPS}[1]
229     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
230     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[2]    @{NET_3_VM_IPS}[0]    ping -c 3 @{NET_1_VM_IPS}[1]
231     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
232
233 Verify Flows Are Present
234     [Arguments]    ${ip}
235     [Documentation]    Verify Flows Are Present
236     ${flow_output}=    Utils.Run Command On Remote System    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
237     BuiltIn.Log    ${flow_output}
238     ${resp} =    BuiltIn.Should Contain    ${flow_output}    table=50
239     ${resp} =    BuiltIn.Should Contain    ${flow_output}    table=21,
240     @{vm_ips} =    BuiltIn.Create List    @{NET_1_VM_IPS}    @{NET_2_VM_IPS}    @{NET_3_VM_IPS}
241     ${resp} =    Should Match regexp    ${flow_output}    table=0.*goto_table:36
242     ${resp} =    Should Match regexp    ${flow_output}    table=0.*goto_table:17
243     : FOR    ${ip}    IN    @{vm_ips}
244     \    ${resp} =    Should Match regexp    ${flow_output}    table=21.*nw_dst=${ip}
245
246 Verify Ping To Sub Interface
247     [Arguments]    ${sub_interface_ip}
248     [Documentation]    Verify ping to the sub-interface
249     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ping -c 3 ${sub_interface_ip}
250     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
251     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[1]    @{NET_2_VM_IPS}[0]    ping -c 3 ${sub_interface_ip}
252     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
253     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[2]    @{NET_3_VM_IPS}[0]    ping -c 3 ${sub_interface_ip}
254     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
255
256 Verify Learnt IP
257     [Arguments]    ${ip}    ${session}
258     [Documentation]    Check that sub interface ip has been learnt after ARP request
259     ${resp}    RequestsLibrary.Get Request    ${session}    /restconf/operational/odl-l3vpn:learnt-vpn-vip-to-port-data/
260     BuiltIn.Log    ${resp.content}
261     BuiltIn.Should Contain    ${resp.content}    ${ip}
262
263 TODO
264     Fail    "Not implemented"