Test cases for L3VPN creation,association and deletion are added 15/46115/8
authorDhevendran Kulandaivel <dhevendran.k@tcs.com>
Fri, 23 Sep 2016 08:58:15 +0000 (14:28 +0530)
committerDhevendran Kulandaivel <dhevendran.k@tcs.com>
Tue, 27 Sep 2016 12:41:35 +0000 (18:11 +0530)
Change-Id: I9ff3a1c6107036aac31c9ca0b3445b9a65a4dc6d
Signed-off-by: Dhevendran Kulandaivel <dhevendran.k@tcs.com>
csit/libraries/OpenStackOperations.robot
csit/libraries/VpnOperations.robot [new file with mode: 0644]
csit/suites/openstack/vpnservice/basic_vpnservice.robot
csit/variables/vpnservice/GETL3vpn.json [new file with mode: 0644]
csit/variables/vpnservice/vpn1_instance_delete.json [new file with mode: 0644]
csit/variables/vpnservice/vpn_instance_template.json [new file with mode: 0644]
csit/variables/vpnservice/vpn_router.json [new file with mode: 0644]

index 21977300d3dc53a76fcae538ccd5a9440d46da58..5a62acfc68dea149715ef5e98a599a0a0d0965c2 100644 (file)
@@ -164,6 +164,17 @@ Get Port Id
     Log    ${port_id}
     [Return]    ${port_id}
 
+Get Router Id
+    [Arguments]    ${router1}    ${devstack_conn_id}
+    [Documentation]    Retrieve the net id for the given network name to create specific vm instance
+    Switch Connection    ${devstack_conn_id}
+    ${output}=    Write Commands Until Prompt    neutron router-list | grep "${router1}" | get_field 1    30s
+    Log    ${output}
+    ${splitted_output}=    Split String    ${output}    ${EMPTY}
+    ${router_id}=    Get from List    ${splitted_output}    0
+    Log    ${router_id}
+    [Return]    ${router_id}
+
 Create Vm Instances
     [Arguments]    ${net_name}    ${vm_instance_names}    ${image}=cirros-0.3.4-x86_64-uec    ${flavor}=m1.nano    ${sg}=default
     [Documentation]    Create X Vm Instance with the net id of the Netowrk.
