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