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