From 2a527f06cecf308d33a425c3f85bfa2d4089f9cd Mon Sep 17 00:00:00 2001 From: Abbas Pareedkunju Date: Tue, 4 Oct 2016 16:52:16 +0530 Subject: [PATCH] ITM Testcases to Create, Delete and Get Tunnels Change-Id: I42852903471c3d9c43aba1c435bae549a3901d85 Signed-off-by: Abbas Pareedkunju --- csit/libraries/OVSDB.robot | 22 +++++++ csit/libraries/VpnOperations.robot | 65 +++++++++++++++++++ .../vpnservice/basic_vpnservice.robot | 27 ++++++-- .../vpnservice/itm_tunnel_create.json | 27 ++++++++ 4 files changed, 136 insertions(+), 5 deletions(-) create mode 100644 csit/variables/vpnservice/itm_tunnel_create.json diff --git a/csit/libraries/OVSDB.robot b/csit/libraries/OVSDB.robot index 32a3d2360f..016997e732 100644 --- a/csit/libraries/OVSDB.robot +++ b/csit/libraries/OVSDB.robot @@ -144,3 +144,25 @@ Add Multiple Managers to OVS ${session}= ClusterManagement.Resolve_Http_Session_For_Member member_index=${controller_index} ${ovsdb_uuid}= Wait Until Keyword Succeeds 30s 2s Get OVSDB UUID controller_http_session=${session} [Return] ${ovsdb_uuid} + +Get DPID + [Arguments] ${ip} + [Documentation] Returns the dpnid from the system at the given ip address using ovs-ofctl assuming br-int is present. + ${output} = Run Command On Remote System ${ip} sudo ovs-ofctl show -O Openflow13 br-int | head -1 | awk -F "dpid:" '{print $2}' + ${dpnid} = Convert To Integer ${output} 16 + Log ${dpnid} + [Return] ${dpnid} + +Get Ethernet Adapter + [Arguments] ${ip} + [Documentation] Returns the ethernet adapter name from the system at the given ip address using ip addr show. + ${adapter} = Run Command On Remote System ${ip} /usr/sbin/ip addr show | grep ${ip} | cut -d " " -f 11 + Log ${adapter} + [Return] ${adapter} + +Get Default Gateway + [Arguments] ${ip} + [Documentation] Returns the default gateway at the given ip address using route command. + ${gateway} = Run Command On Remote System ${ip} /usr/sbin/route -n | grep '^0.0.0.0' | cut -d " " -f 10 + Log ${gateway} + [Return] ${gateway} diff --git a/csit/libraries/VpnOperations.robot b/csit/libraries/VpnOperations.robot index fd8fb8f1e9..10fee2c8f6 100644 --- a/csit/libraries/VpnOperations.robot +++ b/csit/libraries/VpnOperations.robot @@ -4,6 +4,7 @@ Library SSHLibrary Resource Utils.robot Library Collections Library String +Library OperatingSystem Variables ../variables/Variables.py *** Variables *** @@ -19,6 +20,18 @@ ${CREATE_EXPORT_RT_DEFAULT} ["3300:1","8800:1"] ${CREATE_IMPORT_RT_DEFAULT} ["3300:1","8800:1"] ${CREATE_TENANT_ID_DEFAULT} "6c53df3a-3456-11e5-a151-feff819cdc9f" ${VPN_CONFIG_DIR} ${CURDIR}/../variables/vpnservice +${ITM_CREATE_JSON} itm_tunnel_create.json +${itm_prefix_def} "1.1.1.1/24" +${itm_vlan-id_def} 0 +${itm_dpn-id1_def} 1 +${itm_portname1_def} "BR1-eth1" +${itm_ip-address1_def} "2.2.2.2" +${itm_dpn-id2_def} 2 +${itm_portname2_def} "BR2-eth1" +${itm_ip-address2_def} "3.3.3.3" +${itm_gateway-ip_def} "0.0.0.0" +${itm_tunnel-type_def} vxlan +${itm_zone-name_def} TZA *** Keywords *** VPN Create L3VPN @@ -106,3 +119,55 @@ VPN Delete L3VPN ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:deleteL3VPN ${body1} Log ${resp.content} Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE} + +ITM Create Tunnel + [Arguments] &{Kwargs} + [Documentation] Creates Tunnel between the two DPNs + @{KeysList} Create List prefix vlan-id dpn-id1 portname1 ip-address1 + ... dpn-id2 portname2 ip-address2 gateway-ip tunnel-type zone-name + Log Arguments Received:${Kwargs} + ${json_body} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${ITM_CREATE_JSON} + Run Keyword If ${Kwargs} Log ${Kwargs} + Log json_body:${json_body} + ${prefix} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[0]} default=${itm_prefix_def} + ${json_body} = Replace String ${json_body} prefix\"\:${itm_prefix_def} prefix\"\:${prefix} + ${vlan-id} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[1]} default=${itm_vlan-id_def} + ${json_body} = Replace String ${json_body} vlan-id\"\:${itm_vlan-id_def} vlan-id\"\:${vlan-id} + ${dpn-id1} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[2]} default=${itm_dpn-id1_def} + ${json_body} = Replace String ${json_body} dpn-id\"\:${itm_dpn-id1_def}, dpn-id\"\:${dpn-id1}, + ${portname1} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[3]} default=${itm_portname1_def} + ${json_body} = Replace String ${json_body} portname\"\:${itm_portname1_def} portname\"\:${portname1} + ${ip-address1} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[4]} default=${itm_ip-address1_def} + ${json_body} = Replace String ${json_body} ip-address\"\:${itm_ip-address1_def} ip-address\"\:${ip-address1} + ${dpn-id2} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[5]} default=${itm_dpn-id2_def} + ${json_body} = Replace String ${json_body} dpn-id\"\:${itm_dpn-id2_def}, dpn-id\"\:${dpn-id2}, + ${portname2} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[6]} default=${itm_portname2_def} + ${json_body} = Replace String ${json_body} portname\"\:${itm_portname2_def} portname\"\:${portname2} + ${ip-address2} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[7]} default=${itm_ip-address2_def} + ${json_body} = Replace String ${json_body} ip-address\"\:${itm_ip-address2_def} ip-address\"\:${ip-address2} + ${gateway-ip} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[8]} default=${itm_gateway-ip_def} + ${json_body} = Replace String ${json_body} gateway-ip\"\:${itm_gateway-ip_def} gateway-ip\"\:${gateway-ip} + ${tunnel-type} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[9]} default=${itm_tunnel-type_def} + ${json_body} = Replace String ${json_body} \:tunnel-type-${itm_tunnel-type_def} \:tunnel-type-${tunnel-type} + ${zone-name} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[10]} default=${itm_zone-name_def} + ${json_body} = Replace String ${json_body} \"zone-name\":\"${itm_zone-name_def} \"zone-name\":\"${zone-name} + Log ${json_body} + ${resp} = RequestsLibrary.Post Request session ${REST_CON}/itm:transport-zones/ data=${json_body} + Log ${resp.content} + Log ${resp.status_code} + Should Be Equal As Strings ${resp.status_code} 204 + +ITM Get Tunnels + [Documentation] Get all Tunnels and return the contents + ${resp} = RequestsLibrary.Get Request session ${REST_CON}itm:transport-zones/ + Log ${resp.content} + Should Be Equal As Strings ${resp.status_code} 200 + [Return] ${resp.content} + +ITM Delete Tunnel + [Arguments] ${zone-name} + [Documentation] Delete Tunnels created under the transport-zone + ${resp} = RequestsLibrary.Delete Request session ${REST_CON}/itm:transport-zones/transport-zone/${zone-name}/ + Log ${resp.content} + Should Be Equal As Strings ${resp.status_code} 200 + [Return] ${resp.content} diff --git a/csit/suites/openstack/vpnservice/basic_vpnservice.robot b/csit/suites/openstack/vpnservice/basic_vpnservice.robot index a5756e96f6..32c93bb4de 100644 --- a/csit/suites/openstack/vpnservice/basic_vpnservice.robot +++ b/csit/suites/openstack/vpnservice/basic_vpnservice.robot @@ -12,6 +12,7 @@ Resource ../../../libraries/Utils.robot Resource ../../../libraries/OpenStackOperations.robot Resource ../../../libraries/DevstackUtils.robot Resource ../../../libraries/VpnOperations.robot +Resource ../../../libraries/OVSDB.robot Variables ../../../variables/Variables.py *** Variables *** @@ -32,11 +33,23 @@ ${CREATE_TENANT_ID} "6c53df3a-3456-11e5-a151-feff819c1111" @{VPN_INSTANCE_NAME} 4ae8cd92-48ca-49b5-94e1-b2921a2661c7 4ae8cd92-48ca-49b5-94e1-b2921a261111 *** Test Cases *** -Verify Tunnel Creation - [Documentation] Checks that vxlan tunnels have been created properly. - [Tags] exclude - Log This test case is currently a noop, but work can be added here to validate if needed. However, as the suite Documentation notes, it's already assumed that the environment has been configured properly. If we do add work in this test case, we need to remove the "exclude" tag for it to run. In fact, if this - ... test case is critical to run, and if it fails we would be dead in the water for the rest of the suite, we should move it to Suite Setup so that nothing else will run and waste time in a broken environment. +Create ITM Tunnel + [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. + ${node_1_dpid} = Get DPID ${OS_COMPUTE_1_IP} + ${node_2_dpid} = Get DPID ${OS_COMPUTE_2_IP} + ${node_1_adapter} = Get Ethernet Adapter ${OS_COMPUTE_1_IP} + ${node_2_adapter} = Get Ethernet Adapter ${OS_COMPUTE_2_IP} + ${first_two_octets} ${third_octet} ${last_octet}= Split String From Right ${OS_COMPUTE_1_IP} . 2 + ${subnet} = Set Variable ${first_two_octets}.0.0/16 + ${gateway} = Get Default Gateway ${OS_COMPUTE_1_IP} + 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}" + ... dpn-id2=${node_2_dpid} portname2="${node_2_adapter}" prefix="${subnet}" gateway-ip="${gateway}" + ${output}= Run Command On Remote System ${OS_COMPUTE_1_IP} sudo ovs-vsctl show + Log ${output} + ${output}= Run Command On Remote System ${OS_COMPUTE_2_IP} sudo ovs-vsctl show + Log ${output} + ${output} = ITM Get Tunnels + Log ${output} Create Neutron Networks [Documentation] Create two networks @@ -167,6 +180,10 @@ Delete Networks : FOR ${Network} IN @{NETWORKS} \ Delete Network ${Network} +Delete ITM Tunnel + [Documentation] Delete tunnels with specific transport-zone. + ITM Delete Tunnel TZA + *** Keywords *** Basic Vpnservice Suite Setup Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS} diff --git a/csit/variables/vpnservice/itm_tunnel_create.json b/csit/variables/vpnservice/itm_tunnel_create.json new file mode 100644 index 0000000000..6c806b5317 --- /dev/null +++ b/csit/variables/vpnservice/itm_tunnel_create.json @@ -0,0 +1,27 @@ +{ + "transport-zone":[ + { + "zone-name":"TZA", + "subnets":[ + { + "prefix":"1.1.1.1/24", + "vlan-id":0, + "vteps":[ + { + "dpn-id":1, + "portname":"BR1-eth1", + "ip-address":"2.2.2.2" + }, + { + "dpn-id":2, + "portname":"BR2-eth1", + "ip-address":"3.3.3.3" + } + ], + "gateway-ip":"0.0.0.0" + } + ], + "tunnel-type":"odl-interface:tunnel-type-vxlan" + } + ] +} -- 2.36.6