Test cases are added for L3VPN Network Assocition and Dissociation use cases 17/46817/7
authorsmsreddy <madhu.sama@tcs.com>
Wed, 12 Oct 2016 08:47:05 +0000 (14:17 +0530)
committerVratko Polák <vrpolak@cisco.com>
Thu, 20 Oct 2016 14:26:33 +0000 (14:26 +0000)
Change-Id: I7c4651536f3201272475f47ebcc07b6d844f00ed
Signed-off-by: smsreddy <madhu.sama@tcs.com>
csit/libraries/VpnOperations.robot
csit/suites/openstack/vpnservice/basic_vpnservice.robot
csit/variables/Variables.robot
csit/variables/vpnservice/assoc_l3vpn/location.uri [new file with mode: 0644]
csit/variables/vpnservice/assoc_l3vpn/post_data.json [new file with mode: 0644]
csit/variables/vpnservice/dissoc_l3vpn/location.uri [new file with mode: 0644]
csit/variables/vpnservice/dissoc_l3vpn/post_data.json [new file with mode: 0644]
csit/variables/vpnservice/get_l3vpn/location.uri [new file with mode: 0644]
csit/variables/vpnservice/get_l3vpn/post_data.json [new file with mode: 0644]

index 10fee2c8f69a9105d726c04b9eee953adbf46daf..83e930cb122d3e77da4589906ee8f89f231c5946 100644 (file)
@@ -2,14 +2,14 @@
 Documentation     Openstack library. This library is useful for tests to create network, subnet, router and vm instances
 Library           SSHLibrary
 Resource          Utils.robot
+Resource          TemplatedRequests.robot
+Resource          ../variables/Variables.robot
 Library           Collections
 Library           String
 Library           OperatingSystem
 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
@@ -32,11 +32,12 @@ ${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
+${VAR_BASE}       ${CURDIR}/../variables/vpnservice/
 
 *** Keywords ***
 VPN Create L3VPN
     [Arguments]    ${vpn_instance}    &{Kwargs}
-    [Documentation]    Create L3VPN .
+    [Documentation]    Create an L3VPN using the Json using the list of optional arguments received.
     @{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}
@@ -62,67 +63,89 @@ VPN Create L3VPN
     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}
+    ${resp} =    RequestsLibrary.Post Request    session    ${OPERATIONS_API}/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}
+    ${resp} =    RequestsLibrary.Post Request    session    ${OPERATIONS_API}/neutronvpn:getL3VPN    data=${body1}
     Log    ${resp}
     Should Be Equal As Strings    ${resp.status_code}    ${CREATE_RESP_CODE}
 
 VPN Get L3VPN
     [Arguments]    ${GET_L3VPN_ID}
+    [Documentation]    Will return detailed list of the L3VPN_ID received
     ${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}
+    ${resp} =    RequestsLibrary.Post Request    session    ${OPERATIONS_API}/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 L3VPN To Network
+    [Arguments]    &{Kwargs}
+    [Documentation]    Associate the created L3VPN to a network-id received as dictionary argument
+    ${resp} =    TemplatedRequests.Post_As_Json_Templated    folder=${VAR_BASE}/assoc_l3vpn    mapping=${Kwargs}    session=session
+    Log    ${resp}
+    Get L3VPN Association
+
+Dissociate L3VPN From Networks
+    [Arguments]    &{Kwargs}
+    [Documentation]    Disssociate the already associated networks from L3VPN
+    ${resp} =    TemplatedRequests.Post_As_Json_Templated    folder=${VAR_BASE}/dissoc_l3vpn    mapping=${Kwargs}    session=session
+    Log    ${resp}
+    Get L3VPN Association
+
+Get L3VPN Association
+    [Documentation]    Will return detailed list of L3VPN created and associated networks
+    ${resp} =    TemplatedRequests.Post_As_Json_Templated    folder=${VAR_BASE}/get_l3vpn    mapping={"getid":${GET_ID}}    session=session
+    Log    ${resp}
+    [Return]    ${resp}
+
 Associate VPN to Router
     [Arguments]    ${ROUTER}    ${VPN_INSTANCE_NAME}
-    [Documentation]    Associate VPN to Router
+    [Documentation]    Associate the created L3VPN to a router-id received as argument
     ${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}
