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