IPv6: refactor 01_basic_vpnservice.robot
[integration/test.git] / csit / suites / netvirt / Netvirt_Vpnservice / 01_basic_vpnservice.robot
1 *** Settings ***
2 Documentation     Test suite to validate vpnservice functionality in an openstack integrated environment.
3 ...               The assumption of this suite is that the environment is already configured with the proper
4 ...               integration bridges and vxlan tunnels.
5 Suite Setup       Basic Vpnservice Suite Setup
6 Suite Teardown    Basic Vpnservice Suite Teardown
7 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
8 Test Teardown     Get Test Teardown Debugs
9 Library           OperatingSystem
10 Library           RequestsLibrary
11 Resource          ../../../libraries/Utils.robot
12 Resource          ../../../libraries/OpenStackOperations.robot
13 Resource          ../../../libraries/DevstackUtils.robot
14 Resource          ../../../libraries/VpnOperations.robot
15 Resource          ../../../libraries/OVSDB.robot
16 Resource          ../../../libraries/SetupUtils.robot
17 Resource          ../../../libraries/Tcpdump.robot
18 Resource          ../../../variables/Variables.robot
19 Resource          ../../../variables/netvirt/Variables.robot
20
21 *** Variables ***
22 @{NETWORKS}       NET10    NET20
23 @{SUBNETS}        SUBNET1    SUBNET2
24 @{SUBNETS_CIDR}    10.1.1.0/24    20.1.1.0/24
25 @{PORT_LIST}      PORT11    PORT21    PORT12    PORT22
26 @{VM_INSTANCES_NET10}    VM11    VM21
27 @{VM_INSTANCES_NET20}    VM12    VM22
28 @{ROUTERS}        ROUTER_1    ROUTER_2
29 @{EXTRA_NW_IP}    40.1.1.2    50.1.1.2
30 @{EXTRA_NW_SUBNET}    40.1.1.0/24    50.1.1.0/24
31 ${SECURITY_GROUP}    sg-vpnservice
32 ${UPDATE_NETWORK}    UpdateNetwork
33 ${UPDATE_SUBNET}    UpdateSubnet
34 ${UPDATE_PORT}    UpdatePort
35
36 *** Test Cases ***
37 Create Neutron Networks
38     [Documentation]    Create two networks
39     Create Network    ${NETWORKS[0]}
40     Create Network    ${NETWORKS[1]}
41     ${NET_LIST}    List Networks
42     Log    ${NET_LIST}
43     Should Contain    ${NET_LIST}    ${NETWORKS[0]}
44     Should Contain    ${NET_LIST}    ${NETWORKS[1]}
45     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${NETWORK_URL}    ${NETWORKS}
46     Update Network    ${NETWORKS[0]}    additional_args=--description ${UPDATE_NETWORK}
47     ${output} =    Show Network    ${NETWORKS[0]}
48     Should Contain    ${output}    ${UPDATE_NETWORK}
49
50 Create Neutron Subnets
51     [Documentation]    Create two subnets for previously created networks
52     Create SubNet    ${NETWORKS[0]}    ${SUBNETS[0]}    ${SUBNETS_CIDR[0]}
53     Create SubNet    ${NETWORKS[1]}    ${SUBNETS[1]}    ${SUBNETS_CIDR[1]}
54     ${SUB_LIST}    List Subnets
55     Log    ${SUB_LIST}
56     Should Contain    ${SUB_LIST}    ${SUBNETS[0]}
57     Should Contain    ${SUB_LIST}    ${SUBNETS[1]}
58     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${SUBNETWORK_URL}    ${SUBNETS}
59     Update SubNet    ${SUBNETS[0]}    additional_args=--description ${UPDATE_SUBNET}
60     ${output} =    Show SubNet    ${SUBNETS[0]}
61     Should Contain    ${output}    ${UPDATE_SUBNET}
62
63 Add Ssh Allow Rule
64     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
65     Neutron Security Group Create    ${SECURITY_GROUP}
66     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=ingress    port_range_max=65535    port_range_min=1    protocol=tcp
67     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=egress    port_range_max=65535    port_range_min=1    protocol=tcp
68     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=ingress    protocol=icmp
69     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=egress    protocol=icmp
70     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=ingress    port_range_max=65535    port_range_min=1    protocol=udp
71     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=egress    port_range_max=65535    port_range_min=1    protocol=udp
72
73 Create Neutron Ports
74     [Documentation]    Create four ports under previously created subnets
75     ${allowed_address_pairs_args}=    Set Variable    --allowed-address ip_address=${EXTRA_NW_SUBNET[0]} --allowed-address ip_address=${EXTRA_NW_SUBNET[1]}
76     ${allowed_address_pairs_os_cli}=    Set Variable    --allowed-address ip-address=${EXTRA_NW_SUBNET[0]} --allowed-address ip-address=${EXTRA_NW_SUBNET[1]}
77     Run Keyword If    '${OPENSTACK_BRANCH}'=='stable/newton'    Create Port    ${NETWORKS[0]}    ${PORT_LIST[0]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
78     ...    ELSE    Create Port    ${NETWORKS[0]}    ${PORT_LIST[0]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_os_cli}
79     Run Keyword If    '${OPENSTACK_BRANCH}'=='stable/newton'    Create Port    ${NETWORKS[0]}    ${PORT_LIST[1]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
80     ...    ELSE    Create Port    ${NETWORKS[0]}    ${PORT_LIST[1]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_os_cli}
81     Run Keyword If    '${OPENSTACK_BRANCH}'=='stable/newton'    Create Port    ${NETWORKS[1]}    ${PORT_LIST[2]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
82     ...    ELSE    Create Port    ${NETWORKS[1]}    ${PORT_LIST[2]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_os_cli}
83     Run Keyword If    '${OPENSTACK_BRANCH}'=='stable/newton'    Create Port    ${NETWORKS[1]}    ${PORT_LIST[3]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
84     ...    ELSE    Create Port    ${NETWORKS[1]}    ${PORT_LIST[3]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_os_cli}
85     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${CONFIG_API}/neutron:neutron/ports/    ${PORT_LIST}
86     ${PORTS_MACADDR} =    Get Ports MacAddr    ${PORT_LIST}
87     Set Suite Variable    ${PORTS_MACADDR}
88     Update Port    ${PORT_LIST[0]}    additional_args=--description ${UPDATE_PORT}
89     ${output} =    Show Port    ${PORT_LIST[0]}
90
91 Create Nova VMs
92     [Documentation]    Create Vm instances on compute node with port
93     Create Vm Instance With Port On Compute Node    ${PORT_LIST[0]}    ${VM_INSTANCES_NET10[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
94     Create Vm Instance With Port On Compute Node    ${PORT_LIST[1]}    ${VM_INSTANCES_NET10[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
95     Create Vm Instance With Port On Compute Node    ${PORT_LIST[2]}    ${VM_INSTANCES_NET20[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
96     Create Vm Instance With Port On Compute Node    ${PORT_LIST[3]}    ${VM_INSTANCES_NET20[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
97     ${VM_INSTANCES} =    Create List    @{VM_INSTANCES_NET10}    @{VM_INSTANCES_NET20}
98     : FOR    ${VM}    IN    @{VM_INSTANCES}
99     \    Wait Until Keyword Succeeds    25s    5s    Verify VM Is ACTIVE    ${VM}
100     Log    Check for routes
101     Wait Until Keyword Succeeds    30s    10s    Wait For Routes To Propogate    ${NETWORKS}    ${SUBNETS_CIDR}
102     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
103     ...    true    @{VM_INSTANCES_NET10}
104     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
105     ...    true    @{VM_INSTANCES_NET20}
106     ${VM_IP_NET10}    ${DHCP_IP1}    Collect VM IP Addresses    false    @{VM_INSTANCES_NET10}
107     ${VM_IP_NET20}    ${DHCP_IP2}    Collect VM IP Addresses    false    @{VM_INSTANCES_NET20}
108     ${VM_INSTANCES}=    Collections.Combine Lists    ${VM_INSTANCES_NET10}    ${VM_INSTANCES_NET20}
109     ${VM_IPS}=    Collections.Combine Lists    ${VM_IP_NET10}    ${VM_IP_NET20}
110     Log Many    Obtained IPs    ${VM_IPS}
111     ${LOOP_COUNT}    Get Length    ${VM_INSTANCES_NET10}
112     : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
113     \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
114     \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    nova console-log @{VM_INSTANCES}[${index}]    30s
115     Log    ${VM_IP_NET10}
116     Set Suite Variable    ${VM_IP_NET10}
117     Log    ${VM_IP_NET20}
118     Set Suite Variable    ${VM_IP_NET20}
119     Should Not Contain    ${VM_IP_NET10}    None
120     Should Not Contain    ${VM_IP_NET20}    None
121     [Teardown]    Run Keywords    Show Debugs    @{VM_INSTANCES_NET10}    @{VM_INSTANCES_NET20}
122     ...    AND    Get Suite Teardown Debugs
123
124 Check ELAN Datapath Traffic Within The Networks
125     [Documentation]    Checks datapath within the same network with different vlans.
126     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ping -c 3 ${VM_IP_NET10[1]}
127     Should Contain    ${output}    64 bytes
128     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET20[0]}    ping -c 3 ${VM_IP_NET20[1]}
129     Should Contain    ${output}    64 bytes
130
131 Create Routers
132     [Documentation]    Create Router
133     Create Router    ${ROUTERS[0]}
134     ${router_output} =    List Router
135     Log    ${router_output}
136     Should Contain    ${router_output}    ${ROUTERS[0]}
137     ${router_list} =    Create List    ${ROUTERS[0]}
138     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${ROUTER_URL}    ${router_list}
139
140 Add Interfaces To Router
141     [Documentation]    Add Interfaces
142     ${devstack_conn_id} =    Get ControlNode Connection
143     : FOR    ${INTERFACE}    IN    @{SUBNETS}
144     \    Add Router Interface    ${ROUTERS[0]}    ${INTERFACE}
145     ${interface_output} =    Show Router Interface    ${ROUTERS[0]}
146     ${GWMAC_ADDRS}    ${GWIP_ADDRS} =    Get Gateway MAC And IP Address    ${ROUTERS[0]}
147     Log    ${GWMAC_ADDRS}
148     Set Suite Variable    ${GWMAC_ADDRS}
149     Log    ${GWIP_ADDRS}
150     Set Suite Variable    ${GWIP_ADDRS}
151
152 Check L3_Datapath Traffic Across Networks With Router
153     [Documentation]    Datapath test across the networks using router for L3.
154     Log    Verification of FIB Entries and Flow
155     ${cn1_conn_id} =    Start Packet Capture on Node    ${OS_COMPUTE_1_IP}    file_Name=tcpDumpCN1
156     ${cn2_conn_id} =    Start Packet Capture on Node    ${OS_COMPUTE_2_IP}    file_Name=tcpDumpCN2
157     ${os_conn_id} =    Start Packet Capture on Node    ${OS_CONTROL_NODE_IP}    file_Name=tcpDumpOS
158     ${vm_instances} =    Create List    @{VM_IP_NET10}    @{VM_IP_NET20}
159     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${FIB_ENTRY_URL}    ${vm_instances}
160     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_1_IP}    ${vm_instances}
161     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_2_IP}    ${vm_instances}
162     #Verify GWMAC Table
163     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Entry On ODL    ${GWMAC_ADDRS}
164     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_1_IP}
165     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_2_IP}
166     Log    L3 Datapath test across the networks using router
167     ${dst_ip_list} =    Create List    ${VM_IP_NET10[1]}    @{VM_IP_NET20}
168     Log    ${dst_ip_list}
169     Test Operations From Vm Instance    ${NETWORKS[0]}    ${VM_IP_NET10[0]}    ${dst_ip_list}
170     ${dst_ip_list} =    Create List    ${VM_IP_NET20[1]}    @{VM_IP_NET10}
171     Log    ${dst_ip_list}
172     Test Operations From Vm Instance    ${NETWORKS[1]}    ${VM_IP_NET20[0]}    ${dst_ip_list}
173     [Teardown]    Test Teardown With Tcpdump Stop    ${cn1_conn_id}    ${cn2_conn_id}    ${os_conn_id}
174
175 Add Multiple Extra Routes And Check Datapath Before L3VPN Creation
176     [Documentation]    Add multiple extra routes and check data path before L3VPN creation
177     Log    "Adding extra one route to VM"
178     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
179     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP1}
180     ${CONFIG_EXTRA_ROUTE_IP2} =    Catenate    sudo ifconfig eth0:2 @{EXTRA_NW_IP}[1] netmask 255.255.255.0 up
181     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP2}
182     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ifconfig
183     ${EXT_RT1} =    Set Variable    destination=40.1.1.0/24,gateway=${VM_IP_NET10[0]}
184     ${EXT_RT2} =    Set Variable    destination=50.1.1.0/24,gateway=${VM_IP_NET10[0]}
185     ${cmd} =    Catenate    ${RT_OPTIONS}    ${EXT_RT1}    ${RT_OPTIONS}    ${EXT_RT2}
186     Update Router    @{ROUTERS}[0]    ${cmd}
187     Show Router    @{ROUTERS}[0]    -D
188     Log    "Verify FIB table"
189     ${vm_instances} =    Create List    @{EXTRA_NW_SUBNET}
190     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${FIB_ENTRY_URL}    ${vm_instances}
191     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping -c 3 @{EXTRA_NW_IP}[1]
192     Should Contain    ${output}    64 bytes
193     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET20[1]}    ping -c 3 @{EXTRA_NW_IP}[1]
194     Should Contain    ${output}    64 bytes
195     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping -c 3 @{EXTRA_NW_IP}[0]
196     Should Contain    ${output}    64 bytes
197
198 Delete Extra Route
199     [Documentation]    Delete the extra routes
200     Update Router    @{ROUTERS}[0]    ${RT_CLEAR}
201     Show Router    @{ROUTERS}[0]    -D
202
203 Delete And Recreate Extra Route
204     [Documentation]    Recreate multiple extra route and check data path before L3VPN creation
205     Log    "Adding extra route to VM"
206     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
207     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP1}
208     ${EXT_RT1} =    Set Variable    destination=40.1.1.0/24,gateway=${VM_IP_NET10[0]}
209     ${cmd} =    Catenate    ${RT_OPTIONS}    ${EXT_RT1}
210     Update Router    @{ROUTERS}[0]    ${cmd}
211     Show Router    @{ROUTERS}[0]    -D
212     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping -c 3 @{EXTRA_NW_IP}[0]
213     Should Contain    ${output}    64 bytes
214     # clear off extra-routes before the next set of tests
215     [Teardown]    Run Keywords    Update Router    @{ROUTERS}[0]    ${RT_CLEAR}
216     ...    AND    Show Router    @{ROUTERS}[0]    -D
217     ...    AND    Get Test Teardown Debugs
218
219 Create L3VPN
220     [Documentation]    Creates L3VPN and verify the same
221     ${devstack_conn_id} =    Get ControlNode Connection
222     Switch Connection    ${devstack_conn_id}
223     ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
224     ${tenant_id} =    Get Tenant ID From Network    ${net_id}
225     Log    @{RDS}[0]
226     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[0]}    name=${VPN_NAME[0]}    rd=@{RDS}[0]    exportrt=@{RDS}[0]    importrt=@{RDS}[0]    tenantid=${tenant_id}
227     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
228     Should Contain    ${resp}    ${VPN_INSTANCE_ID[0]}
229
230 Associate L3VPN To Routers
231     [Documentation]    Associating router to L3VPN
232     ${devstack_conn_id}=    Get ControlNode Connection
233     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
234     Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
235     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
236     Should Contain    ${resp}    ${router_id}
237
238 Verify L3VPN Datapath With Router Association
239     [Documentation]    Datapath test across the networks using L3VPN with router association.
240     Log    Verify VPN interfaces, FIB entries and Flow table
241     ${vm_instances} =    Create List    @{VM_IP_NET10}    @{VM_IP_NET20}
242     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${VPN_IFACES_URL}    ${vm_instances}
243     ${RD} =    Strip String    ${RDS[0]}    characters="[]
244     Log    ${RD}
245     Wait Until Keyword Succeeds    60s    5s    Check For Elements At URI    ${CONFIG_API}/odl-fib:fibEntries/vrfTables/${RD}/    ${vm_instances}
246     Wait Until Keyword Succeeds    60s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_1_IP}    ${vm_instances}
247     Wait Until Keyword Succeeds    60s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_2_IP}    ${vm_instances}
248     #Verify GWMAC Table
249     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Entry On ODL    ${GWMAC_ADDRS}
250     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_1_IP}
251     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_2_IP}
252     Log    Check datapath from network1 to network2
253     ${dst_ip_list} =    Create List    @{VM_IP_NET10}[1]    @{VM_IP_NET20}
254     Log    ${dst_ip_list}
255     Test Operations From Vm Instance    ${NETWORKS[0]}    @{VM_IP_NET10}[0]    ${dst_ip_list}
256     Log    Check datapath from network2 to network1
257     ${dst_ip_list} =    Create List    @{VM_IP_NET20}[1]    @{VM_IP_NET10}
258     Log    ${dst_ip_list}
259     Test Operations From Vm Instance    ${NETWORKS[1]}    @{VM_IP_NET20}[0]    ${dst_ip_list}
260
261 Dissociate L3VPN From Routers
262     [Documentation]    Dissociating router from L3VPN
263     ${devstack_conn_id}=    Get ControlNode Connection
264     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
265     Dissociate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
266     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
267     Should Not Contain    ${resp}    ${router_id}
268
269 Delete Router And Router Interfaces With L3VPN
270     [Documentation]    Delete Router and Interface to the subnets with L3VPN assciate
271     # Asscoiate router with L3VPN
272     ${devstack_conn_id} =    Get ControlNode Connection
273     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
274     Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
275     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
276     Should Contain    ${resp}    ${router_id}
277     #Delete Interface
278     : FOR    ${INTERFACE}    IN    @{SUBNETS}
279     \    Remove Interface    ${ROUTERS[0]}    ${INTERFACE}
280     ${interface_output} =    Show Router Interface    ${ROUTERS[0]}
281     : FOR    ${INTERFACE}    IN    @{SUBNETS}
282     \    ${subnet_id} =    Get Subnet Id    ${INTERFACE}    ${devstack_conn_id}
283     \    Should Not Contain    ${interface_output}    ${subnet_id}
284     # Delete Router and Interface to the subnets.
285     Delete Router    ${ROUTERS[0]}
286     ${router_output} =    List Router
287     Log    ${router_output}
288     Should Not Contain    ${router_output}    ${ROUTERS[0]}
289     ${router_list} =    Create List    ${ROUTERS[0]}
290     Wait Until Keyword Succeeds    3s    1s    Check For Elements Not At URI    ${ROUTER_URL}    ${router_list}
291     # Verify Router Entry removed from L3VPN
292     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
293     Should Not Contain    ${resp}    ${router_id}
294     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry Removed From Flow Table    ${OS_COMPUTE_1_IP}
295     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry Removed From Flow Table    ${OS_COMPUTE_2_IP}
296
297 Delete Router With NonExistentRouter Name
298     [Documentation]    Delete router with nonExistentRouter name
299     ${devstack_conn_id}=    Get ControlNode Connection
300     Switch Connection    ${devstack_conn_id}
301     ${output} =    Write Commands Until Prompt    neutron router-delete nonExistentRouter    30s
302     Close Connection
303     Should Match Regexp    ${output}    Unable to find router with name or id 'nonExistentRouter'|Unable to find router\\(s\\) with id\\(s\\) 'nonExistentRouter'
304
305 Associate L3VPN To Networks
306     [Documentation]    Associates L3VPN to networks and verify
307     ${devstack_conn_id} =    Get ControlNode Connection
308     ${network1_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
309     ${network2_id} =    Get Net Id    ${NETWORKS[1]}    ${devstack_conn_id}
310     Associate L3VPN To Network    networkid=${network1_id}    vpnid=${VPN_INSTANCE_ID[0]}
311     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
312     Should Contain    ${resp}    ${network1_id}
313     Associate L3VPN To Network    networkid=${network2_id}    vpnid=${VPN_INSTANCE_ID[0]}
314     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
315     Should Contain    ${resp}    ${network2_id}
316
317 Dissociate L3VPN From Networks
318     [Documentation]    Dissociate L3VPN from networks
319     ${devstack_conn_id} =    Get ControlNode Connection
320     ${network1_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
321     ${network2_id} =    Get Net Id    ${NETWORKS[1]}    ${devstack_conn_id}
322     Dissociate L3VPN From Networks    networkid=${network1_id}    vpnid=${VPN_INSTANCE_ID[0]}
323     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
324     Should Not Contain    ${resp}    ${network1_id}
325     Dissociate L3VPN From Networks    networkid=${network2_id}    vpnid=${VPN_INSTANCE_ID[0]}
326     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
327     Should Not Contain    ${resp}    ${network2_id}
328
329 Delete L3VPN
330     [Documentation]    Delete L3VPN
331     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
332
333 Create Multiple L3VPN
334     [Documentation]    Creates three L3VPNs and then verify the same
335     ${devstack_conn_id} =    Get ControlNode Connection
336     Switch Connection    ${devstack_conn_id}
337     ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
338     ${tenant_id} =    Get Tenant ID From Network    ${net_id}
339     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[0]}    name=${VPN_NAME[0]}    rd=${RDS[0]}    exportrt=${RDS[0]}    importrt=${RDS[0]}    tenantid=${tenant_id}
340     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[1]}    name=${VPN_NAME[1]}    rd=${RDS[1]}    exportrt=${RDS[1]}    importrt=${RDS[1]}    tenantid=${tenant_id}
341     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[2]}    name=${VPN_NAME[2]}    rd=${RDS[2]}    exportrt=${RDS[2]}    importrt=${RDS[2]}    tenantid=${tenant_id}
342     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
343     Should Contain    ${resp}    ${VPN_INSTANCE_ID[0]}
344     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[1]}
345     Should Contain    ${resp}    ${VPN_INSTANCE_ID[1]}
346     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[2]}
347     Should Contain    ${resp}    ${VPN_INSTANCE_ID[2]}
348
349 Check Datapath Traffic Across Networks With L3VPN
350     [Documentation]    Datapath Test Across the networks with VPN.
351     [Tags]    exclude
352     Log    This test will be added in the next patch
353
354 Delete Multiple L3VPN
355     [Documentation]    Delete three L3VPNs created using Multiple L3VPN Test
356     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
357     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[1]}
358     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[2]}
359
360 *** Keywords ***
361 Test Teardown With Tcpdump Stop
362     [Arguments]    ${cn1_conn_id}    ${cn2_conn_id}    ${os_conn_id}
363     Stop Packet Capture on Node    ${cn1_conn_id}
364     Stop Packet Capture on Node    ${cn2_conn_id}
365     Stop Packet Capture on Node    ${os_conn_id}
366     Get Test Teardown Debugs
367
368 Get Gateway MAC And IP Address
369     [Arguments]    ${router_Name}
370     [Documentation]    Get Gateway mac and IP Address
371     ${devstack_conn_id}=    Get ControlNode Connection
372     Switch Connection    ${devstack_conn_id}
373     ${output} =    Write Commands Until Prompt    neutron router-port-list ${router_Name}    30s
374     @{MacAddr-list} =    Get Regexp Matches    ${output}    ${MAC_REGEX}
375     @{IpAddr-list} =    Get Regexp Matches    ${output}    ${IP_REGEX}
376     [Return]    ${MacAddr-list}    ${IpAddr-list}
377
378 Verify GWMAC Flow Entry On Flow Table
379     [Arguments]    ${cnIp}
380     [Documentation]    Verify the GWMAC Table, ARP Response table and Dispatcher table.
381     ${flow_output}=    Run Command On Remote System    ${cnIp}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
382     Log    ${flow_output}
383     ${group_output}=    Run Command On Remote System    ${cnIp}    sudo ovs-ofctl -O OpenFlow13 dump-groups br-int
384     Log    ${group_output}
385     #Verify DISPATCHER_TABLE - 17
386     Should Contain    ${flow_output}    table=${DISPATCHER_TABLE}
387     ${dispatcher_table} =    Get Lines Containing String    ${flow_output}    table=${DISPATCHER_TABLE}
388     Log    ${dispatcher_table}
389     Should Contain    ${dispatcher_table}    goto_table:${GWMAC_TABLE}
390     Should Not Contain    ${dispatcher_table}    goto_table:${ARP_RESPONSE_TABLE}
391     #Verify GWMAC_TABLE - 19
392     Should Contain    ${flow_output}    table=${GWMAC_TABLE}
393     ${gwmac_table} =    Get Lines Containing String    ${flow_output}    table=${GWMAC_TABLE}
394     Log    ${gwmac_table}
395     #Verify GWMAC address present in table 19
396     : FOR    ${macAdd}    IN    @{GWMAC_ADDRS}
397     \    Should Contain    ${gwmac_table}    dl_dst=${macAdd} actions=goto_table:${L3_TABLE}
398     #verify Miss entry
399     Should Contain    ${gwmac_table}    actions=resubmit(,17)
400     #arp request and response
401     Should Match Regexp    ${gwmac_table}    ${ARP_RESPONSE_REGEX}
402     ${match} =    Should Match Regexp    ${gwmac_table}    ${ARP_REQUEST_REGEX}
403     ${groupID} =    Split String    ${match}    separator=:
404     Log    groupID
405     Verify ARP REQUEST in groupTable    ${group_output}    ${groupID[1]}
406     #Verify ARP_RESPONSE_TABLE - 81
407     Should Contain    ${flow_output}    table=${ARP_RESPONSE_TABLE}
408     ${arpResponder_table} =    Get Lines Containing String    ${flow_output}    table=${ARP_RESPONSE_TABLE}
409     Log    ${arpResponder_table}
410     Should Contain    ${arpResponder_table}    priority=0 actions=drop
411     : FOR    ${macAdd}    ${ipAdd}    IN ZIP    ${GWMAC_ADDRS}    ${GWIP_ADDRS}
412     \    ${ARP_RESPONSE_IP_MAC_REGEX} =    Set Variable    arp_tpa=${ipAdd},arp_op=1 actions=.*,set_field:${macAdd}->eth_src
413     \    Should Match Regexp    ${arpResponder_table}    ${ARP_RESPONSE_IP_MAC_REGEX}