+    ${resp} =    RequestsLibrary.Post Request    session    ${OPERATIONS_API}/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}
+    ${resp} =    RequestsLibrary.Post Request    session    ${OPERATIONS_API}/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
+    [Documentation]    Dissociate the already associated routers from L3VPN
     ${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}
+    ${resp} =    RequestsLibrary.Post Request    session    ${OPERATIONS_API}/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}
+    ${resp} =    RequestsLibrary.Post Request    session    ${OPERATIONS_API}/neutronvpn:getL3VPN    data=${body1}
     Log    ${resp}
     Should Be Equal As Strings    ${resp.status_code}    ${CREATE_RESP_CODE}
 
 VPN Delete L3VPN
     [Arguments]    ${DEL_L3VPN_ID}
+    [Documentation]    Delete the created L3VPN
     ${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}
+    ${resp} =    RequestsLibrary.Post Request    session    ${OPERATIONS_API}/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
+    [Documentation]    Creates Tunnel between the two DPNs received in the dictionary argument
     @{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}
@@ -152,14 +175,14 @@ ITM Create Tunnel
     ${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}
+    ${resp} =    RequestsLibrary.Post Request    session    ${CONFIG_API}/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/
+    ${resp} =    RequestsLibrary.Get Request    session    ${CONFIG_API}/itm:transport-zones/
     Log    ${resp.content}
     Should Be Equal As Strings    ${resp.status_code}    200
     [Return]    ${resp.content}
@@ -167,7 +190,7 @@ ITM Get Tunnels
 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}/
+    ${resp} =    RequestsLibrary.Delete Request    session    ${CONFIG_API}/itm:transport-zones/transport-zone/${zone-name}/
     Log    ${resp.content}
     Should Be Equal As Strings    ${resp.status_code}    200
     [Return]    ${resp.content}
index 32c93bb4dec8bc8665003bd1b785f52db31d01e4..268f5a8f845e0c8860ce68ed8a5cc55049744148 100644 (file)
@@ -53,8 +53,8 @@ Create ITM Tunnel
 
 Create Neutron Networks
     [Documentation]    Create two networks
-    Create Network    ${NETWORKS[0]}    --provider:network_type local
-    Create Network    ${NETWORKS[1]}    --provider:network_type local
+    Create Network    ${NETWORKS[0]}
+    Create Network    ${NETWORKS[1]}
     ${NET_LIST}    List Networks
     Log    ${NET_LIST}
     Should Contain    ${NET_LIST}    ${NETWORKS[0]}
@@ -108,6 +108,11 @@ Check L3_Datapath Traffic Across Networks With Router
     [Tags]    exclude
     Log    This test will be added in the next patch
 
+Delete Router Interfaces
+    [Documentation]    Remove Interface to the subnets.
+    : FOR    ${INTERFACE}    IN    @{SUBNETS}
+    \    Remove Interface    ${ROUTERS[0]}    ${INTERFACE}
+
 Create L3VPN
     [Documentation]    Creates L3VPN and verify the same
     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}
@@ -127,19 +132,30 @@ Dissociate L3VPN to Routers
     ${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}
