ITM Testcases to Create, Delete and Get Tunnels
[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       Basic Vpnservice Suite Setup
6 Suite Teardown    Basic Vpnservice Suite Teardown
7 Test Setup        Log Testcase Start To Controller Karaf
8 Library           SSHLibrary
9 Library           OperatingSystem
10 Library           RequestsLibrary
11 Resource          ../../../libraries/Utils.robot
12 Resource          ../../../libraries/OpenStackOperations.robot
13 Resource          ../../../libraries/DevstackUtils.robot
14 Resource          ../../../libraries/VpnOperations.robot
15 Resource          ../../../libraries/OVSDB.robot
16 Variables         ../../../variables/Variables.py
17
18 *** Variables ***
19 @{NETWORKS}       NET10    NET20
20 @{SUBNETS}        SUBNET1    SUBNET2
21 @{SUBNET_CIDR}    10.1.1.0/24    20.1.1.0/24
22 @{PORT_LIST}      PORT11    PORT21    PORT12    PORT22
23 @{VM_INSTANCES}    VM11    VM21    VM12    VM22
24 @{ROUTERS}        ROUTER_1    ROUTER_2
25 # Values passed by the calling method to API
26 @{CREATE_ID}      "4ae8cd92-48ca-49b5-94e1-b2921a261111"    "4ae8cd92-48ca-49b5-94e1-b2921a261112"    "4ae8cd92-48ca-49b5-94e1-b2921a261113"
27 @{CREATE_NAME}    "vpn1"    "vpn2"    "vpn3"
28 ${CREATE_ROUTER_DISTINGUISHER}    ["2200:2"]
29 ${CREATE_EXPORT_RT}    ["3300:2","8800:2"]
30 ${CREATE_IMPORT_RT}    ["3300:2","8800:2"]
31 ${CREATE_TENANT_ID}    "6c53df3a-3456-11e5-a151-feff819c1111"
32 @{VPN_INSTANCE}    vpn_instance_template.json
33 @{VPN_INSTANCE_NAME}    4ae8cd92-48ca-49b5-94e1-b2921a2661c7    4ae8cd92-48ca-49b5-94e1-b2921a261111
34
35 *** Test Cases ***
36 Create ITM Tunnel
37     [Documentation]    Checks that vxlan tunnels are created successfully. The proc expects that the two DPNs are in the same network and populates the gateway accordingly.
38     ${node_1_dpid} =    Get DPID    ${OS_COMPUTE_1_IP}
39     ${node_2_dpid} =    Get DPID    ${OS_COMPUTE_2_IP}
40     ${node_1_adapter} =    Get Ethernet Adapter    ${OS_COMPUTE_1_IP}
41     ${node_2_adapter} =    Get Ethernet Adapter    ${OS_COMPUTE_2_IP}
42     ${first_two_octets}    ${third_octet}    ${last_octet}=    Split String From Right    ${OS_COMPUTE_1_IP}    .    2
43     ${subnet} =    Set Variable    ${first_two_octets}.0.0/16
44     ${gateway} =    Get Default Gateway    ${OS_COMPUTE_1_IP}
45     ITM Create Tunnel    tunnel-type=vxlan    vlan-id=0    ip-address1="${OS_COMPUTE_1_IP}"    dpn-id1=${node_1_dpid}    portname1="${node_1_adapter}"    ip-address2="${OS_COMPUTE_2_IP}"
46     ...    dpn-id2=${node_2_dpid}    portname2="${node_2_adapter}"    prefix="${subnet}"    gateway-ip="${gateway}"
47     ${output}=    Run Command On Remote System    ${OS_COMPUTE_1_IP}    sudo ovs-vsctl show
48     Log    ${output}
49     ${output}=    Run Command On Remote System    ${OS_COMPUTE_2_IP}    sudo ovs-vsctl show
50     Log    ${output}
51     ${output} =    ITM Get Tunnels
52     Log    ${output}
53
54 Create Neutron Networks
55     [Documentation]    Create two networks
56     Create Network    ${NETWORKS[0]}    --provider:network_type local
57     Create Network    ${NETWORKS[1]}    --provider:network_type local
58     ${NET_LIST}    List Networks
59     Log    ${NET_LIST}
60     Should Contain    ${NET_LIST}    ${NETWORKS[0]}
61     Should Contain    ${NET_LIST}    ${NETWORKS[1]}
62
63 Create Neutron Subnets
64     [Documentation]    Create two subnets for previously created networks
65     Create SubNet    ${NETWORKS[0]}    ${SUBNETS[0]}    ${SUBNET_CIDR[0]}
66     Create SubNet    ${NETWORKS[1]}    ${SUBNETS[1]}    ${SUBNET_CIDR[1]}
67     ${SUB_LIST}    List Subnets
68     Log    ${SUB_LIST}
69     Should Contain    ${SUB_LIST}    ${SUBNETS[0]}
70     Should Contain    ${SUB_LIST}    ${SUBNETS[1]}
71
72 Create Neutron Ports
73     [Documentation]    Create four ports under previously created subnets
74     Create Port    ${NETWORKS[0]}    ${PORT_LIST[0]}
75     Create Port    ${NETWORKS[0]}    ${PORT_LIST[1]}
76     Create Port    ${NETWORKS[1]}    ${PORT_LIST[2]}
77     Create Port    ${NETWORKS[1]}    ${PORT_LIST[3]}
78
79 Check OpenDaylight Neutron Ports
80     [Documentation]    Checking OpenDaylight Neutron API for known ports
81     ${resp}    RequestsLibrary.Get Request    session    ${NEUTRON_PORTS_API}
82     Log    ${resp.content}
83     Should be Equal As Strings    ${resp.status_code}    200
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[0]}    ${OS_COMPUTE_1_IP}
88     Create Vm Instance With Port On Compute Node    ${PORT_LIST[1]}    ${VM_INSTANCES[1]}    ${OS_COMPUTE_2_IP}
89     Create Vm Instance With Port On Compute Node    ${PORT_LIST[2]}    ${VM_INSTANCES[2]}    ${OS_COMPUTE_1_IP}
90     Create Vm Instance With Port On Compute Node    ${PORT_LIST[3]}    ${VM_INSTANCES[3]}    ${OS_COMPUTE_2_IP}
91
92 Check ELAN Datapath Traffic Within The Networks
93     [Documentation]    Checks datapath within the same network with different vlans.
94     [Tags]    exclude
95     Log    This test will be added in the next patch
96
97 Create Routers
98     [Documentation]    Create Router
99     Create Router    ${ROUTERS[0]}
100
101 Add Interfaces To Router
102     [Documentation]    Add Interfaces
103     : FOR    ${INTERFACE}    IN    @{SUBNETS}
104     \    Add Router Interface    ${ROUTERS[0]}    ${INTERFACE}
105
106 Check L3_Datapath Traffic Across Networks With Router
107     [Documentation]    Datapath Test Across the networks using Router for L3.
108     [Tags]    exclude
109     Log    This test will be added in the next patch
110
111 Create L3VPN
112     [Documentation]    Creates L3VPN and verify the same
113     VPN Create L3VPN    ${VPN_INSTANCE[0]}    CREATE_ID=${CREATE_ID[0]}    CREATE_EXPORT_RT=${CREATE_EXPORT_RT}    CREATE_IMPORT_RT=${CREATE_IMPORT_RT}    CREATE_TENANT_ID=${CREATE_TENANT_ID}
114     VPN Get L3VPN    ${CREATE_ID[0]}
115
116 Associate L3VPN to Routers
117     [Documentation]    Associating router to L3VPN
118     [Tags]    Associate
119     ${devstack_conn_id}=    Get ControlNode Connection
120     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
121     Associate VPN to Router    ${router_id}    ${VPN_INSTANCE_NAME[1]}
122
123 Dissociate L3VPN to Routers
124     [Documentation]    Dissociating router to L3VPN
125     [Tags]    Dissociate
126     ${devstack_conn_id}=    Get ControlNode Connection
127     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
128     Dissociate VPN to Router    ${router_id}    ${VPN_INSTANCE_NAME[1]}
129
130 Delete Router Interfaces
131     [Documentation]    Remove Interface to the subnets.
132     : FOR    ${INTERFACE}    IN    @{SUBNETS}
133     \    Remove Interface    ${ROUTERS[0]}    ${INTERFACE}
134
135 Delete Routers
136     [Documentation]    Delete Router and Interface to the subnets.
137     Delete Router    ${ROUTERS[0]}
138
139 Delete L3VPN
140     [Documentation]    Delete L3VPN
141     VPN Delete L3VPN    ${CREATE_ID[0]}
142
143 Create Multiple L3VPN
144     [Documentation]    Creates three L3VPNs and then verify the same
145     VPN Create L3VPN    ${VPN_INSTANCE[0]}    CREATE_ID=${CREATE_ID[0]}    CREATE_EXPORT_RT=${CREATE_EXPORT_RT}    CREATE_IMPORT_RT=${CREATE_IMPORT_RT}    CREATE_TENANT_ID=${CREATE_TENANT_ID}
146     VPN Create L3VPN    ${VPN_INSTANCE[0]}    CREATE_ID=${CREATE_ID[1]}    CREATE_EXPORT_RT=${CREATE_EXPORT_RT}    CREATE_IMPORT_RT=${CREATE_IMPORT_RT}    CREATE_TENANT_ID=${CREATE_TENANT_ID}
147     VPN Create L3VPN    ${VPN_INSTANCE[0]}    CREATE_ID=${CREATE_ID[2]}    CREATE_EXPORT_RT=${CREATE_EXPORT_RT}    CREATE_IMPORT_RT=${CREATE_IMPORT_RT}    CREATE_TENANT_ID=${CREATE_TENANT_ID}
148     VPN Get L3VPN    ${CREATE_ID[0]}
149     VPN Get L3VPN    ${CREATE_ID[1]}
150     VPN Get L3VPN    ${CREATE_ID[2]}
151
152 Delete Multiple L3VPN
153     [Documentation]    Delete three L3VPNs
154     VPN Delete L3VPN    ${CREATE_ID[0]}
155     VPN Delete L3VPN    ${CREATE_ID[1]}
156     VPN Delete L3VPN    ${CREATE_ID[2]}
157
158 Check Datapath Traffic Across Networks With L3VPN
159     [Documentation]    Datapath Test Across the networks with VPN.
160     [Tags]    exclude
161     Log    This test will be added in the next patch
162
163 Delete Vm Instances
164     [Documentation]    Delete Vm instances in the given Instance List
165     : FOR    ${VmInstance}    IN    @{VM_INSTANCES}
166     \    Delete Vm Instance    ${VmInstance}
167
168 Delete Neutron Ports
169     [Documentation]    Delete Neutron Ports in the given Port List.
170     : FOR    ${Port}    IN    @{PORT_LIST}
171     \    Delete Port    ${Port}
172
173 Delete Sub Networks
174     [Documentation]    Delete Sub Nets in the given Subnet List.
175     : FOR    ${Subnet}    IN    @{SUBNETS}
176     \    Delete SubNet    ${Subnet}
177
178 Delete Networks
179     [Documentation]    Delete Networks in the given Net List
180     : FOR    ${Network}    IN    @{NETWORKS}
181     \    Delete Network    ${Network}
182
183 Delete ITM Tunnel
184     [Documentation]    Delete tunnels with specific transport-zone.
185     ITM Delete Tunnel    TZA
186
187 *** Keywords ***
188 Basic Vpnservice Suite Setup
189     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
190
191 Basic Vpnservice Suite Teardown
192     Delete All Sessions