Add suite setups for remaining modules
[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       Suite Setup
4 Suite Teardown    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/DevstackUtils.robot
10 Resource          ../../../libraries/OpenStackOperations.robot
11 Resource          ../../../libraries/SetupUtils.robot
12 Resource          ../../../libraries/VpnOperations.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 Verify Setup
41     [Documentation]    Verify that VMs received ip and ping is happening between different VM
42     ${vms} =    BuiltIn.Create List    @{NET_1_VM_IPS}    @{NET_2_VM_IPS}    @{NET_3_VM_IPS}
43     BuiltIn.Wait Until Keyword Succeeds    30s    10s    Utils.Check For Elements At URI    ${FIB_ENTRIES_URL}    ${vms}
44     Verify Ping On Same Networks
45     Verify Ping On Different Networks
46
47 Verify GARP Requests
48     [Documentation]    Verify that GARP request are sent to controller
49     BuiltIn.Pass Execution If    "${OS_DEPLOY}" == "1cmb-0ctl-0cmp"    "Test is not supported for combo node"
50     BuiltIn.Set Test Variable    ${fib_entry_1}    @{NET_1_VM_IPS}[0]
51     BuiltIn.Set Test Variable    ${fib_entry_3}    @{NET_1_VM_IPS}[1]
52     Verify Flows Are Present On All Compute Nodes
53     ${output} =    VpnOperations.Get Fib Entries    session
54     ${resp} =    BuiltIn.Should Match Regexp    ${output}    destPrefix\\":\\"${fib_entry_3}\/32".*"${OS_CMP2_IP}\\"
55     ${resp} =    BuiltIn.Should Match Regexp    ${output}    destPrefix\\":\\"${fib_entry_1}\/32".*"${OS_CMP1_IP}\\"
56     ${rx_packet1_before} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ifconfig eth0
57     ${rx_packet0_before} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ifconfig eth0
58     ${config_extra_route_ip1} =    BuiltIn.Catenate    sudo ifconfig ${SUB_IF} @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
59     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ${config_extra_route_ip1}
60     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ifconfig
61     BuiltIn.Should Contain    ${output}    ${SUB_IF}
62     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ${RPING_MIP_IP}
63     BuiltIn.Should Contain    ${output}    broadcast
64     BuiltIn.Should Contain    ${output}    Received 0 reply
65     ${rx_packet1_after} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ifconfig eth0
66     ${rx_packet0_after} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ifconfig eth0
67     BuiltIn.Should Not Be Equal    ${rx_packet0_before}    ${rx_packet0_after}
68     BuiltIn.Should Not Be Equal    ${rx_packet1_before}    ${rx_packet1_after}
69     Verify Flows Are Present On All Compute Nodes
70     BuiltIn.Wait Until Keyword Succeeds    5s    1s    Verify Learnt IP    ${FIB_ENTRY_2}    session
71     ${output} =    VpnOperations.Get Fib Entries    session
72     ${resp} =    BuiltIn.Should Match Regexp    ${output}    destPrefix\\":\\"${fib_entry_3}\\/32".*"${OS_CMP2_IP}\\"
73     ${resp} =    BuiltIn.Should Match Regexp    ${output}    destPrefix\\":\\"${fib_entry_1}\\/32".*"${OS_CMP1_IP}\\"
74     ${resp} =    BuiltIn.Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_2}\\/32".*"${OS_CMP2_IP}\\"
75     Verify Ping To Sub Interface    ${FIB_ENTRY_2}
76
77 Verify MIP Migration
78     [Documentation]    Verify that after migration of movable ip across compute nodes, the controller updates the routes
79     BuiltIn.Pass Execution If    "${OS_DEPLOY}" == "1cmb-0ctl-0cmp"    "Test is not supported for combo node"
80     ${unconfig_extra_route_ip1} =    BuiltIn.Catenate    sudo ifconfig ${SUB_IF} down
81     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ${unconfig_extra_route_ip1}
82     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ifconfig
83     BuiltIn.Should Not Contain    ${output}    ${SUB_IF}
84     ${config_extra_route_ip1} =    BuiltIn.Catenate    sudo ifconfig ${SUB_IF} @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
85     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ${config_extra_route_ip1}
86     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ifconfig
87     BuiltIn.Should Contain    ${output}    ${SUB_IF}
88     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ifconfig ${SUB_IF}
89     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ${RPING_MIP_IP}
90     BuiltIn.Should Contain    ${output}    Received 0 reply
91     BuiltIn.Should Contain    ${output}    broadcast
92     BuiltIn.Wait Until Keyword Succeeds    5s    1s    Verify Learnt IP    ${FIB_ENTRY_2}    session
93     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ${RPING_MIP_IP}
94     ${output}    VpnOperations.Get Fib Entries    session
95     ${resp}=    BuiltIn.Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_2}\\/32".*"${OS_CMP1_IP}\\"
96     Verify Ping To Sub Interface    ${FIB_ENTRY_2}
97     ${unconfig_extra_route_ip1} =    BuiltIn.Catenate    sudo ifconfig ${SUB_IF} down
98     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ${unconfig_extra_route_ip1}
99
100 Verify ping to subnet gateway
101     [Documentation]    Verify ping happens to subnet gateway. To be submitted in next patch
102     [Tags]    not-implemented    exclude
103     TODO
104
105 If anything other than subnet ip then no reply
106     [Documentation]    If anything other than subnet ip then no reply. To be submitted in next patch
107     [Tags]    not-implemented    exclude
108     TODO
109
110 Validate multiple mip migration
111     [Documentation]    Validate multiple mip migration. To be submitted in next patch
112     [Tags]    not-implemented    exclude
113     TODO
114
115 Same DPN MIP Migration
116     [Documentation]    Same DPN MIP Migration. To be submitted in next patch
117     [Tags]    not-implemented    exclude
118     TODO
119
120 *** Keywords ***
121 Suite Setup
122     VpnOperations.Basic Suite Setup
123     : FOR    ${network}    IN    @{NETWORKS}
124     \    OpenStackOperations.Create Network    ${network}
125     ${neutron_networks} =    OpenStackOperations.List Networks
126     : FOR    ${network}    IN    @{NETWORKS}
127     \    BuiltIn.Should Contain    ${neutron_networks}    ${network}
128     ${NET_ID} =    OpenStackOperations.Get Net Id    @{NETWORKS}[0]
129     BuiltIn.Set Suite Variable    ${NET_ID}
130     : FOR    ${i}    IN RANGE    0    3
131     \    OpenStackOperations.Create SubNet    @{NETWORKS}[${i}]    @{SUBNETS}[${i}]    @{SUBNET_CIDRS}[${i}]
132     ${neutron_subnets} =    OpenStackOperations.List Subnets
133     : FOR    ${subnet}    IN    @{SUBNETS}
134     \    BuiltIn.Should Contain    ${neutron_subnets}    ${subnet}
135     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
136     OpenStackOperations.Create Port    @{NETWORKS}[0]    @{PORTS}[0]    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
137     OpenStackOperations.Create Port    @{NETWORKS}[0]    @{PORTS}[1]    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
138     OpenStackOperations.Create Port    @{NETWORKS}[1]    @{PORTS}[2]    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
139     OpenStackOperations.Create Port    @{NETWORKS}[1]    @{PORTS}[3]    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
140     OpenStackOperations.Create Port    @{NETWORKS}[2]    @{PORTS}[4]    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
141     OpenStackOperations.Create Port    @{NETWORKS}[2]    @{PORTS}[5]    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
142     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${CONFIG_API}/neutron:neutron/ports/    ${PORTS}
143     OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORTS}[0]    @{NET_1_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
144     OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORTS}[1]    @{NET_1_VMS}[1]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
145     OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORTS}[2]    @{NET_2_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
146     OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORTS}[3]    @{NET_2_VMS}[1]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
147     OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORTS}[4]    @{NET_3_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
148     OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORTS}[5]    @{NET_3_VMS}[1]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
149     @{NET_1_VM_IPS}    ${NET_1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
150     @{NET_2_VM_IPS}    ${NET_2_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
151     @{NET_3_VM_IPS}    ${NET_3_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_3_VMS}
152     BuiltIn.Set Suite Variable    @{NET_1_VM_IPS}
153     BuiltIn.Set Suite Variable    @{NET_2_VM_IPS}
154     BuiltIn.Set Suite Variable    @{NET_3_VM_IPS}
155     BuiltIn.Should Not Contain    ${NET_1_VM_IPS}    None
156     BuiltIn.Should Not Contain    ${NET_2_VM_IPS}    None
157     BuiltIn.Should Not Contain    ${NET_3_VM_IPS}    None
158     BuiltIn.Should Not Contain    ${NET_1_DHCP_IP}    None
159     BuiltIn.Should Not Contain    ${NET_2_DHCP_IP}    None
160     BuiltIn.Should Not Contain    ${NET_3_DHCP_IP}    None
161     OpenStackOperations.Create Router    ${ROUTER}
162     OpenStackOperations.Add Router Interface    ${ROUTER}    @{SUBNETS}[1]
163     OpenStackOperations.Add Router Interface    ${ROUTER}    @{SUBNETS}[2]
164     ${tenant_id} =    OpenStackOperations.Get Tenant ID From Network    ${NET_ID}
165     VpnOperations.VPN Create L3VPN    vpnid=@{VPN_INSTANCE_IDS}[0]    name=${VPN_NAMES[0]}    rd=${RD1}    exportrt=${EXPORT_RT}    importrt=${IMPORT_RT}    tenantid=${tenant_id}
166     ${resp} =    VpnOperations.VPN Get L3VPN    vpnid=@{VPN_INSTANCE_IDS}[0]
167     BuiltIn.Should Contain    ${resp}    @{VPN_INSTANCE_IDS}[0]
168     Associate L3VPN To ROUTER
169     OpenStackOperations.Show Debugs    @{NET_1_VMS}    @{NET_2_VMS}    @{NET_3_VMS}
170     OpenStackOperations.Get Suite Debugs
171
172 Suite Teardown
173     [Documentation]    Delete the setup
174     BuiltIn.Run Keyword And Ignore Error    VpnOperations.Dissociate L3VPN From Networks    networkid=${NET_ID}    vpnid=@{VPN_INSTANCE_IDS}[0]
175     BuiltIn.Run Keyword And Ignore Error    VpnOperations.Dissociate VPN to Router    routerid=${ROUTER_ID}    vpnid=@{VPN_INSTANCE_IDS}[0]
176     BuiltIn.Run Keyword And Ignore Error    VpnOperations.VPN Delete L3VPN    vpnid=@{VPN_INSTANCE_IDS}[0]
177     OpenStackOperations.OpenStack Suite Teardown
178
179 Associate L3VPN To ROUTER
180     VpnOperations.Associate L3VPN To Network    networkid=${NET_ID}    vpnid=@{VPN_INSTANCE_IDS}[0]
181     ${resp} =    VpnOperations.VPN Get L3VPN    vpnid=@{VPN_INSTANCE_IDS}[0]
182     BuiltIn.Should Contain    ${resp}    ${NET_ID}
183     ${ROUTER_ID} =    OpenStackOperations.Get Router Id    ${ROUTER}
184     BuiltIn.Set Suite Variable    ${ROUTER_ID}
185     VpnOperations.Associate VPN to Router    routerid=${ROUTER_ID}    vpnid=@{VPN_INSTANCE_IDS}[0]
186     ${resp} =    VpnOperations.VPN Get L3VPN    vpnid=@{VPN_INSTANCE_IDS}[0]
187     BuiltIn.Should Contain    ${resp}    ${ROUTER_ID}
188
189 Verify Ping On Same Networks
190     [Documentation]    Verify ping among VM of same network
191     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ping -c 3 @{NET_1_VM_IPS}[1]
192     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
193     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[1]    @{NET_2_VM_IPS}[0]    ping -c 3 @{NET_2_VM_IPS}[1]
194     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
195     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ping -c 3 @{NET_1_VM_IPS}[0]
196     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
197     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[1]    @{NET_2_VM_IPS}[1]    ping -c 3 @{NET_2_VM_IPS}[0]
198     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
199     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[2]    @{NET_3_VM_IPS}[0]    ping -c 3 @{NET_3_VM_IPS}[1]
200     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
201
202 Verify Ping On Different Networks
203     [Documentation]    Verify ping among VMs of different network
204     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ping -c 3 @{NET_2_VM_IPS}[0]
205     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
206     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[1]    @{NET_2_VM_IPS}[0]    ping -c 3 @{NET_3_VM_IPS}[0]
207     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
208     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[1]    ping -c 3 @{NET_2_VM_IPS}[1]
209     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
210     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[1]    @{NET_2_VM_IPS}[1]    ping -c 3 @{NET_3_VM_IPS}[1]
211     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
212     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[2]    @{NET_3_VM_IPS}[0]    ping -c 3 @{NET_1_VM_IPS}[1]
213     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
214
215 Verify Flows Are Present
216     [Arguments]    ${ip}
217     [Documentation]    Verify Flows Are Present
218     ${flow_output}=    Utils.Run Command On Remote System    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
219     BuiltIn.Log    ${flow_output}
220     ${resp} =    BuiltIn.Should Contain    ${flow_output}    table=50
221     ${resp} =    BuiltIn.Should Contain    ${flow_output}    table=21,
222     @{vm_ips} =    BuiltIn.Create List    @{NET_1_VM_IPS}    @{NET_2_VM_IPS}    @{NET_3_VM_IPS}
223     ${resp} =    Should Match regexp    ${flow_output}    table=0.*goto_table:36
224     ${resp} =    Should Match regexp    ${flow_output}    table=0.*goto_table:17
225     : FOR    ${ip}    IN    @{vm_ips}
226     \    ${resp} =    Should Match regexp    ${flow_output}    table=21.*nw_dst=${ip}
227
228 Verify Flows Are Present On All Compute Nodes
229     [Documentation]    Verify Flows Are Present On All Compute Nodes
230     : FOR    ${ip}    IN    @{OS_CMP_IPS}
231     \    BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Flows Are Present    ${ip}
232
233 Verify Ping To Sub Interface
234     [Arguments]    ${sub_interface_ip}
235     [Documentation]    Verify ping to the sub-interface
236     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ping -c 3 ${sub_interface_ip}
237     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
238     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[1]    @{NET_2_VM_IPS}[0]    ping -c 3 ${sub_interface_ip}
239     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
240     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[2]    @{NET_3_VM_IPS}[0]    ping -c 3 ${sub_interface_ip}
241     BuiltIn.Should Contain    ${output}    ${PING_REGEXP}
242
243 Verify Learnt IP
244     [Arguments]    ${ip}    ${session}
245     [Documentation]    Check that sub interface ip has been learnt after ARP request
246     ${resp}    RequestsLibrary.Get Request    ${session}    /restconf/operational/odl-l3vpn:learnt-vpn-vip-to-port-data/
247     BuiltIn.Log    ${resp.content}
248     BuiltIn.Should Contain    ${resp.content}    ${ip}
249
250 TODO
251     Fail    "Not implemented"