-    \    Remove Interface    ${ROUTERS[0]}    ${INTERFACE}
-
-Delete Routers
-    [Documentation]    Delete Router and Interface to the subnets.
-    Delete Router    ${ROUTERS[0]}
+Associate L3VPN To Networks
+    [Documentation]    Associates L3VPN to networks and verify
+    ${devstack_conn_id} =    Get ControlNode Connection
+    ${network1_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
+    ${network2_id} =    Get Net Id    ${NETWORKS[1]}    ${devstack_conn_id}
+    Associate L3VPN To Network    networkid=${network1_id}    vpnid=${VPN_INSTANCE_NAME[1]}
+    Associate L3VPN To Network    networkid=${network2_id}    vpnid=${VPN_INSTANCE_NAME[1]}
+
+Dissociate L3VPN From Networks
+    [Documentation]    Dissociate L3VPN from networks
+    ${devstack_conn_id} =    Get ControlNode Connection
+    ${network1_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
+    ${network2_id} =    Get Net Id    ${NETWORKS[1]}    ${devstack_conn_id}
+    Dissociate L3VPN From Networks    networkid=${network1_id}    vpnid=${VPN_INSTANCE_NAME[1]}
+    Dissociate L3VPN From Networks    networkid=${network2_id}    vpnid=${VPN_INSTANCE_NAME[1]}
 
 Delete L3VPN
     [Documentation]    Delete L3VPN
     VPN Delete L3VPN    ${CREATE_ID[0]}
 
+Delete Routers
+    [Documentation]    Delete Router and Interface to the subnets.
+    Delete Router    ${ROUTERS[0]}
+
 Create Multiple L3VPN
     [Documentation]    Creates three L3VPNs and then verify the same
     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}
index 3b41dcc9cca2b5cdb98127f32ea78e47991fac79..f90d423766948ad3f418b4f8c12f1379272ccd3a 100644 (file)
@@ -117,9 +117,10 @@ ${ODL_SYSTEM_USER}    ${DEFAULT_USER}    # Linux username specific for ODL syste
 ${ODL_SYSTEM_PASSWORD}    ${DEFAULT_PASSWORD}    # Linux password (or empty to use public key) specific for ODL systems.
 ${ODL_SYSTEM_PROMPT}    ${DEFAULT_PROMPT}    # Bash prompt substring specific for ODL systems.
 ${OPERATIONAL_API}    /restconf/operational    # FIXME: Move to a separate Resource and add description.
+${OPERATIONS_API}    /restconf/operations    # FIXME: Move to a separate Resource and add description.
 ${OPERATIONAL_GBP_TENANTS_API}    /restconf/operational/policy:tenants    # FIXME: Move to a separate GroupBasedPolicy-related Resource and add description.
 ${OPERATIONAL_NODES_API}    /restconf/operational/opendaylight-inventory:nodes    # FIXME: Move to a separate Resource and add description.
-${OPERATIONAL_NODES_NETVIRT} /restconf/operational/network-topology:network-topology/topology/netvirt:1    \    # FIXME: Move to a separate Resource and add description.
+${OPERATIONAL_NODES_NETVIRT}    /restconf/operational/network-topology:network-topology/topology/netvirt:1    \    # FIXME: Move to a separate Resource and add description.
 ${OPERATIONAL_TOPO_API}    /restconf/operational/network-topology:network-topology    # FIXME: Move to a separate Resource and add description.
 ${OS_SYSTEM_PROMPT}    \$    # Prompt substring specific to OpenStack systems.
 ${OSREST}         /v2.0/networks    # FIXME: Move to a separate Neutron-related Resource and add description.
diff --git a/csit/variables/vpnservice/assoc_l3vpn/location.uri b/csit/variables/vpnservice/assoc_l3vpn/location.uri
new file mode 100644 (file)
index 0000000..5cb7a4a
--- /dev/null
@@ -0,0 +1 @@
+/restconf/operations/neutronvpn:associateNetworks
diff --git a/csit/variables/vpnservice/assoc_l3vpn/post_data.json b/csit/variables/vpnservice/assoc_l3vpn/post_data.json
new file mode 100644 (file)
index 0000000..b5c6e66
--- /dev/null
@@ -0,0 +1,8 @@
+{
+   "input":{
+      "vpn-id":"$vpnid",
+      "network-id":[
+         "$networkid"
+      ]
+   }
+}
diff --git a/csit/variables/vpnservice/dissoc_l3vpn/location.uri b/csit/variables/vpnservice/dissoc_l3vpn/location.uri
new file mode 100644 (file)
index 0000000..887ab40
--- /dev/null
@@ -0,0 +1 @@
+/restconf/operations/neutronvpn:dissociateNetworks
diff --git a/csit/variables/vpnservice/dissoc_l3vpn/post_data.json b/csit/variables/vpnservice/dissoc_l3vpn/post_data.json
new file mode 100644 (file)
index 0000000..b5c6e66
--- /dev/null
@@ -0,0 +1,8 @@
+{
+   "input":{
+      "vpn-id":"$vpnid",
+      "network-id":[
+         "$networkid"
+      ]
+   }
+}
diff --git a/csit/variables/vpnservice/get_l3vpn/location.uri b/csit/variables/vpnservice/get_l3vpn/location.uri
new file mode 100644 (file)
index 0000000..7280ef2
--- /dev/null
@@ -0,0 +1 @@
+/restconf/operations/neutronvpn:getL3VPN
diff --git a/csit/variables/vpnservice/get_l3vpn/post_data.json b/csit/variables/vpnservice/get_l3vpn/post_data.json
new file mode 100644 (file)
index 0000000..bba4ef3
--- /dev/null
@@ -0,0 +1,5 @@
+{
+   "input":{
+      "id":"$getid"
+   }
+}