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