d9484ff15b92dc3e1965c2a61f648d1b63a1b39b
[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 @{SUBNET_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 @{VPN_INSTANCE_ID}    4ae8cd92-48ca-49b5-94e1-b2921a261111    4ae8cd92-48ca-49b5-94e1-b2921a261112    4ae8cd92-48ca-49b5-94e1-b2921a261113
30 @{VPN_NAME}       vpn1    vpn2    vpn3
31 @{CREATE_RD}      ["2200:2"]    ["2300:2"]    ["2400:2"]
32 @{CREATE_EXPORT_RT}    ["2200:2"]    ["2300:2"]    ["2400:2"]
33 @{CREATE_IMPORT_RT}    ["2200:2"]    ["2300:2"]    ["2400:2"]
34 @{EXTRA_NW_IP}    40.1.1.2    50.1.1.2
35 @{EXTRA_NW_SUBNET}    40.1.1.0/24    50.1.1.0/24
36 ${SECURITY_GROUP}    sg-vpnservice
37 # Values passed for extra routes
38 ${RT_OPTIONS}     --routes type=dict list=true
39 ${RT_CLEAR}       --routes action=clear
40 ${ARP_RESPONSE_REGEX}    arp,arp_op=2 actions=CONTROLLER:65535,resubmit\\(,${DISPATCHER_TABLE}\\)
41 ${ARP_REQUEST_REGEX}    arp,arp_op=1 actions=group:\\d+
42 ${ARP_REQUEST_GROUP_REGEX}    actions=CONTROLLER:65535,bucket=actions=resubmit\\(,${DISPATCHER_TABLE}\\),bucket=actions=resubmit\\(,${ARP_RESPONSE_TABLE}\\)
43 ${MAC_REGEX}      (([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2}))
44 ${IP_REGEX}       (([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])
45 ${UPDATE_NETWORK}    UpdateNetwork
46 ${UPDATE_SUBNET}    UpdateSubnet
47 ${UPDATE_PORT}    UpdatePort
48
49 *** Test Cases ***
50 Create Neutron Networks
51     [Documentation]    Create two networks
52     Create Network    ${NETWORKS[0]}
53     Create Network    ${NETWORKS[1]}
54     ${NET_LIST}    List Networks
55     Log    ${NET_LIST}
56     Should Contain    ${NET_LIST}    ${NETWORKS[0]}
57     Should Contain    ${NET_LIST}    ${NETWORKS[1]}
58     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${CONFIG_API}/neutron:neutron/networks/    ${NETWORKS}
59     Update Network    ${NETWORKS[0]}    additional_args=--description ${UPDATE_NETWORK}
60     ${output} =    Show Network    ${NETWORKS[0]}
61     Should Contain    ${output}    ${UPDATE_NETWORK}
62
63 Create Neutron Subnets
64     [Documentation]    Create two subnets for previously created networks
65     Create SubNet    ${NETWORKS[0]}    ${SUBNETS[0]}    ${SUBNET_CIDR[0]}
66     Create SubNet    ${NETWORKS[1]}    ${SUBNETS[1]}    ${SUBNET_CIDR[1]}
67     ${SUB_LIST}    List Subnets
68     Log    ${SUB_LIST}
69     Should Contain    ${SUB_LIST}    ${SUBNETS[0]}
70     Should Contain    ${SUB_LIST}    ${SUBNETS[1]}
71     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${CONFIG_API}/neutron:neutron/subnets/    ${SUBNETS}
72     Update SubNet    ${SUBNETS[0]}    additional_args=--description ${UPDATE_SUBNET}
73     ${output} =    Show SubNet    ${SUBNETS[0]}
74     Should Contain    ${output}    ${UPDATE_SUBNET}
75
76 Add Ssh Allow Rule
77     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
78     Neutron Security Group Create    ${SECURITY_GROUP}
79     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=ingress    port_range_max=65535    port_range_min=1    protocol=tcp    remote_ip_prefix=0.0.0.0/0
80     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=egress    port_range_max=65535    port_range_min=1    protocol=tcp    remote_ip_prefix=0.0.0.0/0
81     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=ingress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
82     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=egress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
83     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=ingress    port_range_max=65535    port_range_min=1    protocol=udp    remote_ip_prefix=0.0.0.0/0
84     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=egress    port_range_max=65535    port_range_min=1    protocol=udp    remote_ip_prefix=0.0.0.0/0
85
86 Create Neutron Ports
87     [Documentation]    Create four ports under previously created subnets
88     ${allowed_address_pairs_args}=    Set Variable    --allowed-address-pairs type=dict list=true ip_address=${EXTRA_NW_SUBNET[0]} ip_address=${EXTRA_NW_SUBNET[1]}
89     Create Port    ${NETWORKS[0]}    ${PORT_LIST[0]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
90     Create Port    ${NETWORKS[0]}    ${PORT_LIST[1]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
91     Create Port    ${NETWORKS[1]}    ${PORT_LIST[2]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
92     Create Port    ${NETWORKS[1]}    ${PORT_LIST[3]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
93     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${CONFIG_API}/neutron:neutron/ports/    ${PORT_LIST}
94     ${PORTS_MACADDR} =    Get Ports MacAddr    ${PORT_LIST}
95     Set Suite Variable    ${PORTS_MACADDR}
96     Update Port    ${PORT_LIST[0]}    additional_args=--description ${UPDATE_PORT}
97     ${output} =    Show Port    ${PORT_LIST[0]}
98     Should Contain    ${output}    ${UPDATE_PORT}
99
100 Create Nova VMs
101     [Documentation]    Create Vm instances on compute node with port
102     Create Vm Instance With Port On Compute Node    ${PORT_LIST[0]}    ${VM_INSTANCES_NET10[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
103     Create Vm Instance With Port On Compute Node    ${PORT_LIST[1]}    ${VM_INSTANCES_NET10[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
104     Create Vm Instance With Port On Compute Node    ${PORT_LIST[2]}    ${VM_INSTANCES_NET20[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
105     Create Vm Instance With Port On Compute Node    ${PORT_LIST[3]}    ${VM_INSTANCES_NET20[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
106     ${VM_INSTANCES} =    Create List    @{VM_INSTANCES_NET10}    @{VM_INSTANCES_NET20}
107     : FOR    ${VM}    IN    @{VM_INSTANCES}
108     \    Wait Until Keyword Succeeds    25s    5s    Verify VM Is ACTIVE    ${VM}
109     Log    Check for routes
110     Wait Until Keyword Succeeds    30s    10s    Wait For Routes To Propogate
111     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
112     ...    true    @{VM_INSTANCES_NET10}
113     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
114     ...    true    @{VM_INSTANCES_NET20}
115     ${VM_IP_NET10}    ${DHCP_IP1}    Collect VM IP Addresses    false    @{VM_INSTANCES_NET10}
116     ${VM_IP_NET20}    ${DHCP_IP2}    Collect VM IP Addresses    false    @{VM_INSTANCES_NET20}
117     ${VM_INSTANCES}=    Collections.Combine Lists    ${VM_INSTANCES_NET10}    ${VM_INSTANCES_NET20}
118     ${VM_IPS}=    Collections.Combine Lists    ${VM_IP_NET10}    ${VM_IP_NET20}
119     ${LOOP_COUNT}    Get Length    ${VM_INSTANCES_NET10}
120     : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
121     \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
122     \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    nova console-log @{VM_INSTANCES}[${index}]    30s
123     Log    ${VM_IP_NET10}
124     Set Suite Variable    ${VM_IP_NET10}
125     Log    ${VM_IP_NET20}
126     Set Suite Variable    ${VM_IP_NET20}
127     Should Not Contain    ${VM_IP_NET10}    None
128     Should Not Contain    ${VM_IP_NET20}    None
129     [Teardown]    Run Keywords    Show Debugs    @{VM_INSTANCES_NET10}    @{VM_INSTANCES_NET20}
130     ...    AND    Get Suite Teardown Debugs
131
132 Check ELAN Datapath Traffic Within The Networks
133     [Documentation]    Checks datapath within the same network with different vlans.
134     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ping -c 3 ${VM_IP_NET10[1]}
135     Should Contain    ${output}    64 bytes
136     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET20[0]}    ping -c 3 ${VM_IP_NET20[1]}
137     Should Contain    ${output}    64 bytes
138
139 Create Routers
140     [Documentation]    Create Router
141     Create Router    ${ROUTERS[0]}
142     ${router_output} =    List Router
143     Log    ${router_output}
144     Should Contain    ${router_output}    ${ROUTERS[0]}
145     ${router_list} =    Create List    ${ROUTERS[0]}
146     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${CONFIG_API}/neutron:neutron/routers/    ${router_list}
147
148 Add Interfaces To Router
149     [Documentation]    Add Interfaces
150     ${devstack_conn_id} =    Get ControlNode Connection
151     : FOR    ${INTERFACE}    IN    @{SUBNETS}
152     \    Add Router Interface    ${ROUTERS[0]}    ${INTERFACE}
153     ${interface_output} =    Show Router Interface    ${ROUTERS[0]}
154     : FOR    ${INTERFACE}    IN    @{SUBNETS}
155     \    ${subnet_id} =    Get Subnet Id    ${INTERFACE}    ${devstack_conn_id}
156     \    Should Contain    ${interface_output}    ${subnet_id}
157     ${GWMAC_ADDRS}    ${GWIP_ADDRS} =    Get Gateway MAC And IP Address    ${ROUTERS[0]}
158     Log    ${GWMAC_ADDRS}
159     Set Suite Variable    ${GWMAC_ADDRS}
160     Log    ${GWIP_ADDRS}
161     Set Suite Variable    ${GWIP_ADDRS}
162
163 Check L3_Datapath Traffic Across Networks With Router
164     [Documentation]    Datapath test across the networks using router for L3.
165     Log    Verification of FIB Entries and Flow
166     ${cn1_conn_id} =    Start Packet Capture on Node    ${OS_COMPUTE_1_IP}    file_Name=tcpDumpCN1
167     ${cn2_conn_id} =    Start Packet Capture on Node    ${OS_COMPUTE_2_IP}    file_Name=tcpDumpCN2
168     ${os_conn_id} =    Start Packet Capture on Node    ${OS_CONTROL_NODE_IP}    file_Name=tcpDumpOS
169     ${vm_instances} =    Create List    @{VM_IP_NET10}    @{VM_IP_NET20}
170     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${CONFIG_API}/odl-fib:fibEntries/    ${vm_instances}
171     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_1_IP}    ${vm_instances}
172     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_2_IP}    ${vm_instances}
173     #Verify GWMAC Table
174     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Entry On ODL    ${GWMAC_ADDRS}
175     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_1_IP}
176     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_2_IP}
177     Log    L3 Datapath test across the networks using router
178     ${dst_ip_list} =    Create List    ${VM_IP_NET10[1]}    @{VM_IP_NET20}
179     Log    ${dst_ip_list}
180     Test Operations From Vm Instance    ${NETWORKS[0]}    ${VM_IP_NET10[0]}    ${dst_ip_list}
181     ${dst_ip_list} =    Create List    ${VM_IP_NET20[1]}    @{VM_IP_NET10}
182     Log    ${dst_ip_list}
183     Test Operations From Vm Instance    ${NETWORKS[1]}    ${VM_IP_NET20[0]}    ${dst_ip_list}
184     [Teardown]    Test Teardown With Tcpdump Stop    ${cn1_conn_id}    ${cn2_conn_id}    ${os_conn_id}
185
186 Add Multiple Extra Routes And Check Datapath Before L3VPN Creation
187     [Documentation]    Add multiple extra routes and check data path before L3VPN creation
188     Log    "Adding extra one route to VM"
189     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
190     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP1}
191     ${CONFIG_EXTRA_ROUTE_IP2} =    Catenate    sudo ifconfig eth0:2 @{EXTRA_NW_IP}[1] netmask 255.255.255.0 up
192     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP2}
193     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ifconfig
194     ${EXT_RT1} =    Set Variable    destination=40.1.1.0/24,nexthop=${VM_IP_NET10[0]}
195     ${EXT_RT2} =    Set Variable    destination=50.1.1.0/24,nexthop=${VM_IP_NET10[0]}
196     ${cmd} =    Catenate    ${RT_OPTIONS}    ${EXT_RT1}    ${EXT_RT2}
197     Update Router    @{ROUTERS}[0]    ${cmd}
198     Show Router    @{ROUTERS}[0]    -D
199     Log    "Verify FIB table"
200     ${vm_instances} =    Create List    @{EXTRA_NW_SUBNET}
201     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${CONFIG_API}/odl-fib:fibEntries/    ${vm_instances}
202     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping -c 3 @{EXTRA_NW_IP}[1]
203     Should Contain    ${output}    64 bytes
204     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET20[1]}    ping -c 3 @{EXTRA_NW_IP}[1]
205     Should Contain    ${output}    64 bytes
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
209 Delete Extra Route
210     [Documentation]    Delete the extra routes
211     Update Router    @{ROUTERS}[0]    ${RT_CLEAR}
212     Show Router    @{ROUTERS}[0]    -D
213
214 Delete And Recreate Extra Route
215     [Documentation]    Recreate multiple extra route and check data path before L3VPN creation
216     Log    "Adding extra route to VM"
217     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
218     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP1}
219     ${EXT_RT1} =    Set Variable    destination=40.1.1.0/24,nexthop=${VM_IP_NET10[0]}
220     ${cmd} =    Catenate    ${RT_OPTIONS}    ${EXT_RT1}
221     Update Router    @{ROUTERS}[0]    ${cmd}
222     Show Router    @{ROUTERS}[0]    -D
223     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping -c 3 @{EXTRA_NW_IP}[0]
224     Should Contain    ${output}    64 bytes
225     # clear off extra-routes before the next set of tests
226     [Teardown]    Run Keywords    Update Router    @{ROUTERS}[0]    ${RT_CLEAR}
227     ...    AND    Show Router    @{ROUTERS}[0]    -D
228     ...    AND    Get Test Teardown Debugs
229
230 Create L3VPN
231     [Documentation]    Creates L3VPN and verify the same
232     ${devstack_conn_id} =    Get ControlNode Connection
233     Switch Connection    ${devstack_conn_id}
234     ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
235     ${tenant_id} =    Get Tenant ID From Network    ${net_id}
236     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[0]}    name=${VPN_NAME[0]}    rd=${CREATE_RD[0]}    exportrt=${CREATE_EXPORT_RT[0]}    importrt=${CREATE_IMPORT_RT[0]}    tenantid=${tenant_id}
237     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
238     Should Contain    ${resp}    ${VPN_INSTANCE_ID[0]}
239
240 Associate L3VPN To Routers
241     [Documentation]    Associating router to L3VPN
242     ${devstack_conn_id}=    Get ControlNode Connection
243     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
244     Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
245     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
246     Should Contain    ${resp}    ${router_id}
247
248 Verify L3VPN Datapath With Router Association
249     [Documentation]    Datapath test across the networks using L3VPN with router association.
250     Log    Verify VPN interfaces, FIB entries and Flow table
251     ${vm_instances} =    Create List    @{VM_IP_NET10}    @{VM_IP_NET20}
252     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${CONFIG_API}/l3vpn:vpn-interfaces/    ${vm_instances}
253     ${RD} =    Strip String    ${CREATE_RD[0]}    characters="[]
254     Log    ${RD}
255     Wait Until Keyword Succeeds    60s    5s    Check For Elements At URI    ${CONFIG_API}/odl-fib:fibEntries/vrfTables/${RD}/    ${vm_instances}
256     Wait Until Keyword Succeeds    60s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_1_IP}    ${vm_instances}
257     Wait Until Keyword Succeeds    60s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_2_IP}    ${vm_instances}
258     #Verify GWMAC Table
259     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Entry On ODL    ${GWMAC_ADDRS}
260     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_1_IP}
261     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_2_IP}
262     Log    Check datapath from network1 to network2
263     ${dst_ip_list} =    Create List    @{VM_IP_NET10}[1]    @{VM_IP_NET20}
264     Log    ${dst_ip_list}
265     Test Operations From Vm Instance    ${NETWORKS[0]}    @{VM_IP_NET10}[0]    ${dst_ip_list}
266     Log    Check datapath from network2 to network1
267     ${dst_ip_list} =    Create List    @{VM_IP_NET20}[1]    @{VM_IP_NET10}
268     Log    ${dst_ip_list}
269     Test Operations From Vm Instance    ${NETWORKS[1]}    @{VM_IP_NET20}[0]    ${dst_ip_list}
270
271 Dissociate L3VPN From Routers
272     [Documentation]    Dissociating router from L3VPN
273     ${devstack_conn_id}=    Get ControlNode Connection
274     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
275     Dissociate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
276     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
277     Should Not Contain    ${resp}    ${router_id}
278
279 Delete Router And Router Interfaces With L3VPN
280     [Documentation]    Delete Router and Interface to the subnets with L3VPN assciate
281     # Asscoiate router with L3VPN
282     ${devstack_conn_id} =    Get ControlNode Connection
283     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
284     Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
285     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
286     Should Contain    ${resp}    ${router_id}
287     #Delete Interface
288     : FOR    ${INTERFACE}    IN    @{SUBNETS}
289     \    Remove Interface    ${ROUTERS[0]}    ${INTERFACE}
290     ${interface_output} =    Show Router Interface    ${ROUTERS[0]}
291     : FOR    ${INTERFACE}    IN    @{SUBNETS}
292     \    ${subnet_id} =    Get Subnet Id    ${INTERFACE}    ${devstack_conn_id}
293     \    Should Not Contain    ${interface_output}    ${subnet_id}
294     # Delete Router and Interface to the subnets.
295     Delete Router    ${ROUTERS[0]}
296     ${router_output} =    List Router
297     Log    ${router_output}
298     Should Not Contain    ${router_output}    ${ROUTERS[0]}
299     ${router_list} =    Create List    ${ROUTERS[0]}
300     Wait Until Keyword Succeeds    3s    1s    Check For Elements Not At URI    ${CONFIG_API}/neutron:neutron/routers/    ${router_list}
301     # Verify Router Entry removed from L3VPN
302     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
303     Should Not Contain    ${resp}    ${router_id}
304     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry Removed From Flow Table    ${OS_COMPUTE_1_IP}
305     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry Removed From Flow Table    ${OS_COMPUTE_2_IP}
306
307 Delete Router With NonExistentRouter Name
308     [Documentation]    Delete router with nonExistentRouter name
309     ${devstack_conn_id}=    Get ControlNode Connection
310     Switch Connection    ${devstack_conn_id}
311     ${output} =    Write Commands Until Prompt    neutron router-delete nonExistentRouter    30s
312     Close Connection
313     Should Match Regexp    ${output}    Unable to find router with name or id 'nonExistentRouter'|Unable to find router\\(s\\) with id\\(s\\) 'nonExistentRouter'
314
315 Associate L3VPN To Networks
316     [Documentation]    Associates L3VPN to networks and verify
317     ${devstack_conn_id} =    Get ControlNode Connection
318     ${network1_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
319     ${network2_id} =    Get Net Id    ${NETWORKS[1]}    ${devstack_conn_id}
320     Associate L3VPN To Network    networkid=${network1_id}    vpnid=${VPN_INSTANCE_ID[0]}
321     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
322     Should Contain    ${resp}    ${network1_id}
323     Associate L3VPN To Network    networkid=${network2_id}    vpnid=${VPN_INSTANCE_ID[0]}
324     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
325     Should Contain    ${resp}    ${network2_id}
326
327 Dissociate L3VPN From Networks
328     [Documentation]    Dissociate L3VPN from networks
329     ${devstack_conn_id} =    Get ControlNode Connection
330     ${network1_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
331     ${network2_id} =    Get Net Id    ${NETWORKS[1]}    ${devstack_conn_id}
332     Dissociate L3VPN From Networks    networkid=${network1_id}    vpnid=${VPN_INSTANCE_ID[0]}
333     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
334     Should Not Contain    ${resp}    ${network1_id}
335     Dissociate L3VPN From Networks    networkid=${network2_id}    vpnid=${VPN_INSTANCE_ID[0]}
336     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
337     Should Not Contain    ${resp}    ${network2_id}
338
339 Delete L3VPN
340     [Documentation]    Delete L3VPN
341     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
342
343 Create Multiple L3VPN
344     [Documentation]    Creates three L3VPNs and then verify the same
345     ${devstack_conn_id} =    Get ControlNode Connection
346     Switch Connection    ${devstack_conn_id}
347     ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
348     ${tenant_id} =    Get Tenant ID From Network    ${net_id}
349     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[0]}    name=${VPN_NAME[0]}    rd=${CREATE_RD[0]}    exportrt=${CREATE_EXPORT_RT[0]}    importrt=${CREATE_IMPORT_RT[0]}    tenantid=${tenant_id}
350     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[1]}    name=${VPN_NAME[1]}    rd=${CREATE_RD[1]}    exportrt=${CREATE_EXPORT_RT[1]}    importrt=${CREATE_IMPORT_RT[1]}    tenantid=${tenant_id}
351     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[2]}    name=${VPN_NAME[2]}    rd=${CREATE_RD[2]}    exportrt=${CREATE_EXPORT_RT[2]}    importrt=${CREATE_IMPORT_RT[2]}    tenantid=${tenant_id}
352     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
353     Should Contain    ${resp}    ${VPN_INSTANCE_ID[0]}
354     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[1]}
355     Should Contain    ${resp}    ${VPN_INSTANCE_ID[1]}
356     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[2]}
357     Should Contain    ${resp}    ${VPN_INSTANCE_ID[2]}
358
359 Delete Multiple L3VPN
360     [Documentation]    Delete three L3VPNs created using Multiple L3VPN Test
361     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
362     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[1]}
363     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[2]}
364
365 Check Datapath Traffic Across Networks With L3VPN
366     [Documentation]    Datapath Test Across the networks with VPN.
367     [Tags]    exclude
368     Log    This test will be added in the next patch
369
370 Delete Vm Instances
371     [Documentation]    Delete Vm instances in the given Instance List
372     ${VM_INSTANCES} =    Create List    @{VM_INSTANCES_NET10}    @{VM_INSTANCES_NET20}
373     : FOR    ${VmInstance}    IN    @{VM_INSTANCES}
374     \    Delete Vm Instance    ${VmInstance}
375
376 Delete Neutron Ports
377     [Documentation]    Delete Neutron Ports in the given Port List.
378     : FOR    ${Port}    IN    @{PORT_LIST}
379     \    Delete Port    ${Port}
380
381 Delete Sub Networks
382     [Documentation]    Delete Sub Nets in the given Subnet List.
383     : FOR    ${Subnet}    IN    @{SUBNETS}
384     \    Delete SubNet    ${Subnet}
385
386 Delete Networks
387     [Documentation]    Delete Networks in the given Net List
388     : FOR    ${Network}    IN    @{NETWORKS}
389     \    Delete Network    ${Network}
390
391 *** Keywords ***
392 Basic Vpnservice Suite Setup
393     SetupUtils.Setup_Utils_For_Setup_And_Teardown
394     DevstackUtils.Devstack Suite Setup
395
396 Basic Vpnservice Suite Teardown
397     Delete SecurityGroup    ${SECURITY_GROUP}
398     Close All Connections
399
400 Test Teardown With Tcpdump Stop
401     [Arguments]    ${cn1_conn_id}    ${cn2_conn_id}    ${os_conn_id}
402     Stop Packet Capture on Node    ${cn1_conn_id}
403     Stop Packet Capture on Node    ${cn2_conn_id}
404     Stop Packet Capture on Node    ${os_conn_id}
405     Get Test Teardown Debugs
406
407 Wait For Routes To Propogate
408     ${devstack_conn_id} =    Get ControlNode Connection
409     Switch Connection    ${devstack_conn_id}
410     ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
411     ${output} =    Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ip route    ]>
412     Should Contain    ${output}    @{SUBNET_CIDR}[0]
413     ${net_id} =    Get Net Id    @{NETWORKS}[1]    ${devstack_conn_id}
414     ${output} =    Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ip route    ]>
415     Should Contain    ${output}    @{SUBNET_CIDR}[1]
416
417 Verify GWMAC Entry On ODL
418     [Arguments]    ${GWMAC_ADDRS}
419     [Documentation]    get ODL GWMAC table entry
420     ${resp} =    RequestsLibrary.Get Request    session    ${CONFIG_API}/neutronvpn:neutron-vpn-portip-port-data/
421     Log    ${resp.content}
422     Should Be Equal As Strings    ${resp.status_code}    200
423     : FOR    ${macAdd}    IN    @{GWMAC_ADDRS}
424     \    Should Contain    ${resp.content}    ${macAdd}
425
426 Get Gateway MAC And IP Address
427     [Arguments]    ${router_Name}
428     [Documentation]    Get Gateway mac and IP Address
429     ${devstack_conn_id}=    Get ControlNode Connection
430     Switch Connection    ${devstack_conn_id}
431     ${output} =    Write Commands Until Prompt    neutron router-port-list ${router_Name}    30s
432     @{MacAddr-list} =    Get Regexp Matches    ${output}    ${MAC_REGEX}
433     @{IpAddr-list} =    Get Regexp Matches    ${output}    ${IP_REGEX}
434     [Return]    ${MacAddr-list}    ${IpAddr-list}
435
436 Verify GWMAC Flow Entry On Flow Table
437     [Arguments]    ${cnIp}
438     [Documentation]    Verify the GWMAC Table, ARP Response table and Dispatcher table.
439     ${flow_output}=    Run Command On Remote System    ${cnIp}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
440     Log    ${flow_output}
441     ${group_output}=    Run Command On Remote System    ${cnIp}    sudo ovs-ofctl -O OpenFlow13 dump-groups br-int
442     Log    ${group_output}
443     #Verify DISPATCHER_TABLE - 17
444     Should Contain    ${flow_output}    table=${DISPATCHER_TABLE}
445     ${dispatcher_table} =    Get Lines Containing String    ${flow_output}    table=${DISPATCHER_TABLE}
446     Log    ${dispatcher_table}
447     Should Contain    ${dispatcher_table}    goto_table:${GWMAC_TABLE}
448     Should Not Contain    ${dispatcher_table}    goto_table:${ARP_RESPONSE_TABLE}
449     #Verify GWMAC_TABLE - 19
450     Should Contain    ${flow_output}    table=${GWMAC_TABLE}
451     ${gwmac_table} =    Get Lines Containing String    ${flow_output}    table=${GWMAC_TABLE}
452     Log    ${gwmac_table}
453     #Verify GWMAC address present in table 19
454     : FOR    ${macAdd}    IN    @{GWMAC_ADDRS}
455     \    Should Contain    ${gwmac_table}    dl_dst=${macAdd} actions=goto_table:${L3_TABLE}
456     #verify Miss entry
457     Should Contain    ${gwmac_table}    actions=resubmit(,17)
458     #arp request and response
459     Should Match Regexp    ${gwmac_table}    ${ARP_RESPONSE_REGEX}
460     ${match} =    Should Match Regexp    ${gwmac_table}    ${ARP_REQUEST_REGEX}
461     ${groupID} =    Split String    ${match}    separator=:
462     Log    groupID
463     Verify ARP REQUEST in groupTable    ${group_output}    ${groupID[1]}
464     #Verify ARP_RESPONSE_TABLE - 81
465     Should Contain    ${flow_output}    table=${ARP_RESPONSE_TABLE}
466     ${arpResponder_table} =    Get Lines Containing String    ${flow_output}    table=${ARP_RESPONSE_TABLE}
467     Log    ${arpResponder_table}
468     Should Contain    ${arpResponder_table}    priority=0 actions=drop
469     : FOR    ${macAdd}    ${ipAdd}    IN ZIP    ${GWMAC_ADDRS}    ${GWIP_ADDRS}
470     \    ${ARP_RESPONSE_IP_MAC_REGEX} =    Set Variable    arp_tpa=${ipAdd},arp_op=1 actions=.*,set_field:${macAdd}->eth_src
471     \    Should Match Regexp    ${arpResponder_table}    ${ARP_RESPONSE_IP_MAC_REGEX}
472
473 Verify ARP REQUEST in groupTable
474     [Arguments]    ${group_output}    ${Group-ID}
475     [Documentation]    get flow dump for group ID
476     Should Contain    ${group_output}    group_id=${Group-ID}
477     ${arp_group} =    Get Lines Containing String    ${group_output}    group_id=${Group-ID}
478     Log    ${arp_group}
479     Should Match Regexp    ${arp_group}    ${ARP_REQUEST_GROUP_REGEX}
480
481 Verify GWMAC Flow Entry Removed From Flow Table
482     [Arguments]    ${cnIp}
483     [Documentation]    Verify the GWMAC Table, ARP Response table and Dispatcher table.
484     ${flow_output}=    Run Command On Remote System    ${cnIp}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
485     Log    ${flow_output}
486     #Verify GWMAC_TABLE - 19
487     Should Contain    ${flow_output}    table=${GWMAC_TABLE}
488     ${gwmac_table} =    Get Lines Containing String    ${flow_output}    table=${GWMAC_TABLE}
489     Log    ${gwmac_table}
490     #Verify GWMAC address present in table 19
491     : FOR    ${macAdd}    IN    @{GWMAC_ADDRS}
492     \    Should Not Contain    ${gwmac_table}    dl_dst=${macAdd} actions=goto_table:${L3_TABLE}