Add tests to clustered reconciliation
[integration/test.git] / csit / suites / netvirt / Netvirt_Vpnservice / 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       BuiltIn.Run Keywords    SetupUtils.Setup_Utils_For_Setup_And_Teardown
6 ...               AND    DevstackUtils.Devstack Suite Setup
7 Suite Teardown    Basic Vpnservice Suite Teardown
8 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
9 Test Teardown     Get Test Teardown Debugs
10 Library           OperatingSystem
11 Library           RequestsLibrary
12 Resource          ../../../libraries/Utils.robot
13 Resource          ../../../libraries/OpenStackOperations.robot
14 Resource          ../../../libraries/DevstackUtils.robot
15 Resource          ../../../libraries/VpnOperations.robot
16 Resource          ../../../libraries/OVSDB.robot
17 Resource          ../../../libraries/SetupUtils.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
46 *** Test Cases ***
47 Create Neutron Networks
48     [Documentation]    Create two networks
49     Create Network    ${NETWORKS[0]}
50     Create Network    ${NETWORKS[1]}
51     ${NET_LIST}    List Networks
52     Log    ${NET_LIST}
53     Should Contain    ${NET_LIST}    ${NETWORKS[0]}
54     Should Contain    ${NET_LIST}    ${NETWORKS[1]}
55     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${CONFIG_API}/neutron:neutron/networks/    ${NETWORKS}
56
57 Create Neutron Subnets
58     [Documentation]    Create two subnets for previously created networks
59     Create SubNet    ${NETWORKS[0]}    ${SUBNETS[0]}    ${SUBNET_CIDR[0]}
60     Create SubNet    ${NETWORKS[1]}    ${SUBNETS[1]}    ${SUBNET_CIDR[1]}
61     ${SUB_LIST}    List Subnets
62     Log    ${SUB_LIST}
63     Should Contain    ${SUB_LIST}    ${SUBNETS[0]}
64     Should Contain    ${SUB_LIST}    ${SUBNETS[1]}
65     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${CONFIG_API}/neutron:neutron/subnets/    ${SUBNETS}
66
67 Add Ssh Allow Rule
68     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
69     Neutron Security Group Create    ${SECURITY_GROUP}
70     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
71     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
72     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=ingress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
73     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=egress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
74     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
75     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
76
77 Create Neutron Ports
78     [Documentation]    Create four ports under previously created subnets
79     ${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]}
80     Create Port    ${NETWORKS[0]}    ${PORT_LIST[0]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
81     Create Port    ${NETWORKS[0]}    ${PORT_LIST[1]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
82     Create Port    ${NETWORKS[1]}    ${PORT_LIST[2]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
83     Create Port    ${NETWORKS[1]}    ${PORT_LIST[3]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
84     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${CONFIG_API}/neutron:neutron/ports/    ${PORT_LIST}
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
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     ${LOOP_COUNT}    Get Length    ${VM_INSTANCES_NET10}
106     : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
107     \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
108     \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    nova console-log @{VM_INSTANCES}[${index}]    30s
109     Log    ${VM_IP_NET10}
110     Set Suite Variable    ${VM_IP_NET10}
111     Log    ${VM_IP_NET20}
112     Set Suite Variable    ${VM_IP_NET20}
113     Should Not Contain    ${VM_IP_NET10}    None
114     Should Not Contain    ${VM_IP_NET20}    None
115     [Teardown]    Run Keywords    Show Debugs    @{VM_INSTANCES_NET10}    @{VM_INSTANCES_NET20}
116     ...    AND    Get Suite Teardown Debugs
117
118 Check ELAN Datapath Traffic Within The Networks
119     [Documentation]    Checks datapath within the same network with different vlans.
120     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ping -c 3 ${VM_IP_NET10[1]}
121     Should Contain    ${output}    64 bytes
122     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET20[0]}    ping -c 3 ${VM_IP_NET20[1]}
123     Should Contain    ${output}    64 bytes
124
125 Create Routers
126     [Documentation]    Create Router
127     Create Router    ${ROUTERS[0]}
128     ${router_output} =    List Router
129     Log    ${router_output}
130     Should Contain    ${router_output}    ${ROUTERS[0]}
131     ${router_list} =    Create List    ${ROUTERS[0]}
132     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${CONFIG_API}/neutron:neutron/routers/    ${router_list}
133
134 Add Interfaces To Router
135     [Documentation]    Add Interfaces
136     ${devstack_conn_id} =    Get ControlNode Connection
137     : FOR    ${INTERFACE}    IN    @{SUBNETS}
138     \    Add Router Interface    ${ROUTERS[0]}    ${INTERFACE}
139     ${interface_output} =    Show Router Interface    ${ROUTERS[0]}
140     : FOR    ${INTERFACE}    IN    @{SUBNETS}
141     \    ${subnet_id} =    Get Subnet Id    ${INTERFACE}    ${devstack_conn_id}
142     \    Should Contain    ${interface_output}    ${subnet_id}
143     ${GWMAC_ADDRS}    ${GWIP_ADDRS} =    Get Gateway MAC And IP Address    ${ROUTERS[0]}
144     Log    ${GWMAC_ADDRS}
145     Set Suite Variable    ${GWMAC_ADDRS}
146     Log    ${GWIP_ADDRS}
147     Set Suite Variable    ${GWIP_ADDRS}
148
149 Check L3_Datapath Traffic Across Networks With Router
150     [Documentation]    Datapath test across the networks using router for L3.
151     Log    Verification of FIB Entries and Flow
152     ${vm_instances} =    Create List    @{VM_IP_NET10}    @{VM_IP_NET20}
153     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${CONFIG_API}/odl-fib:fibEntries/    ${vm_instances}
154     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_1_IP}    ${VM_IP_NET10}
155     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_1_IP}    ${VM_IP_NET20}
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[1]}    ${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
168 Add Multiple Extra Routes And Check Datapath Before L3VPN Creation
169     [Documentation]    Add multiple extra routes and check data path before L3VPN creation
170     Log    "Adding extra one route to VM"
171     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
172     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP1}
173     ${CONFIG_EXTRA_ROUTE_IP2} =    Catenate    sudo ifconfig eth0:2 @{EXTRA_NW_IP}[1] netmask 255.255.255.0 up
174     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP2}
175     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ifconfig
176     ${EXT_RT1} =    Set Variable    destination=40.1.1.0/24,nexthop=${VM_IP_NET10[0]}
177     ${EXT_RT2} =    Set Variable    destination=50.1.1.0/24,nexthop=${VM_IP_NET10[0]}
178     ${cmd} =    Catenate    ${RT_OPTIONS}    ${EXT_RT1}    ${EXT_RT2}
179     Update Router    @{ROUTERS}[0]    ${cmd}
180     Show Router    @{ROUTERS}[0]    -D
181     Log    "Verify FIB table"
182     ${vm_instances} =    Create List    @{EXTRA_NW_SUBNET}
183     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${CONFIG_API}/odl-fib:fibEntries/    ${vm_instances}
184     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping -c 3 @{EXTRA_NW_IP}[1]
185     Should Contain    ${output}    64 bytes
186     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET20[1]}    ping -c 3 @{EXTRA_NW_IP}[1]
187     Should Contain    ${output}    64 bytes
188     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping -c 3 @{EXTRA_NW_IP}[0]
189     Should Contain    ${output}    64 bytes
190
191 Delete Extra Route
192     [Documentation]    Delete the extra routes
193     Update Router    @{ROUTERS}[0]    ${RT_CLEAR}
194     Show Router    @{ROUTERS}[0]    -D
195
196 Delete And Recreate Extra Route
197     [Documentation]    Recreate multiple extra route and check data path before L3VPN creation
198     Log    "Adding extra route to VM"
199     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
200     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP1}
201     ${EXT_RT1} =    Set Variable    destination=40.1.1.0/24,nexthop=${VM_IP_NET10[0]}
202     ${cmd} =    Catenate    ${RT_OPTIONS}    ${EXT_RT1}
203     Update Router    @{ROUTERS}[0]    ${cmd}
204     Show Router    @{ROUTERS}[0]    -D
205     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping -c 3 @{EXTRA_NW_IP}[0]
206     Should Contain    ${output}    64 bytes
207     # clear off extra-routes before the next set of tests
208     [Teardown]    Run Keywords    Update Router    @{ROUTERS}[0]    ${RT_CLEAR}
209     ...    AND    Show Router    @{ROUTERS}[0]    -D
210     ...    AND    Get Test Teardown Debugs
211
212 Create L3VPN
213     [Documentation]    Creates L3VPN and verify the same
214     ${devstack_conn_id} =    Get ControlNode Connection
215     Switch Connection    ${devstack_conn_id}
216     ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
217     ${tenant_id} =    Get Tenant ID From Network    ${net_id}
218     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}
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     ${devstack_conn_id}=    Get ControlNode Connection
225     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
226     Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
227     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
228     Should Contain    ${resp}    ${router_id}
229
230 Verify L3VPN Datapath With Router Association
231     [Documentation]    Datapath test across the networks using L3VPN with router association.
232     Log    Verify VPN interfaces, FIB entries and Flow table
233     ${vm_instances} =    Create List    @{VM_IP_NET10}    @{VM_IP_NET20}
234     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${CONFIG_API}/l3vpn:vpn-interfaces/    ${vm_instances}
235     ${RD} =    Strip String    ${CREATE_RD[0]}    characters="[]
236     Log    ${RD}
237     Wait Until Keyword Succeeds    60s    5s    Check For Elements At URI    ${CONFIG_API}/odl-fib:fibEntries/vrfTables/${RD}/    ${vm_instances}
238     Wait Until Keyword Succeeds    60s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_1_IP}    ${vm_instances}
239     Wait Until Keyword Succeeds    60s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_2_IP}    ${vm_instances}
240     #Verify GWMAC Table
241     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Entry On ODL    ${GWMAC_ADDRS}
242     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_1_IP}
243     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_2_IP}
244     Log    Check datapath from network1 to network2
245     ${dst_ip_list} =    Create List    @{VM_IP_NET10}[1]    @{VM_IP_NET20}
246     Log    ${dst_ip_list}
247     Test Operations From Vm Instance    ${NETWORKS[0]}    @{VM_IP_NET10}[0]    ${dst_ip_list}
248     Log    Check datapath from network2 to network1
249     ${dst_ip_list} =    Create List    @{VM_IP_NET20}[1]    @{VM_IP_NET10}
250     Log    ${dst_ip_list}
251     Test Operations From Vm Instance    ${NETWORKS[1]}    @{VM_IP_NET20}[0]    ${dst_ip_list}
252
253 Dissociate L3VPN From Routers
254     [Documentation]    Dissociating router from L3VPN
255     ${devstack_conn_id}=    Get ControlNode Connection
256     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
257     Dissociate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
258     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
259     Should Not Contain    ${resp}    ${router_id}
260
261 Delete Router And Router Interfaces With L3VPN
262     [Documentation]    Delete Router and Interface to the subnets with L3VPN assciate
263     # Asscoiate router with L3VPN
264     ${devstack_conn_id} =    Get ControlNode Connection
265     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
266     Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
267     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
268     Should Contain    ${resp}    ${router_id}
269     #Delete Interface
270     : FOR    ${INTERFACE}    IN    @{SUBNETS}
271     \    Remove Interface    ${ROUTERS[0]}    ${INTERFACE}
272     ${interface_output} =    Show Router Interface    ${ROUTERS[0]}
273     : FOR    ${INTERFACE}    IN    @{SUBNETS}
274     \    ${subnet_id} =    Get Subnet Id    ${INTERFACE}    ${devstack_conn_id}
275     \    Should Not Contain    ${interface_output}    ${subnet_id}
276     # Delete Router and Interface to the subnets.
277     Delete Router    ${ROUTERS[0]}
278     ${router_output} =    List Router
279     Log    ${router_output}
280     Should Not Contain    ${router_output}    ${ROUTERS[0]}
281     ${router_list} =    Create List    ${ROUTERS[0]}
282     Wait Until Keyword Succeeds    3s    1s    Check For Elements Not At URI    ${CONFIG_API}/neutron:neutron/routers/    ${router_list}
283     # Verify Router Entry removed from L3VPN
284     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
285     Should Not Contain    ${resp}    ${router_id}
286     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry Removed From Flow Table    ${OS_COMPUTE_1_IP}
287     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry Removed From Flow Table    ${OS_COMPUTE_2_IP}
288
289 Delete Router With NonExistentRouter Name
290     [Documentation]    Delete router with nonExistentRouter name
291     ${devstack_conn_id}=    Get ControlNode Connection
292     Switch Connection    ${devstack_conn_id}
293     ${output} =    Write Commands Until Prompt    neutron router-delete nonExistentRouter    30s
294     Close Connection
295     Should Match Regexp    ${output}    Unable to find router with name or id 'nonExistentRouter'|Unable to find router\\(s\\) with id\\(s\\) 'nonExistentRouter'
296
297 Associate L3VPN To Networks
298     [Documentation]    Associates L3VPN to networks and verify
299     ${devstack_conn_id} =    Get ControlNode Connection
300     ${network1_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
301     ${network2_id} =    Get Net Id    ${NETWORKS[1]}    ${devstack_conn_id}
302     Associate L3VPN To Network    networkid=${network1_id}    vpnid=${VPN_INSTANCE_ID[0]}
303     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
304     Should Contain    ${resp}    ${network1_id}
305     Associate L3VPN To Network    networkid=${network2_id}    vpnid=${VPN_INSTANCE_ID[0]}
306     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
307     Should Contain    ${resp}    ${network2_id}
308
309 Dissociate L3VPN From Networks
310     [Documentation]    Dissociate L3VPN from networks
311     ${devstack_conn_id} =    Get ControlNode Connection
312     ${network1_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
313     ${network2_id} =    Get Net Id    ${NETWORKS[1]}    ${devstack_conn_id}
314     Dissociate L3VPN From Networks    networkid=${network1_id}    vpnid=${VPN_INSTANCE_ID[0]}
315     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
316     Should Not Contain    ${resp}    ${network1_id}
317     Dissociate L3VPN From Networks    networkid=${network2_id}    vpnid=${VPN_INSTANCE_ID[0]}
318     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
319     Should Not Contain    ${resp}    ${network2_id}
320
321 Delete L3VPN
322     [Documentation]    Delete L3VPN
323     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
324
325 Create Multiple L3VPN
326     [Documentation]    Creates three L3VPNs and then verify the same
327     ${devstack_conn_id} =    Get ControlNode Connection
328     Switch Connection    ${devstack_conn_id}
329     ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
330     ${tenant_id} =    Get Tenant ID From Network    ${net_id}
331     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}
332     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}
333     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}
334     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
335     Should Contain    ${resp}    ${VPN_INSTANCE_ID[0]}
336     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[1]}
337     Should Contain    ${resp}    ${VPN_INSTANCE_ID[1]}
338     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[2]}
339     Should Contain    ${resp}    ${VPN_INSTANCE_ID[2]}
340
341 Delete Multiple L3VPN
342     [Documentation]    Delete three L3VPNs created using Multiple L3VPN Test
343     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
344     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[1]}
345     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[2]}
346
347 Check Datapath Traffic Across Networks With L3VPN
348     [Documentation]    Datapath Test Across the networks with VPN.
349     [Tags]    exclude
350     Log    This test will be added in the next patch
351
352 Delete Vm Instances
353     [Documentation]    Delete Vm instances in the given Instance List
354     ${VM_INSTANCES} =    Create List    @{VM_INSTANCES_NET10}    @{VM_INSTANCES_NET20}
355     : FOR    ${VmInstance}    IN    @{VM_INSTANCES}
356     \    Delete Vm Instance    ${VmInstance}
357
358 Delete Neutron Ports
359     [Documentation]    Delete Neutron Ports in the given Port List.
360     : FOR    ${Port}    IN    @{PORT_LIST}
361     \    Delete Port    ${Port}
362
363 Delete Sub Networks
364     [Documentation]    Delete Sub Nets in the given Subnet List.
365     : FOR    ${Subnet}    IN    @{SUBNETS}
366     \    Delete SubNet    ${Subnet}
367
368 Delete Networks
369     [Documentation]    Delete Networks in the given Net List
370     : FOR    ${Network}    IN    @{NETWORKS}
371     \    Delete Network    ${Network}
372
373 Create ITM Tunnel
374     [Documentation]    Checks that vxlan tunnels are created successfully. This testcase expects that the two DPNs are in the same network hence populates the gateway accordingly.
375     ${node_1_dpid} =    Get DPID    ${OS_COMPUTE_1_IP}
376     ${node_2_dpid} =    Get DPID    ${OS_COMPUTE_2_IP}
377     ${node_1_adapter} =    Get Ethernet Adapter    ${OS_COMPUTE_1_IP}
378     ${node_2_adapter} =    Get Ethernet Adapter    ${OS_COMPUTE_2_IP}
379     ${subnet} =    Get Subnet    ${OS_COMPUTE_1_IP}
380     ${gateway} =    Get Default Gateway    ${OS_COMPUTE_1_IP}
381     ITM Create Tunnel    tunneltype=vxlan    vlanid=0    prefix=${subnet}    gateway=${gateway}    ipaddress1=${OS_COMPUTE_1_IP}    dpnid1=${node_1_dpid}
382     ...    portname1=${node_1_adapter}    ipaddress2=${OS_COMPUTE_2_IP}    dpnid2=${node_2_dpid}    portname2=${node_2_adapter}
383     Get DumpFlows And Ovsconfig    ${OS_COMPUTE_1_IP}
384     Get DumpFlows And Ovsconfig    ${OS_COMPUTE_2_IP}
385     ${output} =    ITM Get Tunnels
386     Log    ${output}
387
388 Delete ITM Tunnel
389     [Documentation]    Delete tunnels with specific transport-zone.
390     ITM Delete Tunnel    TZA
391
392 *** Keywords ***
393 Basic Vpnservice Suite Setup
394     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
395
396 Basic Vpnservice Suite Teardown
397     Delete SecurityGroup    ${SECURITY_GROUP}
398     Close All Connections
399
400 Wait For Routes To Propogate
401     ${devstack_conn_id} =    Get ControlNode Connection
402     Switch Connection    ${devstack_conn_id}
403     ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
404     ${output} =    Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ip route    ]>
405     Should Contain    ${output}    @{SUBNET_CIDR}[0]
406     ${net_id} =    Get Net Id    @{NETWORKS}[1]    ${devstack_conn_id}
407     ${output} =    Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ip route    ]>
408     Should Contain    ${output}    @{SUBNET_CIDR}[1]
409
410 Verify GWMAC Entry On ODL
411     [Arguments]    ${GWMAC_ADDRS}
412     [Documentation]    get ODL GWMAC table entry
413     ${resp} =    RequestsLibrary.Get Request    session    ${CONFIG_API}/neutronvpn:neutron-vpn-portip-port-data/
414     Log    ${resp.content}
415     Should Be Equal As Strings    ${resp.status_code}    200
416     : FOR    ${macAdd}    IN    @{GWMAC_ADDRS}
417     \    Should Contain    ${resp.content}    ${macAdd}
418
419 Get Gateway MAC And IP Address
420     [Arguments]    ${router_Name}
421     [Documentation]    Get Gateway mac and IP Address
422     ${devstack_conn_id}=    Get ControlNode Connection
423     Switch Connection    ${devstack_conn_id}
424     ${output} =    Write Commands Until Prompt    neutron router-port-list ${router_Name}    30s
425     @{MacAddr-list} =    Get Regexp Matches    ${output}    ${MAC_REGEX}
426     @{IpAddr-list} =    Get Regexp Matches    ${output}    ${IP_REGEX}
427     [Return]    ${MacAddr-list}    ${IpAddr-list}
428
429 Verify GWMAC Flow Entry On Flow Table
430     [Arguments]    ${cnIp}
431     [Documentation]    Verify the GWMAC Table, ARP Response table and Dispatcher table.
432     ${flow_output}=    Run Command On Remote System    ${cnIp}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
433     Log    ${flow_output}
434     ${group_output}=    Run Command On Remote System    ${cnIp}    sudo ovs-ofctl -O OpenFlow13 dump-groups br-int
435     Log    ${group_output}
436     #Verify DISPATCHER_TABLE - 17
437     Should Contain    ${flow_output}    table=${DISPATCHER_TABLE}
438     ${dispatcher_table} =    Get Lines Containing String    ${flow_output}    table=${DISPATCHER_TABLE}
439     Log    ${dispatcher_table}
440     Should Contain    ${dispatcher_table}    goto_table:${GWMAC_TABLE}
441     Should Not Contain    ${dispatcher_table}    goto_table:${ARP_RESPONSE_TABLE}
442     #Verify GWMAC_TABLE - 19
443     Should Contain    ${flow_output}    table=${GWMAC_TABLE}
444     ${gwmac_table} =    Get Lines Containing String    ${flow_output}    table=${GWMAC_TABLE}
445     Log    ${gwmac_table}
446     #Verify GWMAC address present in table 19
447     : FOR    ${macAdd}    IN    @{GWMAC_ADDRS}
448     \    Should Contain    ${gwmac_table}    dl_dst=${macAdd} actions=goto_table:${L3_TABLE}
449     #verify Miss entry
450     Should Contain    ${gwmac_table}    actions=resubmit(,17)
451     #arp request and response
452     Should Match Regexp    ${gwmac_table}    ${ARP_RESPONSE_REGEX}
453     ${match} =    Should Match Regexp    ${gwmac_table}    ${ARP_REQUEST_REGEX}
454     ${groupID} =    Split String    ${match}    separator=:
455     Log    groupID
456     Verify ARP REQUEST in groupTable    ${group_output}    ${groupID[1]}
457     #Verify ARP_RESPONSE_TABLE - 81
458     Should Contain    ${flow_output}    table=${ARP_RESPONSE_TABLE}
459     ${arpResponder_table} =    Get Lines Containing String    ${flow_output}    table=${ARP_RESPONSE_TABLE}
460     Log    ${arpResponder_table}
461     Should Contain    ${arpResponder_table}    priority=0 actions=drop
462     : FOR    ${macAdd}    ${ipAdd}    IN ZIP    ${GWMAC_ADDRS}    ${GWIP_ADDRS}
463     \    ${ARP_RESPONSE_IP_MAC_REGEX} =    Set Variable    arp_tpa=${ipAdd},arp_op=1 actions=.*,set_field:${macAdd}->eth_src
464     \    Should Match Regexp    ${arpResponder_table}    ${ARP_RESPONSE_IP_MAC_REGEX}
465
466 Verify ARP REQUEST in groupTable
467     [Arguments]    ${group_output}    ${Group-ID}
468     [Documentation]    get flow dump for group ID
469     Should Contain    ${group_output}    group_id=${Group-ID}
470     ${arp_group} =    Get Lines Containing String    ${group_output}    group_id=${Group-ID}
471     Log    ${arp_group}
472     Should Match Regexp    ${arp_group}    ${ARP_REQUEST_GROUP_REGEX}
473
474 Verify GWMAC Flow Entry Removed From Flow Table
475     [Arguments]    ${cnIp}
476     [Documentation]    Verify the GWMAC Table, ARP Response table and Dispatcher table.
477     ${flow_output}=    Run Command On Remote System    ${cnIp}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
478     Log    ${flow_output}
479     #Verify GWMAC_TABLE - 19
480     Should Contain    ${flow_output}    table=${GWMAC_TABLE}
481     ${gwmac_table} =    Get Lines Containing String    ${flow_output}    table=${GWMAC_TABLE}
482     Log    ${gwmac_table}
483     #Verify GWMAC address present in table 19
484     : FOR    ${macAdd}    IN    @{GWMAC_ADDRS}
485     \    Should Not Contain    ${gwmac_table}    dl_dst=${macAdd} actions=goto_table:${L3_TABLE}