diff --git a/csit/libraries/VpnOperations.robot b/csit/libraries/VpnOperations.robot
new file mode 100644 (file)
index 0000000..fd8fb8f
--- /dev/null
@@ -0,0 +1,108 @@
+*** Settings ***
+Documentation     Openstack library. This library is useful for tests to create network, subnet, router and vm instances
+Library           SSHLibrary
+Resource          Utils.robot
+Library           Collections
+Library           String
+Variables         ../variables/Variables.py
+
+*** Variables ***
+${REST_CON}       /restconf/config/
+${REST_CON_OP}    /restconf/operations/
+${VPN_INSTANCE_DELETE}    vpn1_instance_delete.json
+${GETL3VPN}       GETL3vpn.json
+${CREATE_RESP_CODE}    200
+${CREATE_ID_DEFAULT}    "4ae8cd92-48ca-49b5-94e1-b2921a2661c7"
+${CREATE_NAME_DEFAULT}    "vpn1"
+${CREATE_ROUTER_DISTINGUISHER_DEFAULT}    ["2200:1"]
+${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
+
+*** Keywords ***
+VPN Create L3VPN
+    [Arguments]    ${vpn_instance}    &{Kwargs}
+    [Documentation]    Create L3VPN .
+    @{KeysList}    Create List    CREATE_ID    CREATE_NAME    CREATE_ROUTER_DISTINGUISHER    CREATE_EXPORT_RT    CREATE_IMPORT_RT
+    ...    CREATE_TENANT_ID
+    ${body} =    OperatingSystem.Get File    ${VPN_CONFIG_DIR}/${vpn_instance}
+    Log    Body:${body}
+    Run Keyword If    ${Kwargs}    Log    ${Kwargs}
+    ${CREATE_ID} =    Run Keyword If    ${Kwargs} != None    Pop From Dictionary    ${Kwargs}    ${KeysList[0]}    default=${CREATE_ID_DEFAULT}
+    ${body} =    Replace String    ${body}    ${CREATE_ID_DEFAULT}    ${CREATE_ID}
+    Log    ID:${CREATE_ID}
+    ${CREATE_NAME} =    Run Keyword If    ${Kwargs} != None    Pop From Dictionary    ${Kwargs}    ${KeysList[1]}    default=${CREATE_NAME_DEFAULT}
+    ${body} =    Replace String    ${body}    ${CREATE_NAME_DEFAULT}    ${CREATE_NAME}
+    Log    NAME:${CREATE_NAME}
+    ${CREATE_ROUTER_DISTINGUISHER} =    Run Keyword If    ${Kwargs} != None    Pop From Dictionary    ${Kwargs}    ${KeysList[2]}    default=${CREATE_ROUTER_DISTINGUISHER_DEFAULT}
+    ${body} =    Replace String    ${body}    ${CREATE_ROUTER_DISTINGUISHER_DEFAULT}    ${CREATE_ROUTER_DISTINGUISHER}
+    Log    ROUTER_DISTIGNSHER:${CREATE_ROUTER_DISTINGUISHER}
+    ${CREATE_EXPORT_RT} =    Run Keyword If    ${Kwargs} != None    Pop From Dictionary    ${Kwargs}    ${KeysList[3]}    default=${CREATE_EXPORT_RT_DEFAULT}
+    ${body} =    Replace String    ${body}    ${CREATE_EXPORT_RT_DEFAULT}    ${CREATE_EXPORT_RT}
+    Log    EXPORT_RT:${CREATE_EXPORT_RT}
+    ${CREATE_IMPORT_RT} =    Run Keyword If    ${Kwargs} != None    Pop From Dictionary    ${Kwargs}    ${KeysList[4]}    default=${CREATE_IMPORT_RT_DEFAULT}
+    ${body} =    Replace String    ${body}    ${CREATE_IMPORT_RT_DEFAULT}    ${CREATE_IMPORT_RT}
+    Log    IMPORT_RT:${CREATE_IMPORT_RT}
+    ${CREATE_TENANT_ID} =    Run Keyword If    ${Kwargs} != None    Pop From Dictionary    ${Kwargs}    ${KeysList[5]}    default=${CREATE_TENANT_ID_DEFAULT}
+    ${body} =    Replace String    ${body}    ${CREATE_TENANT_ID_DEFAULT}    ${CREATE_TENANT_ID}
+    Log    TENANT_ID:${CREATE_TENANT_ID}
+    Set Global Variable    ${GET_ID}    ${CREATE_ID}
+    Log    ${body}
+    ${resp} =    RequestsLibrary.Post Request    session    ${REST_CON_OP}neutronvpn:createL3VPN    data=${body}
+    Log    ${resp.content}
+    Should Be Equal As Strings    ${resp.status_code}    ${CREATE_RESP_CODE}
+    ${body1} =    OperatingSystem.Get File    ${VPN_CONFIG_DIR}/${GETL3VPN}
+    ${body1} =    Replace String    ${body1}    ${CREATE_ID_DEFAULT}    ${CREATE_ID}
+    ${resp} =    RequestsLibrary.Post Request    session    ${REST_CON_OP}neutronvpn:getL3VPN    data=${body1}
+    Log    ${resp}
+    Should Be Equal As Strings    ${resp.status_code}    ${CREATE_RESP_CODE}
+
+VPN Get L3VPN
+    [Arguments]    ${GET_L3VPN_ID}
+    ${body1} =    OperatingSystem.Get File    ${VPN_CONFIG_DIR}/${GETL3VPN}
+    ${body1} =    Replace String    ${body1}    ${CREATE_ID_DEFAULT}    ${GET_L3VPN_ID}
+    ${resp} =    RequestsLibrary.Post Request    session    ${REST_CON_OP}neutronvpn:getL3VPN    data=${body1}
+    Log    ${resp}
+    Log    BODY:${resp.content}
+    Should Be Equal As Strings    ${resp.status_code}    ${CREATE_RESP_CODE}
+    [Return]    ${resp.content}
+
+Associate VPN to Router
+    [Arguments]    ${ROUTER}    ${VPN_INSTANCE_NAME}
+    [Documentation]    Associate VPN to Router
+    ${body} =    OperatingSystem.Get File    ${VPN_CONFIG_DIR}/vpn_router.json
+    ${body} =    Replace String    ${body}    VPN_ID    ${VPN_INSTANCE_NAME}
+    ${body} =    Replace String    ${body}    ROUTER_ID    ${ROUTER}
+    ${resp} =    RequestsLibrary.Post Request    session    ${REST_CON_OP}neutronvpn:associateRouter    data=${body}
+    Log    ${resp.content}
+    Should Be Equal As Strings    ${resp.status_code}    ${CREATE_RESP_CODE}
+    ${body1} =    OperatingSystem.Get File    ${VPN_CONFIG_DIR}/${GETL3VPN}
+    ${body1} =    Replace String    ${body1}    ${CREATE_ID_DEFAULT}    ${GET_ID}
+    ${resp} =    RequestsLibrary.Post Request    session    ${REST_CON_OP}neutronvpn:getL3VPN    data=${body1}
+    Log    ${resp}
+    Should Be Equal As Strings    ${resp.status_code}    ${CREATE_RESP_CODE}
+
+Dissociate VPN to Router
+    [Arguments]    ${ROUTER}    ${VPN_INSTANCE_NAME}
+    [Documentation]    Dissociate VPN to Router
+    ${body} =    OperatingSystem.Get File    ${VPN_CONFIG_DIR}/vpn_router.json
+    ${body} =    Replace String    ${body}    VPN_ID    ${VPN_INSTANCE_NAME}
+    ${body} =    Replace String    ${body}    ROUTER_ID    ${ROUTER}
+    ${resp} =    RequestsLibrary.Post Request    session    ${REST_CON_OP}neutronvpn:dissociateRouter    data=${body}
+    Log    ${resp.content}
+    Should Be Equal As Strings    ${resp.status_code}    ${CREATE_RESP_CODE}
+    ${body1} =    OperatingSystem.Get File    ${VPN_CONFIG_DIR}/${GETL3VPN}
+    ${body1} =    Replace String    ${body1}    ${CREATE_ID_DEFAULT}    ${GET_ID}
+    ${resp} =    RequestsLibrary.Post Request    session    ${REST_CON_OP}neutronvpn:getL3VPN    data=${body1}
+    Log    ${resp}
+    Should Be Equal As Strings    ${resp.status_code}    ${CREATE_RESP_CODE}
+
+VPN Delete L3VPN
+    [Arguments]    ${DEL_L3VPN_ID}
+    ${body1} =    OperatingSystem.Get File    ${VPN_CONFIG_DIR}/${VPN_INSTANCE_DELETE}
+    Log    ${body1}
+    ${body1} =    Replace String    ${body1}    ${CREATE_ID_DEFAULT}    ${DEL_L3VPN_ID}
+    ${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}
index 84cdfcf81e15a98cdc768e602aeb88ff90df21c2..b2a42a3a197932b754e336b0e70af2fecde5aa2c 100644 (file)
@@ -11,6 +11,7 @@ Library           RequestsLibrary
 Resource          ../../../libraries/Utils.robot
 Resource          ../../../libraries/OpenStackOperations.robot
 Resource          ../../../libraries/DevstackUtils.robot
+Resource          ../../../libraries/VpnOperations.robot
 Variables         ../../../variables/Variables.py
 
 *** Variables ***
@@ -20,6 +21,15 @@ Variables         ../../../variables/Variables.py
 @{PORT_LIST}      PORT11    PORT21    PORT12    PORT22
 @{VM_INSTANCES}    VM11    VM21    VM12    VM22
 @{ROUTERS}        ROUTER_1    ROUTER_2
+# Values passed by the calling method to API
+${CREATE_ID}      "4ae8cd92-48ca-49b5-94e1-b2921a261111"
+${CREATE_NAME}    "vpn2"
+${CREATE_ROUTER_DISTINGUISHER}    ["2200:2"]
+${CREATE_EXPORT_RT}    ["3300:2","8800:2"]
+${CREATE_IMPORT_RT}    ["3300:2","8800:2"]
+${CREATE_TENANT_ID}    "6c53df3a-3456-11e5-a151-feff819c1111"
+@{VPN_INSTANCE}    vpn_instance_template.json
+@{VPN_INSTANCE_NAME}    4ae8cd92-48ca-49b5-94e1-b2921a2661c7    4ae8cd92-48ca-49b5-94e1-b2921a261111
 
 *** Test Cases ***
 Verify Tunnel Creation
@@ -32,13 +42,19 @@ Create Neutron Networks
     [Documentation]    Create two networks
     Create Network    ${NETWORKS[0]}    --provider:network_type local
     Create Network    ${NETWORKS[1]}    --provider:network_type local
-    List Networks
+    ${NET_LIST}    List Networks
+    Log    ${NET_LIST}
+    Should Contain    ${NET_LIST}    ${NETWORKS[0]}
+    Should Contain    ${NET_LIST}    ${NETWORKS[1]}
 
 Create Neutron Subnets
     [Documentation]    Create two subnets for previously created networks
     Create SubNet    ${NETWORKS[0]}    ${SUBNETS[0]}    ${SUBNET_CIDR[0]}
     Create SubNet    ${NETWORKS[1]}    ${SUBNETS[1]}    ${SUBNET_CIDR[1]}
-    List Subnets
+    ${SUB_LIST}    List Subnets
+    Log    ${SUB_LIST}
+    Should Contain    ${SUB_LIST}    ${SUBNETS[0]}
+    Should Contain    ${SUB_LIST}    ${SUBNETS[1]}
 
 Create Neutron Ports
     [Documentation]    Create four ports under previously created subnets
@@ -79,6 +95,25 @@ Check L3_Datapath Traffic Across Networks With Router
     [Tags]    exclude
     Log    This test will be added in the next patch
 
+Create L3VPN
+    [Documentation]    Creates L3VPN and verify the same
+    VPN Create L3VPN    ${VPN_INSTANCE[0]}    CREATE_ID=${CREATE_ID}    CREATE_EXPORT_RT=${CREATE_EXPORT_RT}    CREATE_IMPORT_RT=${CREATE_IMPORT_RT}    CREATE_TENANT_ID=${CREATE_TENANT_ID}
+    VPN Get L3VPN    ${CREATE_ID}
+
+Associate L3VPN to Routers
+    [Documentation]    Associating router to L3VPN
+    [Tags]    Associate
+    ${devstack_conn_id}=    Get ControlNode Connection
+    ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
+    Associate VPN to Router    ${router_id}    ${VPN_INSTANCE_NAME[1]}
+
+Dissociate L3VPN to Routers
+    [Documentation]    Dissociating router to L3VPN
+    [Tags]    Dissociate
+    ${devstack_conn_id}=    Get ControlNode Connection
+    ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
+    Dissociate VPN to Router    ${router_id}    ${VPN_INSTANCE_NAME[1]}
+
 Delete Router Interfaces
     [Documentation]    Remove Interface to the subnets.
     : FOR    ${INTERFACE}    IN    @{SUBNETS}
@@ -88,15 +123,9 @@ Delete Routers
     [Documentation]    Delete Router and Interface to the subnets.
     Delete Router    ${ROUTERS[0]}
 
-Create L3VPN
-    [Documentation]    Create L3VPN.
-    [Tags]    exclude
-    Log    This test will be added in the next patch
-
-Associate Networks To L3VPN
-    [Documentation]    Associate Networks To L3VPN.
-    [Tags]    exclude
-    Log    This test will be added in the next patch
+Delete L3VPN
+    [Documentation]    Delete L3VPN
+    VPN Delete L3VPN    ${CREATE_ID}
 
 Check Datapath Traffic Across Networks With L3VPN
     [Documentation]    Datapath Test Across the networks with VPN.
diff --git a/csit/variables/vpnservice/GETL3vpn.json b/csit/variables/vpnservice/GETL3vpn.json
new file mode 100644 (file)
index 0000000..844e045
--- /dev/null
@@ -0,0 +1,5 @@
+{
+   "input":{
+      "id":"4ae8cd92-48ca-49b5-94e1-b2921a2661c7"
+   }
+}
diff --git a/csit/variables/vpnservice/vpn1_instance_delete.json b/csit/variables/vpnservice/vpn1_instance_delete.json
new file mode 100644 (file)
index 0000000..751b0c9
--- /dev/null
@@ -0,0 +1,8 @@
+{
+   "input":{
+      "vpn-id":"VPN_ID",
+      "router-id":[
+         "ROUTER_ID"
+      ]
+   }
+}
diff --git a/csit/variables/vpnservice/vpn_instance_template.json b/csit/variables/vpnservice/vpn_instance_template.json
new file mode 100644 (file)
index 0000000..85a1138
--- /dev/null
@@ -0,0 +1,22 @@
+{
+   "input":{
+      "l3vpn":[
+         {
+            "id":"4ae8cd92-48ca-49b5-94e1-b2921a2661c7",
+            "name":"vpn1",
+            "route-distinguisher":[
+               "2200:1"
+            ],
+            "export-RT":[
+               "3300:1",
+               "8800:1"
+            ],
+            "import-RT":[
+               "3300:1",
+               "8800:1"
+            ],
+            "tenant-id":"6c53df3a-3456-11e5-a151-feff819cdc9f"
+         }
+      ]
+   }
+}
diff --git a/csit/variables/vpnservice/vpn_router.json b/csit/variables/vpnservice/vpn_router.json
new file mode 100644 (file)
index 0000000..751b0c9
--- /dev/null
@@ -0,0 +1,8 @@
+{
+   "input":{
+      "vpn-id":"VPN_ID",
+      "router-id":[
+         "ROUTER_ID"
+      ]
+   }
+}