Use - or _ depending on openstack version
[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 If    '${OPENSTACK_BRANCH}'=='stable/newton'    --allowed-address ip_address=${EXTRA_NW_SUBNET[0]} --allowed-address ip_address=${EXTRA_NW_SUBNET[1]}    --allowed-address ip-address=${EXTRA_NW_SUBNET[0]} --allowed-address ip-address=${EXTRA_NW_SUBNET[1]}
76     Create Port    ${NETWORKS[0]}    ${PORT_LIST[0]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
77     Create Port    ${NETWORKS[0]}    ${PORT_LIST[1]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
78     Create Port    ${NETWORKS[1]}    ${PORT_LIST[2]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
79     Create Port    ${NETWORKS[1]}    ${PORT_LIST[3]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
80     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${CONFIG_API}/neutron:neutron/ports/    ${PORT_LIST}
81     ${PORTS_MACADDR} =    Get Ports MacAddr    ${PORT_LIST}
82     Set Suite Variable    ${PORTS_MACADDR}
83     Update Port    ${PORT_LIST[0]}    additional_args=--description ${UPDATE_PORT}
84     ${output} =    Show Port    ${PORT_LIST[0]}
85
86 Create Nova VMs
87     [Documentation]    Create Vm instances on compute node with port
88     Create Vm Instance With Port On Compute Node    ${PORT_LIST[0]}    ${VM_INSTANCES_NET10[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
89     Create Vm Instance With Port On Compute Node    ${PORT_LIST[1]}    ${VM_INSTANCES_NET10[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
90     Create Vm Instance With Port On Compute Node    ${PORT_LIST[2]}    ${VM_INSTANCES_NET20[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
91     Create Vm Instance With Port On Compute Node    ${PORT_LIST[3]}    ${VM_INSTANCES_NET20[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
92     ${VM_INSTANCES} =    Create List    @{VM_INSTANCES_NET10}    @{VM_INSTANCES_NET20}
93     : FOR    ${VM}    IN    @{VM_INSTANCES}
94     \    Wait Until Keyword Succeeds    25s    5s    Verify VM Is ACTIVE    ${VM}
95     Log    Check for routes
96     Wait Until Keyword Succeeds    30s    10s    Wait For Routes To Propogate    ${NETWORKS}    ${SUBNETS_CIDR}
97     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
98     ...    true    @{VM_INSTANCES_NET10}
99     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
100     ...    true    @{VM_INSTANCES_NET20}
101     ${VM_IP_NET10}    ${DHCP_IP1}    Collect VM IP Addresses    false    @{VM_INSTANCES_NET10}
102     ${VM_IP_NET20}    ${DHCP_IP2}    Collect VM IP Addresses    false    @{VM_INSTANCES_NET20}
103     ${VM_INSTANCES}=    Collections.Combine Lists    ${VM_INSTANCES_NET10}    ${VM_INSTANCES_NET20}
104     ${VM_IPS}=    Collections.Combine Lists    ${VM_IP_NET10}    ${VM_IP_NET20}
105     Log Many    Obtained IPs    ${VM_IPS}
106     ${LOOP_COUNT}    Get Length    ${VM_INSTANCES_NET10}
107     : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
108     \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
109     \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    nova console-log @{VM_INSTANCES}[${index}]    30s
110     Log    ${VM_IP_NET10}
111     Set Suite Variable    ${VM_IP_NET10}
112     Log    ${VM_IP_NET20}
113     Set Suite Variable    ${VM_IP_NET20}
114     Should Not Contain    ${VM_IP_NET10}    None
115     Should Not Contain    ${VM_IP_NET20}    None
116     [Teardown]    Run Keywords    Show Debugs    @{VM_INSTANCES_NET10}    @{VM_INSTANCES_NET20}
117     ...    AND    Get Suite Teardown Debugs
118
119 Check ELAN Datapath Traffic Within The Networks
120     [Documentation]    Checks datapath within the same network with different vlans.
121     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ping -c 3 ${VM_IP_NET10[1]}
122     Should Contain    ${output}    64 bytes
123     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET20[0]}    ping -c 3 ${VM_IP_NET20[1]}
124     Should Contain    ${output}    64 bytes
125
126 Create Routers
127     [Documentation]    Create Router
128     Create Router    ${ROUTERS[0]}
129     ${router_output} =    List Router
130     Log    ${router_output}
131     Should Contain    ${router_output}    ${ROUTERS[0]}
132     ${router_list} =    Create List    ${ROUTERS[0]}
133     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${ROUTER_URL}    ${router_list}
134
135 Add Interfaces To Router
136     [Documentation]    Add Interfaces
137     : FOR    ${INTERFACE}    IN    @{SUBNETS}
138     \    Add Router Interface    ${ROUTERS[0]}    ${INTERFACE}
139     ${interface_output} =    Show Router Interface    ${ROUTERS[0]}
140     ${GWMAC_ADDRS}    ${GWIP_ADDRS} =    Get Gateway MAC And IP Address    ${ROUTERS[0]}
141     Log    ${GWMAC_ADDRS}
142     Set Suite Variable    ${GWMAC_ADDRS}
143     Log    ${GWIP_ADDRS}
144     Set Suite Variable    ${GWIP_ADDRS}
145
146 Check L3_Datapath Traffic Across Networks With Router
147     [Documentation]    Datapath test across the networks using router for L3.
148     Log    Verification of FIB Entries and Flow
149     ${cn1_conn_id} =    Start Packet Capture on Node    ${OS_COMPUTE_1_IP}    file_Name=tcpDumpCN1
150     ${cn2_conn_id} =    Start Packet Capture on Node    ${OS_COMPUTE_2_IP}    file_Name=tcpDumpCN2
151     ${os_conn_id} =    Start Packet Capture on Node    ${OS_CONTROL_NODE_IP}    file_Name=tcpDumpOS
152     ${vm_instances} =    Create List    @{VM_IP_NET10}    @{VM_IP_NET20}
153     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${FIB_ENTRY_URL}    ${vm_instances}
154     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_1_IP}    ${vm_instances}
155     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_2_IP}    ${vm_instances}
156     #Verify GWMAC Table
157     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Entry On ODL    ${GWMAC_ADDRS}
158     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_1_IP}
159     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_2_IP}
160     Log    L3 Datapath test across the networks using router
161     ${dst_ip_list} =    Create List    ${VM_IP_NET10[1]}    @{VM_IP_NET20}
162     Log    ${dst_ip_list}
163     Test Operations From Vm Instance    ${NETWORKS[0]}    ${VM_IP_NET10[0]}    ${dst_ip_list}
164     ${dst_ip_list} =    Create List    ${VM_IP_NET20[1]}    @{VM_IP_NET10}
165     Log    ${dst_ip_list}
166     Test Operations From Vm Instance    ${NETWORKS[1]}    ${VM_IP_NET20[0]}    ${dst_ip_list}
167     [Teardown]    Test Teardown With Tcpdump Stop    ${cn1_conn_id}    ${cn2_conn_id}    ${os_conn_id}
168
169 Add Multiple Extra Routes And Check Datapath Before L3VPN Creation
170     [Documentation]    Add multiple extra routes and check data path before L3VPN creation
171     Log    "Adding extra one route to VM"
172     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
173     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP1}
174     ${CONFIG_EXTRA_ROUTE_IP2} =    Catenate    sudo ifconfig eth0:2 @{EXTRA_NW_IP}[1] netmask 255.255.255.0 up
175     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP2}
176     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ifconfig
177     ${EXT_RT1} =    Set Variable    destination=40.1.1.0/24,gateway=${VM_IP_NET10[0]}
178     ${EXT_RT2} =    Set Variable    destination=50.1.1.0/24,gateway=${VM_IP_NET10[0]}
179     ${cmd} =    Catenate    ${RT_OPTIONS}    ${EXT_RT1}    ${RT_OPTIONS}    ${EXT_RT2}
180     Update Router    @{ROUTERS}[0]    ${cmd}
181     Show Router    @{ROUTERS}[0]    -D
182     Log    "Verify FIB table"
183     ${vm_instances} =    Create List    @{EXTRA_NW_SUBNET}
184     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${FIB_ENTRY_URL}    ${vm_instances}
185     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping -c 3 @{EXTRA_NW_IP}[1]
186     Should Contain    ${output}    64 bytes
187     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET20[1]}    ping -c 3 @{EXTRA_NW_IP}[1]
188     Should Contain    ${output}    64 bytes
189     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping -c 3 @{EXTRA_NW_IP}[0]
190     Should Contain    ${output}    64 bytes
191
192 Delete Extra Route
193     [Documentation]    Delete the extra routes
194     Update Router    @{ROUTERS}[0]    ${RT_CLEAR}
195     Show Router    @{ROUTERS}[0]    -D
196
197 Delete And Recreate Extra Route
198     [Documentation]    Recreate multiple extra route and check data path before L3VPN creation
199     Log    "Adding extra route to VM"
200     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
201     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP1}
202     ${EXT_RT1} =    Set Variable    destination=40.1.1.0/24,gateway=${VM_IP_NET10[0]}
203     ${cmd} =    Catenate    ${RT_OPTIONS}    ${EXT_RT1}
204     Update Router    @{ROUTERS}[0]    ${cmd}
205     Show Router    @{ROUTERS}[0]    -D
206     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping -c 3 @{EXTRA_NW_IP}[0]
207     Should Contain    ${output}    64 bytes
208     # clear off extra-routes before the next set of tests
209     [Teardown]    Run Keywords    Update Router    @{ROUTERS}[0]    ${RT_CLEAR}
210     ...    AND    Show Router    @{ROUTERS}[0]    -D
211     ...    AND    Get Test Teardown Debugs
212
213 Create L3VPN
214     [Documentation]    Creates L3VPN and verify the same
215     ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
216     ${tenant_id} =    Get Tenant ID From Network    ${net_id}
217     Log    @{RDS}[0]
218     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[0]}    name=${VPN_NAME[0]}    rd=@{RDS}[0]    exportrt=@{RDS}[0]    importrt=@{RDS}[0]    tenantid=${tenant_id}
219     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
220     Should Contain    ${resp}    ${VPN_INSTANCE_ID[0]}
221
222 Associate L3VPN To Routers
223     [Documentation]    Associating router to L3VPN
224     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
225     Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
226     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
227     Should Contain    ${resp}    ${router_id}
228
229 Verify L3VPN Datapath With Router Association
230     [Documentation]    Datapath test across the networks using L3VPN with router association.
231     Log    Verify VPN interfaces, FIB entries and Flow table
232     ${vm_instances} =    Create List    @{VM_IP_NET10}    @{VM_IP_NET20}
233     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${VPN_IFACES_URL}    ${vm_instances}
234     ${RD} =    Strip String    ${RDS[0]}    characters="[]
235     Log    ${RD}
236     Wait Until Keyword Succeeds    60s    5s    Check For Elements At URI    ${CONFIG_API}/odl-fib:fibEntries/vrfTables/${RD}/    ${vm_instances}
237     Wait Until Keyword Succeeds    60s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_1_IP}    ${vm_instances}
238     Wait Until Keyword Succeeds    60s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_2_IP}    ${vm_instances}
239     #Verify GWMAC Table
240     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Entry On ODL    ${GWMAC_ADDRS}
241     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_1_IP}
242     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_2_IP}
243     Log    Check datapath from network1 to network2
244     ${dst_ip_list} =    Create List    @{VM_IP_NET10}[1]    @{VM_IP_NET20}
245     Log    ${dst_ip_list}
246     Test Operations From Vm Instance    ${NETWORKS[0]}    @{VM_IP_NET10}[0]    ${dst_ip_list}
247     Log    Check datapath from network2 to network1
248     ${dst_ip_list} =    Create List    @{VM_IP_NET20}[1]    @{VM_IP_NET10}
249     Log    ${dst_ip_list}
250     Test Operations From Vm Instance    ${NETWORKS[1]}    @{VM_IP_NET20}[0]    ${dst_ip_list}
251
252 Dissociate L3VPN From Routers
253     [Documentation]    Dissociating router from L3VPN
254     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
255     Dissociate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
256     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
257     Should Not Contain    ${resp}    ${router_id}
258
259 Delete Router And Router Interfaces With L3VPN
260     [Documentation]    Delete Router and Interface to the subnets with L3VPN assciate
261     # Asscoiate router with L3VPN
262     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
263     Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
264     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
265     Should Contain    ${resp}    ${router_id}
266     #Delete Interface
267     : FOR    ${INTERFACE}    IN    @{SUBNETS}
268     \    Remove Interface    ${ROUTERS[0]}    ${INTERFACE}
269     ${interface_output} =    Show Router Interface    ${ROUTERS[0]}
270     : FOR    ${INTERFACE}    IN    @{SUBNETS}
271     \    ${subnet_id} =    Get Subnet Id    ${INTERFACE}    ${devstack_conn_id}
272     \    Should Not Contain    ${interface_output}    ${subnet_id}
273     # Delete Router and Interface to the subnets.
274     Delete Router    ${ROUTERS[0]}
275     ${router_output} =    List Router
276     Log    ${router_output}
277     Should Not Contain    ${router_output}    ${ROUTERS[0]}
278     ${router_list} =    Create List    ${ROUTERS[0]}
279     Wait Until Keyword Succeeds    3s    1s    Check For Elements Not At URI    ${ROUTER_URL}    ${router_list}
280     # Verify Router Entry removed from L3VPN
281     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
282     Should Not Contain    ${resp}    ${router_id}
283     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry Removed From Flow Table    ${OS_COMPUTE_1_IP}
284     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry Removed From Flow Table    ${OS_COMPUTE_2_IP}
285
286 Delete Router With NonExistentRouter Name
287     [Documentation]    Delete router with nonExistentRouter name
288     ${rc}    ${output}=    Run And Return Rc And Output    neutron router-delete nonExistentRouter
289     Log    ${output}
290     Log    ${rc}
291     Should Match Regexp    ${output}    Unable to find router with name or id 'nonExistentRouter'|Unable to find router\\(s\\) with id\\(s\\) 'nonExistentRouter'
292
293 Associate L3VPN To Networks
294     [Documentation]    Associates L3VPN to networks and verify
295     ${network1_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
296     ${network2_id} =    Get Net Id    ${NETWORKS[1]}    ${devstack_conn_id}
297     Associate L3VPN To Network    networkid=${network1_id}    vpnid=${VPN_INSTANCE_ID[0]}
298     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
299     Should Contain    ${resp}    ${network1_id}
300     Associate L3VPN To Network    networkid=${network2_id}    vpnid=${VPN_INSTANCE_ID[0]}
301     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
302     Should Contain    ${resp}    ${network2_id}
303
304 Dissociate L3VPN From Networks
305     [Documentation]    Dissociate L3VPN from networks
306     ${network1_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
307     ${network2_id} =    Get Net Id    ${NETWORKS[1]}    ${devstack_conn_id}
308     Dissociate L3VPN From Networks    networkid=${network1_id}    vpnid=${VPN_INSTANCE_ID[0]}
309     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
310     Should Not Contain    ${resp}    ${network1_id}
311     Dissociate L3VPN From Networks    networkid=${network2_id}    vpnid=${VPN_INSTANCE_ID[0]}
312     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
313     Should Not Contain    ${resp}    ${network2_id}
314
315 Delete L3VPN
316     [Documentation]    Delete L3VPN
317     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
318
319 Create Multiple L3VPN
320     [Documentation]    Creates three L3VPNs and then verify the same
321     ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
322     ${tenant_id} =    Get Tenant ID From Network    ${net_id}
323     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[0]}    name=${VPN_NAME[0]}    rd=${RDS[0]}    exportrt=${RDS[0]}    importrt=${RDS[0]}    tenantid=${tenant_id}
324     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[1]}    name=${VPN_NAME[1]}    rd=${RDS[1]}    exportrt=${RDS[1]}    importrt=${RDS[1]}    tenantid=${tenant_id}
325     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[2]}    name=${VPN_NAME[2]}    rd=${RDS[2]}    exportrt=${RDS[2]}    importrt=${RDS[2]}    tenantid=${tenant_id}
326     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
327     Should Contain    ${resp}    ${VPN_INSTANCE_ID[0]}
328     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[1]}
329     Should Contain    ${resp}    ${VPN_INSTANCE_ID[1]}
330     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[2]}
331     Should Contain    ${resp}    ${VPN_INSTANCE_ID[2]}
332
333 Check Datapath Traffic Across Networks With L3VPN
334     [Documentation]    Datapath Test Across the networks with VPN.
335     [Tags]    exclude
336     Log    This test will be added in the next patch
337
338 Delete Multiple L3VPN
339     [Documentation]    Delete three L3VPNs created using Multiple L3VPN Test
340     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
341     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[1]}
342     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[2]}
343
344 *** Keywords ***
345 Test Teardown With Tcpdump Stop
346     [Arguments]    ${cn1_conn_id}    ${cn2_conn_id}    ${os_conn_id}
347     Stop Packet Capture on Node    ${cn1_conn_id}
348     Stop Packet Capture on Node    ${cn2_conn_id}
349     Stop Packet Capture on Node    ${os_conn_id}
350     Get Test Teardown Debugs
351
352 Get Gateway MAC And IP Address
353     [Arguments]    ${router_Name}
354     [Documentation]    Get Gateway mac and IP Address
355     ${output} =    Write Commands Until Prompt    neutron router-port-list ${router_Name}    30s
356     @{MacAddr-list} =    Get Regexp Matches    ${output}    ${MAC_REGEX}
357     @{IpAddr-list} =    Get Regexp Matches    ${output}    ${IP_REGEX}
358     [Return]    ${MacAddr-list}    ${IpAddr-list}
359
360 Verify GWMAC Flow Entry On Flow Table
361     [Arguments]    ${cnIp}
362     [Documentation]    Verify the GWMAC Table, ARP Response table and Dispatcher table.
363     ${flow_output}=    Run Command On Remote System    ${cnIp}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
364     Log    ${flow_output}
365     ${group_output}=    Run Command On Remote System    ${cnIp}    sudo ovs-ofctl -O OpenFlow13 dump-groups br-int
366     Log    ${group_output}
367     #Verify DISPATCHER_TABLE - 17
368     Should Contain    ${flow_output}    table=${DISPATCHER_TABLE}
369     ${dispatcher_table} =    Get Lines Containing String    ${flow_output}    table=${DISPATCHER_TABLE}
370     Log    ${dispatcher_table}
371     Should Contain    ${dispatcher_table}    goto_table:${GWMAC_TABLE}
372     Should Not Contain    ${dispatcher_table}    goto_table:${ARP_RESPONSE_TABLE}
373     #Verify GWMAC_TABLE - 19
374     Should Contain    ${flow_output}    table=${GWMAC_TABLE}
375     ${gwmac_table} =    Get Lines Containing String    ${flow_output}    table=${GWMAC_TABLE}
376     Log    ${gwmac_table}
377     #Verify GWMAC address present in table 19
378     : FOR    ${macAdd}    IN    @{GWMAC_ADDRS}
379     \    Should Contain    ${gwmac_table}    dl_dst=${macAdd} actions=goto_table:${L3_TABLE}
380     #verify Miss entry
381     Should Contain    ${gwmac_table}    actions=resubmit(,17)
382     #arp request and response
383     Should Match Regexp    ${gwmac_table}    ${ARP_RESPONSE_REGEX}
384     ${match} =    Should Match Regexp    ${gwmac_table}    ${ARP_REQUEST_REGEX}
385     ${groupID} =    Split String    ${match}    separator=:
386     Log    groupID
387     Verify ARP REQUEST in groupTable    ${group_output}    ${groupID[1]}
388     #Verify ARP_RESPONSE_TABLE - 81
389     Should Contain    ${flow_output}    table=${ARP_RESPONSE_TABLE}
390     ${arpResponder_table} =    Get Lines Containing String    ${flow_output}    table=${ARP_RESPONSE_TABLE}
391     Log    ${arpResponder_table}
392     Should Contain    ${arpResponder_table}    priority=0 actions=drop
393     : FOR    ${macAdd}    ${ipAdd}    IN ZIP    ${GWMAC_ADDRS}    ${GWIP_ADDRS}
394     \    ${ARP_RESPONSE_IP_MAC_REGEX} =    Set Variable    arp_tpa=${ipAdd},arp_op=1 actions=.*,set_field:${macAdd}->eth_src
395     \    Should Match Regexp    ${arpResponder_table}    ${ARP_RESPONSE_IP_MAC_REGEX}