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