Migrate to Openstack CLI
[integration/test.git] / csit / suites / netvirt / 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-vpnservice1
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_INSTANCES} =    Create List    @{VM_INSTANCES_NET1}    @{VM_INSTANCES_NET2}    @{VM_INSTANCES_NET3}
28     : FOR    ${VM}    IN    @{VM_INSTANCES}
29     \    Wait Until Keyword Succeeds    25s    5s    Verify VM Is ACTIVE    ${VM}
30     ${VM_IP_NET1}    ${DHCP_IP1}    Collect VM IP Addresses    false    @{VM_INSTANCES_NET1}
31     ${VM_IP_NET2}    ${DHCP_IP2}    Collect VM IP Addresses    false    @{VM_INSTANCES_NET2}
32     ${VM_IP_NET3}    ${DHCP_IP3}    Collect VM IP Addresses    false    @{VM_INSTANCES_NET3}
33     ${VM_INSTANCES}=    Collections.Combine Lists    ${VM_INSTANCES_NET1}    ${VM_INSTANCES_NET2}    ${VM_INSTANCES_NET3}
34     ${VM_IPS}=    Collections.Combine Lists    ${VM_IP_NET1}    ${VM_IP_NET2}    ${VM_IP_NET3}
35     ${LOOP_COUNT}    Get Length    ${VM_INSTANCES_NET1}
36     : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
37     \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
38     \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    nova console-log @{VM_INSTANCES}[${index}]    30s
39     Set Suite Variable    ${VM_IP_NET1}
40     Set Suite Variable    ${VM_IP_NET2}
41     Set Suite Variable    ${VM_IP_NET3}
42     Should Not Contain    ${VM_IP_NET1}    None
43     Should Not Contain    ${VM_IP_NET2}    None
44     Should Not Contain    ${VM_IP_NET3}    None
45     ${vm_instances} =    Create List    @{VM_IP_NET1}    @{VM_IP_NET2}    @{VM_IP_NET3}
46     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${FIB_ENTRIES_URL}    ${vm_instances}
47     Verify Ping On Same Networks
48     Verify Ping On Different Networks
49
50 TC01 Verify GARP Requests
51     [Documentation]    Verify that GARP request are sent to controller
52     Set Suite Variable    ${FIB_ENTRY_1}    ${VM_IP_NET1[0]}
53     Set Suite Variable    ${FIB_ENTRY_3}    ${VM_IP_NET1[1]}
54     Wait Until Keyword Succeeds    10s    1s    Verify Flows Are Present    ${OS_COMPUTE_1_IP}
55     Wait Until Keyword Succeeds    10s    1s    Verify Flows Are Present    ${OS_COMPUTE_2_IP}
56     ${output}=    Get Fib Entries    session
57     ${resp}=    Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_3}\/32".*"${OS_COMPUTE_2_IP}\\"
58     ${resp}=    Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_1}\/32".*"${OS_COMPUTE_1_IP}\\"
59     Log    Checking the RX Packets Count on VM1 and VM2 before ARP Broadcast
60     ${rx_packet1_before} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ifconfig eth0
61     ${rx_packet0_before} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ifconfig eth0
62     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
63     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ${CONFIG_EXTRA_ROUTE_IP1}
64     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ifconfig
65     Should Contain    ${output}    eth0:1
66     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ${RPING_MIP_IP}
67     Should Contain    ${output}    broadcast
68     Should Contain    ${output}    Received 0 reply
69     Log    Checking the RX Packets Count on VM1 and VM2 after ARP Broadcast
70     ${rx_packet1_after} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ifconfig eth0
71     ${rx_packet0_after} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ifconfig eth0
72     Should Not Be Equal    ${rx_packet0_before}    ${rx_packet0_after}
73     Should Not Be Equal    ${rx_packet1_before}    ${rx_packet1_after}
74     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present    ${OS_COMPUTE_1_IP}
75     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present    ${OS_COMPUTE_2_IP}
76     Wait Until Keyword Succeeds    5s    1s    Verify Learnt IP    ${FIB_ENTRY_2}    session
77     ${output}=    Get Fib Entries    session
78     ${resp}=    Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_3}\\/32".*"${OS_COMPUTE_2_IP}\\"
79     ${resp}=    Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_1}\\/32".*"${OS_COMPUTE_1_IP}\\"
80     ${resp}=    Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_2}\\/32".*"${OS_COMPUTE_2_IP}\\"
81     Verify Ping To Sub Interface    ${FIB_ENTRY_2}
82
83 TC02 Verify MIP Migration
84     [Documentation]    Verify that after migration of movable ip across compute nodes, the controller updates the routes
85     Log    Bring down the Sub Interface on DPN2
86     ${UNCONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 down
87     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ${UNCONFIG_EXTRA_ROUTE_IP1}
88     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ifconfig
89     Should Not Contain    ${output}    eth0:1
90     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
91     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ${CONFIG_EXTRA_ROUTE_IP1}
92     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ifconfig
93     Should Contain    ${output}    eth0:1
94     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ifconfig eth0:1
95     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ${RPING_MIP_IP}
96     Should Contain    ${output}    Received 0 reply
97     Should Contain    ${output}    broadcast
98     Wait Until Keyword Succeeds    5s    1s    Verify Learnt IP    ${FIB_ENTRY_2}    session
99     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ${RPING_MIP_IP}
100     ${output}    Get Fib Entries    session
101     ${resp}=    Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_2}\\/32".*"${OS_COMPUTE_1_IP}\\"
102     Verify Ping To Sub Interface    ${FIB_ENTRY_2}
103     Log    Removing the created sub-interface
104     ${UNCONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 down
105     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ${UNCONFIG_EXTRA_ROUTE_IP1}
106
107 TC03 Verify ping to subnet gateway
108     [Documentation]    Verify pig happens to subnet gateway. To be sobmitted in next patch
109     [Tags]    not-implemented    exclude
110     TODO
111
112 TC04 If anything other than subnet ip then no reply
113     [Documentation]    If anything other than subnet ip then no reply. To be sobmitted in next patch
114     [Tags]    not-implemented    exclude
115     TODO
116
117 TC05 Validate multiple mip migration
118     [Documentation]    Validate multiple mip migration. To be sobmitted in next patch
119     [Tags]    not-implemented    exclude
120     TODO
121
122 TC06 Same DPN MIP Migration
123     [Documentation]    Same DPN MIP Migration. To be sobmitted in next patch
124     [Tags]    not-implemented    exclude
125     TODO
126
127 *** Keywords ***
128 Start Suite
129     [Documentation]    Run at start of the suite
130     DevstackUtils.Devstack Suite Setup
131     SetupUtils.Setup_Utils_For_Setup_And_Teardown
132     Create Setup
133
134 End Suite
135     [Documentation]    Run at end of the suite
136     Delete Setup
137     Close All Connections
138
139 Create Setup
140     [Documentation]    Create networks,subnets,ports and VMs
141     : FOR    ${network}    IN    @{NETWORKS}
142     \    Create Network    ${network}
143     ${NET_LIST}    List Networks
144     : FOR    ${network}    IN    @{NETWORKS}
145     \    Should Contain    ${NET_LIST}    ${network}
146     : FOR    ${i}    IN RANGE    0    3
147     \    Create SubNet    ${NETWORKS[${i}]}    ${SUBNETS[${i}]}    ${SUBNET_CIDR[${i}]}
148     ${SUB_LIST}    List Subnets
149     : FOR    ${subnet}    IN    @{SUBNETS}
150     \    Should Contain    ${SUB_LIST}    ${subnet}
151     Neutron Security Group Create    ${SECURITY_GROUP}
152     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=ingress    port_range_max=65535    port_range_min=1    protocol=tcp
153     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=egress    port_range_max=65535    port_range_min=1    protocol=tcp
154     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=ingress    protocol=icmp
155     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=egress    protocol=icmp
156     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=ingress    port_range_max=65535    port_range_min=1    protocol=udp
157     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=egress    port_range_max=65535    port_range_min=1    protocol=udp
158     Create Port    ${NETWORKS[0]}    ${PORT_LIST[0]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
159     Create Port    ${NETWORKS[0]}    ${PORT_LIST[1]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
160     Create Port    ${NETWORKS[1]}    ${PORT_LIST[2]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
161     Create Port    ${NETWORKS[1]}    ${PORT_LIST[3]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
162     Create Port    ${NETWORKS[1]}    ${PORT_LIST[4]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
163     Create Port    ${NETWORKS[1]}    ${PORT_LIST[5]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
164     Create Vm Instance With Port On Compute Node    ${PORT_LIST[0]}    ${VM_INSTANCES_NET1[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
165     Create Vm Instance With Port On Compute Node    ${PORT_LIST[1]}    ${VM_INSTANCES_NET1[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
166     Create Vm Instance With Port On Compute Node    ${PORT_LIST[2]}    ${VM_INSTANCES_NET2[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
167     Create Vm Instance With Port On Compute Node    ${PORT_LIST[3]}    ${VM_INSTANCES_NET2[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
168     Create Vm Instance With Port On Compute Node    ${PORT_LIST[4]}    ${VM_INSTANCES_NET3[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
169     Create Vm Instance With Port On Compute Node    ${PORT_LIST[5]}    ${VM_INSTANCES_NET3[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
170     Create Router    ${ROUTERS}
171     Add Router Interface    ${ROUTERS}    ${SUBNETS[1]}
172     Add Router Interface    ${ROUTERS}    ${SUBNETS[2]}
173     ${devstack_conn_id} =    Get ControlNode Connection
174     Switch Connection    ${devstack_conn_id}
175     ${net_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
176     Set Suite Variable    ${net_id}
177     ${tenant_id} =    Get Tenant ID From Network    ${net_id}
178     Set Suite Variable    ${tenant_id}
179     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}
180     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
181     Should Contain    ${resp}    ${VPN_INSTANCE_ID[0]}
182     Associate L3VPN To Network    networkid=${net_id}    vpnid=${VPN_INSTANCE_ID[0]}
183     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
184     Should Contain    ${resp}    ${net_id}
185     ${router_id}=    Get Router Id    ${ROUTERS}    ${devstack_conn_id}
186     Set Suite Variable    ${router_id}
187     Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
188     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
189     Should Contain    ${resp}    ${router_id}
190
191 Verify Ping On Same Networks
192     [Documentation]    Verify ping among VM of same network
193     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ping -c 3 ${VM_IP_NET1[1]}
194     Should Contain    ${output}    ${PING_REGEXP}
195     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[0]}    ping -c 3 ${VM_IP_NET2[1]}
196     Should Contain    ${output}    ${PING_REGEXP}
197     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ping -c 3 ${VM_IP_NET1[0]}
198     Should Contain    ${output}    ${PING_REGEXP}
199     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[1]}    ping -c 3 ${VM_IP_NET2[0]}
200     Should Contain    ${output}    ${PING_REGEXP}
201     ${output}=    Execute Command on VM Instance    @{NETWORKS}[2]    ${VM_IP_NET3[0]}    ping -c 3 ${VM_IP_NET3[1]}
202     Should Contain    ${output}    ${PING_REGEXP}
203
204 Verify Ping On Different Networks
205     [Documentation]    Verify ping among VMs of different network
206     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ping -c 3 ${VM_IP_NET2[0]}
207     Should Contain    ${output}    ${PING_REGEXP}
208     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[0]}    ping -c 3 ${VM_IP_NET3[0]}
209     Should Contain    ${output}    ${PING_REGEXP}
210     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ping -c 3 ${VM_IP_NET2[1]}
211     Should Contain    ${output}    ${PING_REGEXP}
212     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[1]}    ping -c 3 ${VM_IP_NET3[1]}
213     Should Contain    ${output}    ${PING_REGEXP}
214     ${output}=    Execute Command on VM Instance    @{NETWORKS}[2]    ${VM_IP_NET3[0]}    ping -c 3 ${VM_IP_NET1[1]}
215     Should Contain    ${output}    ${PING_REGEXP}
216
217 Verify Flows Are Present
218     [Arguments]    ${ip}
219     [Documentation]    Verify Flows Are Present
220     ${flow_output}=    Run Command On Remote System    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
221     Log    ${flow_output}
222     ${resp}=    Should Contain    ${flow_output}    table=50
223     ${resp}=    Should Contain    ${flow_output}    table=21,
224     @{vm_ip}=    Create List    @{VM_IP_NET1}    @{VM_IP_NET2}    @{VM_IP_NET3}
225     ${resp}=    Should Match regexp    ${flow_output}    table=0.*goto_table:36
226     ${resp}=    Should Match regexp    ${flow_output}    table=0.*goto_table:17
227     : FOR    ${i}    IN    @{vm_ip}
228     \    ${resp}=    Should Match regexp    ${flow_output}    table=21.*nw_dst=${i}
229
230 Verify Ping To Sub Interface
231     [Arguments]    ${sub_interface_ip}
232     [Documentation]    Verify ping to the sub-interface
233     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ping -c 3 ${sub_interface_ip}
234     Should Contain    ${output}    ${PING_REGEXP}
235     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[0]}    ping -c 3 ${sub_interface_ip}
236     Should Contain    ${output}    ${PING_REGEXP}
237     ${output}=    Execute Command on VM Instance    @{NETWORKS}[2]    ${VM_IP_NET3[0]}    ping -c 3 ${sub_interface_ip}
238     Should Contain    ${output}    ${PING_REGEXP}
239
240 Verify Learnt IP
241     [Arguments]    ${ip}    ${session}
242     [Documentation]    Check that sub interface ip has been learnt after ARP request
243     ${resp}    RequestsLibrary.Get Request    ${session}    /restconf/operational/odl-l3vpn:learnt-vpn-vip-to-port-data/
244     Log    ${resp.content}
245     Should Contain    ${resp.content}    ${ip}
246
247 TODO
248     Fail    "Not implemented"
249
250 Delete Setup
251     [Documentation]    Delete the setup
252     Dissociate L3VPN From Networks    networkid=${net_id}    vpnid=${VPN_INSTANCE_ID[0]}
253     Dissociate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
254     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
255     Remove Interface    ${ROUTERS}    ${SUBNETS[1]}
256     Remove Interface    ${ROUTERS}    ${SUBNETS[2]}
257     Delete Router    ${ROUTERS}
258     ${VM_INSTANCES} =    Create List    @{VM_INSTANCES_NET1}    @{VM_INSTANCES_NET2}    @{VM_INSTANCES_NET3}
259     : FOR    ${VmInstance}    IN    @{VM_INSTANCES}
260     \    Delete Vm Instance    ${VmInstance}
261     : FOR    ${Port}    IN    @{PORT_LIST}
262     \    Delete Port    ${Port}
263     : FOR    ${Subnet}    IN    @{SUBNETS}
264     \    Delete SubNet    ${Subnet}
265     : FOR    ${Network}    IN    @{NETWORKS}
266     \    Delete Network    ${Network}
267     Delete SecurityGroup    ${SECURITY_GROUP}