Search for errors/warnings in karaf log for test teardown
[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    Close All Connections
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 Variables         ../../../variables/Variables.py
19
20 *** Variables ***
21 @{NETWORKS}       NET10    NET20
22 @{SUBNETS}        SUBNET1    SUBNET2
23 @{SUBNET_CIDR}    10.1.1.0/24    20.1.1.0/24
24 @{PORT_LIST}      PORT11    PORT21    PORT12    PORT22
25 @{VM_INSTANCES_NET10}    VM11    VM21
26 @{VM_INSTANCES_NET20}    VM12    VM22
27 @{ROUTERS}        ROUTER_1    ROUTER_2
28 @{VPN_INSTANCE_ID}    4ae8cd92-48ca-49b5-94e1-b2921a261111    4ae8cd92-48ca-49b5-94e1-b2921a261112    4ae8cd92-48ca-49b5-94e1-b2921a261113
29 @{VPN_NAME}       vpn1    vpn2    vpn3
30 @{CREATE_RD}      ["2200:2"]    ["2300:2"]    ["2400:2"]
31 @{CREATE_EXPORT_RT}    ["2200:2"]    ["2300:2"]    ["2400:2"]
32 @{CREATE_IMPORT_RT}    ["2200:2"]    ["2300:2"]    ["2400:2"]
33 @{EXTRA_NW_IP}    40.1.1.2    50.1.1.2
34 # Values passed for extra routes
35 ${RT_OPTIONS}     --routes type=dict list=true
36 ${RT_CLEAR}       --routes action=clear
37
38 *** Test Cases ***
39 Create Neutron Networks
40     [Documentation]    Create two networks
41     Create Network    ${NETWORKS[0]}
42     Create Network    ${NETWORKS[1]}
43     ${NET_LIST}    List Networks
44     Log    ${NET_LIST}
45     Should Contain    ${NET_LIST}    ${NETWORKS[0]}
46     Should Contain    ${NET_LIST}    ${NETWORKS[1]}
47
48 Create Neutron Subnets
49     [Documentation]    Create two subnets for previously created networks
50     Create SubNet    ${NETWORKS[0]}    ${SUBNETS[0]}    ${SUBNET_CIDR[0]}
51     Create SubNet    ${NETWORKS[1]}    ${SUBNETS[1]}    ${SUBNET_CIDR[1]}
52     ${SUB_LIST}    List Subnets
53     Log    ${SUB_LIST}
54     Should Contain    ${SUB_LIST}    ${SUBNETS[0]}
55     Should Contain    ${SUB_LIST}    ${SUBNETS[1]}
56
57 Add Ssh Allow Rule
58     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
59     Neutron Security Group Create    sg-vpnservice
60     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
61     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
62     Neutron Security Group Rule Create    sg-vpnservice    direction=ingress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
63     Neutron Security Group Rule Create    sg-vpnservice    direction=egress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
64     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
65     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
66
67 Create Neutron Ports
68     [Documentation]    Create four ports under previously created subnets
69     Create Port    ${NETWORKS[0]}    ${PORT_LIST[0]}    sg=sg-vpnservice
70     Create Port    ${NETWORKS[0]}    ${PORT_LIST[1]}    sg=sg-vpnservice
71     Create Port    ${NETWORKS[1]}    ${PORT_LIST[2]}    sg=sg-vpnservice
72     Create Port    ${NETWORKS[1]}    ${PORT_LIST[3]}    sg=sg-vpnservice
73
74 Check OpenDaylight Neutron Ports
75     [Documentation]    Checking OpenDaylight Neutron API for known ports
76     ${resp}    RequestsLibrary.Get Request    session    ${NEUTRON_PORTS_API}
77     Log    ${resp.content}
78     Should be Equal As Strings    ${resp.status_code}    200
79
80 Create Nova VMs
81     [Documentation]    Create Vm instances on compute node with port
82     Create Vm Instance With Port On Compute Node    ${PORT_LIST[0]}    ${VM_INSTANCES_NET10[0]}    ${OS_COMPUTE_1_IP}    sg=sg-vpnservice
83     Create Vm Instance With Port On Compute Node    ${PORT_LIST[1]}    ${VM_INSTANCES_NET10[1]}    ${OS_COMPUTE_2_IP}    sg=sg-vpnservice
84     Create Vm Instance With Port On Compute Node    ${PORT_LIST[2]}    ${VM_INSTANCES_NET20[0]}    ${OS_COMPUTE_1_IP}    sg=sg-vpnservice
85     Create Vm Instance With Port On Compute Node    ${PORT_LIST[3]}    ${VM_INSTANCES_NET20[1]}    ${OS_COMPUTE_2_IP}    sg=sg-vpnservice
86     Log    Check for routes
87     Wait Until Keyword Succeeds    30s    10s    Wait For Routes To Propogate
88     ${VM_IP_NET10}    ${DHCP_IP1}    Wait Until Keyword Succeeds    30s    10s    Verify VMs Received DHCP Lease    @{VM_INSTANCES_NET10}
89     Log    ${VM_IP_NET10}
90     Set Suite Variable    ${VM_IP_NET10}
91     ${VM_IP_NET20}    ${DHCP_IP2}    Wait Until Keyword Succeeds    30s    10s    Verify VMs Received DHCP Lease    @{VM_INSTANCES_NET20}
92     Log    ${VM_IP_NET20}
93     Set Suite Variable    ${VM_IP_NET20}
94
95 Check ELAN Datapath Traffic Within The Networks
96     [Documentation]    Checks datapath within the same network with different vlans.
97     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ping -c 3 ${VM_IP_NET10[1]}
98     Should Contain    ${output}    64 bytes
99     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET20[0]}    ping -c 3 ${VM_IP_NET20[1]}
100     Should Contain    ${output}    64 bytes
101
102 Create Routers
103     [Documentation]    Create Router
104     Create Router    ${ROUTERS[0]}
105
106 Add Interfaces To Router
107     [Documentation]    Add Interfaces
108     : FOR    ${INTERFACE}    IN    @{SUBNETS}
109     \    Add Router Interface    ${ROUTERS[0]}    ${INTERFACE}
110
111 Check L3_Datapath Traffic Across Networks With Router
112     [Documentation]    Datapath test across the networks using router for L3.
113     ${dst_ip_list} =    Create List    ${VM_IP_NET10[1]}    ${VM_IP_NET20[0]}    ${VM_IP_NET20[1]}
114     Log    ${dst_ip_list}
115     Test Operations From Vm Instance    ${NETWORKS[0]}    ${VM_IP_NET10[1]}    ${dst_ip_list}
116     ${dst_ip_list} =    Create List    ${VM_IP_NET20[1]}    ${VM_IP_NET10[0]}    ${VM_IP_NET10[1]}
117     Log    ${dst_ip_list}
118     Test Operations From Vm Instance    ${NETWORKS[1]}    ${VM_IP_NET20[0]}    ${dst_ip_list}
119
120 Add Multiple Extra Routes And Check Datapath Before L3VPN Creation
121     [Documentation]    Add multiple extra routes and check data path before L3VPN creation
122     Log    "Adding extra one route to VM"
123     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
124     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP1}
125     ${CONFIG_EXTRA_ROUTE_IP2} =    Catenate    sudo ifconfig eth0:2 @{EXTRA_NW_IP}[1] netmask 255.255.255.0 up
126     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP2}
127     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ifconfig
128     ${EXT_RT1} =    Set Variable    destination=40.1.1.0/24,nexthop=${VM_IP_NET10[0]}
129     ${EXT_RT2} =    Set Variable    destination=50.1.1.0/24,nexthop=${VM_IP_NET10[0]}
130     ${cmd} =    Catenate    ${RT_OPTIONS}    ${EXT_RT1}    ${EXT_RT2}
131     Update Router    @{ROUTERS}[0]    ${cmd}
132     Show Router    @{ROUTERS}[0]    -D
133     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping -c 3 @{EXTRA_NW_IP}[1]
134     Should Contain    ${output}    64 bytes
135     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET20[1]}    ping -c 3 @{EXTRA_NW_IP}[1]
136     Should Contain    ${output}    64 bytes
137     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping -c 3 @{EXTRA_NW_IP}[0]
138     Should Contain    ${output}    64 bytes
139
140 Delete Extra Route
141     [Documentation]    Delete the extra routes
142     Update Router    @{ROUTERS}[0]    ${RT_CLEAR}
143     Show Router    @{ROUTERS}[0]    -D
144
145 Delete And Recreate Extra Route
146     [Documentation]    Recreate multiple extra route and check data path before L3VPN creation
147     Log    "Adding extra route to VM"
148     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
149     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP1}
150     ${EXT_RT1} =    Set Variable    destination=40.1.1.0/24,nexthop=${VM_IP_NET10[0]}
151     ${cmd} =    Catenate    ${RT_OPTIONS}    ${EXT_RT1}
152     Update Router    @{ROUTERS}[0]    ${cmd}
153     Show Router    @{ROUTERS}[0]    -D
154     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping -c 3 @{EXTRA_NW_IP}[0]
155     Should Contain    ${output}    64 bytes
156     Update Router    @{ROUTERS}[0]    ${RT_CLEAR}
157     Show Router    @{ROUTERS}[0]    -D
158
159 Delete Router Interfaces
160     [Documentation]    Remove Interface to the subnets.
161     : FOR    ${INTERFACE}    IN    @{SUBNETS}
162     \    Remove Interface    ${ROUTERS[0]}    ${INTERFACE}
163
164 Create L3VPN
165     [Documentation]    Creates L3VPN and verify the same
166     ${devstack_conn_id} =    Get ControlNode Connection
167     Switch Connection    ${devstack_conn_id}
168     ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
169     ${tenant_id} =    Get Tenant ID From Network    ${net_id}
170     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}
171     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
172     Should Contain    ${resp}    ${VPN_INSTANCE_ID[0]}
173
174 Associate L3VPN To Routers
175     [Documentation]    Associating router to L3VPN
176     ${devstack_conn_id}=    Get ControlNode Connection
177     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
178     Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
179     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
180     Should Contain    ${resp}    ${router_id}
181
182 Dissociate L3VPN To Routers
183     [Documentation]    Dissociating router from L3VPN
184     ${devstack_conn_id}=    Get ControlNode Connection
185     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
186     Dissociate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
187     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
188     Should Not Contain    ${resp}    ${router_id}
189
190 Associate L3VPN To Networks
191     [Documentation]    Associates L3VPN to networks and verify
192     ${devstack_conn_id} =    Get ControlNode Connection
193     ${network1_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
194     ${network2_id} =    Get Net Id    ${NETWORKS[1]}    ${devstack_conn_id}
195     Associate L3VPN To Network    networkid=${network1_id}    vpnid=${VPN_INSTANCE_ID[0]}
196     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
197     Should Contain    ${resp}    ${network1_id}
198     Associate L3VPN To Network    networkid=${network2_id}    vpnid=${VPN_INSTANCE_ID[0]}
199     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
200     Should Contain    ${resp}    ${network2_id}
201
202 Dissociate L3VPN From Networks
203     [Documentation]    Dissociate L3VPN from networks
204     ${devstack_conn_id} =    Get ControlNode Connection
205     ${network1_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
206     ${network2_id} =    Get Net Id    ${NETWORKS[1]}    ${devstack_conn_id}
207     Dissociate L3VPN From Networks    networkid=${network1_id}    vpnid=${VPN_INSTANCE_ID[0]}
208     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
209     Should Not Contain    ${resp}    ${network1_id}
210     Dissociate L3VPN From Networks    networkid=${network2_id}    vpnid=${VPN_INSTANCE_ID[0]}
211     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
212     Should Not Contain    ${resp}    ${network2_id}
213
214 Delete Routers
215     [Documentation]    Delete Router and Interface to the subnets.
216     Delete Router    ${ROUTERS[0]}
217
218 Delete L3VPN
219     [Documentation]    Delete L3VPN
220     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
221
222 Create Multiple L3VPN
223     [Documentation]    Creates three L3VPNs and then verify the same
224     ${devstack_conn_id} =    Get ControlNode Connection
225     Switch Connection    ${devstack_conn_id}
226     ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
227     ${tenant_id} =    Get Tenant ID From Network    ${net_id}
228     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}
229     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}
230     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}
231     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
232     Should Contain    ${resp}    ${VPN_INSTANCE_ID[0]}
233     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[1]}
234     Should Contain    ${resp}    ${VPN_INSTANCE_ID[1]}
235     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[2]}
236     Should Contain    ${resp}    ${VPN_INSTANCE_ID[2]}
237
238 Delete Multiple L3VPN
239     [Documentation]    Delete three L3VPNs created using Multiple L3VPN Test
240     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
241     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[1]}
242     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[2]}
243
244 Check Datapath Traffic Across Networks With L3VPN
245     [Documentation]    Datapath Test Across the networks with VPN.
246     [Tags]    exclude
247     Log    This test will be added in the next patch
248
249 Delete Vm Instances
250     [Documentation]    Delete Vm instances in the given Instance List
251     @{VM_INSTANCES}    Collections.Combine Lists    @{VM_INSTANCES_NET10}    @{VM_INSTANCES_NET20}
252     : FOR    ${VmInstance}    IN    @{VM_INSTANCES}
253     \    Delete Vm Instance    ${VmInstance}
254
255 Delete Neutron Ports
256     [Documentation]    Delete Neutron Ports in the given Port List.
257     : FOR    ${Port}    IN    @{PORT_LIST}
258     \    Delete Port    ${Port}
259
260 Delete Sub Networks
261     [Documentation]    Delete Sub Nets in the given Subnet List.
262     : FOR    ${Subnet}    IN    @{SUBNETS}
263     \    Delete SubNet    ${Subnet}
264
265 Delete Networks
266     [Documentation]    Delete Networks in the given Net List
267     : FOR    ${Network}    IN    @{NETWORKS}
268     \    Delete Network    ${Network}
269
270 Create ITM Tunnel
271     [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.
272     ${node_1_dpid} =    Get DPID    ${OS_COMPUTE_1_IP}
273     ${node_2_dpid} =    Get DPID    ${OS_COMPUTE_2_IP}
274     ${node_1_adapter} =    Get Ethernet Adapter    ${OS_COMPUTE_1_IP}
275     ${node_2_adapter} =    Get Ethernet Adapter    ${OS_COMPUTE_2_IP}
276     ${subnet} =    Get Subnet    ${OS_COMPUTE_1_IP}
277     ${gateway} =    Get Default Gateway    ${OS_COMPUTE_1_IP}
278     ITM Create Tunnel    tunneltype=vxlan    vlanid=0    prefix=${subnet}    gateway=${gateway}    ipaddress1=${OS_COMPUTE_1_IP}    dpnid1=${node_1_dpid}
279     ...    portname1=${node_1_adapter}    ipaddress2=${OS_COMPUTE_2_IP}    dpnid2=${node_2_dpid}    portname2=${node_2_adapter}
280     Get DumpFlows And Ovsconfig    ${OS_COMPUTE_1_IP}
281     Get DumpFlows And Ovsconfig    ${OS_COMPUTE_2_IP}
282     ${output} =    ITM Get Tunnels
283     Log    ${output}
284
285 Delete ITM Tunnel
286     [Documentation]    Delete tunnels with specific transport-zone.
287     ITM Delete Tunnel    TZA
288
289 *** Keywords ***
290 Basic Vpnservice Suite Setup
291     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
292
293 Basic Vpnservice Suite Teardown
294     Delete All Sessions
295
296 Wait For Routes To Propogate
297     ${devstack_conn_id} =    Get ControlNode Connection
298     Switch Connection    ${devstack_conn_id}
299     ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
300     ${output} =    Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ip route    ]>
301     Should Contain    ${output}    @{SUBNET_CIDR}[0]
302     ${net_id} =    Get Net Id    @{NETWORKS}[1]    ${devstack_conn_id}
303     ${output} =    Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ip route    ]>
304     Should Contain    ${output}    @{SUBNET_CIDR}[1]