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