diff options
author | Keong Lim <keong.lim@huawei.com> | 2019-03-19 15:44:35 +1100 |
---|---|---|
committer | Keong Lim <keong.lim@huawei.com> | 2019-03-19 15:46:49 +1100 |
commit | eff1eab948cd5624477e56c65db01104f87e7c96 (patch) | |
tree | 6c4b3a809e6e19d65f08a0a3a3c25b4b947ad4c1 | |
parent | 2c0558d9c185638a071666e459bab50dd010f0ed (diff) |
AAI-2208 Robot tests for CCVPN and relationships
Add relationship to relationship-list
Add vpn-binding keywords
Update connectivity keywords
Update test cases to relate connectivity to vpn-binding and vice-versa
Change-Id: Id23f4603f0df47e737adf481d8b6308a64936ba0
Issue-ID: AAI-2208
Signed-off-by: Keong Lim <keong.lim@huawei.com>
-rw-r--r-- | robot/assets/templates/aai/add-relationship.template | 4 | ||||
-rw-r--r-- | robot/assets/templates/aai/add-vpn-binding.template | 18 | ||||
-rw-r--r-- | robot/resources/aai/add-relationship-list.robot | 43 | ||||
-rw-r--r-- | robot/resources/aai/ccvpn-connectivities.robot | 25 | ||||
-rw-r--r-- | robot/resources/aai/ccvpn-vpn-bindings.robot | 108 | ||||
-rw-r--r-- | robot/testsuites/aai/aai-regression-test-v14.robot | 57 |
6 files changed, 252 insertions, 3 deletions
diff --git a/robot/assets/templates/aai/add-relationship.template b/robot/assets/templates/aai/add-relationship.template new file mode 100644 index 00000000..e8550aaf --- /dev/null +++ b/robot/assets/templates/aai/add-relationship.template @@ -0,0 +1,4 @@ +{ + "related-to": "${related_class_name}", + "related-link": "${related_object_url}" +} diff --git a/robot/assets/templates/aai/add-vpn-binding.template b/robot/assets/templates/aai/add-vpn-binding.template new file mode 100644 index 00000000..8c6743fe --- /dev/null +++ b/robot/assets/templates/aai/add-vpn-binding.template @@ -0,0 +1,18 @@ +{ + "vpn-id": "${vpn_id}", + "vpn-name": "", + "vpn-platform": "", + "vpn-type": "", + "vpn-region": "", + "customer-vpn-id": "", + "route-distinguisher": "", + "access-provider-id": "", + "access-client-id": "", + "access-topology-id": "", + "src-access-node-id": "", + "src-access-ltp-id": "", + "dst-access-node-id": "", + "dst-access-ltp-id": "", + "operational-status": "", + "resource-version": "" +}
\ No newline at end of file diff --git a/robot/resources/aai/add-relationship-list.robot b/robot/resources/aai/add-relationship-list.robot new file mode 100644 index 00000000..056b896f --- /dev/null +++ b/robot/resources/aai/add-relationship-list.robot @@ -0,0 +1,43 @@ +*** Settings *** +Documentation Operations on relationship-list sub-object in AAI, +... using specified base URL path including API version where it is implemented, +... relies on system to choose default EdgeRule for the pair of object classes + +Resource ../json_templater.robot +Resource aai_interface.robot +Resource api_version_properties.robot +Library OperatingSystem +Library Collections + + +*** Variables *** +${AAI_RELATIONSHIPLIST_PATH}= relationship-list +${AAI_RELATIONSHIP_PATH}= ${AAI_RELATIONSHIPLIST_PATH}/relationship +${AAI_ADD_RELATIONSHIP_BODY}= robot/assets/templates/aai/add-relationship.template +${AAI_RELATIONSHIP_DEPTH}= ?depth=1 + +*** Keywords *** +Add Relationship + [Documentation] Adds Relationship sub-object to existing object in AAI + [Arguments] ${api_version_base_object_url} ${related_class_name} ${related_object_url} + ${arguments}= Create Dictionary related_class_name=${related_class_name} related_object_url=${related_object_url} + ${data}= Fill JSON Template File ${AAI_ADD_RELATIONSHIP_BODY} ${arguments} + ${put_resp}= Run A&AI Put Request ${api_version_base_object_url}/${AAI_RELATIONSHIP_PATH} ${data} + ${status_string}= Convert To String ${put_resp.status_code} + Should Match Regexp ${status_string} ^(201|200)$ + +Get RelationshipList + [Documentation] Return RelationshipList of the object in AAI + [Arguments] ${api_version_base_object_url} + ${resp}= Get Object With Depth ${api_version_base_object_url} + Log Returning response ${resp['${AAI_RELATIONSHIPLIST_PATH}']} + [Return] ${resp['${AAI_RELATIONSHIPLIST_PATH}']} + +Get Object With Depth + [Documentation] Return Object with Depth parameter to show RelationshipList + [Arguments] ${api_version_base_object_url} + ${resp}= Run A&AI Get Request ${api_version_base_object_url}${AAI_RELATIONSHIP_DEPTH} + Should Be Equal As Strings ${resp.status_code} 200 + Log Returning response ${resp.json()} + [Return] ${resp.json()} + diff --git a/robot/resources/aai/ccvpn-connectivities.robot b/robot/resources/aai/ccvpn-connectivities.robot index e4d7bd51..3f4dc0b2 100644 --- a/robot/resources/aai/ccvpn-connectivities.robot +++ b/robot/resources/aai/ccvpn-connectivities.robot @@ -4,6 +4,7 @@ Documentation Operations on connectivities in AAI for CCVPN use case, using Resource ../json_templater.robot Resource aai_interface.robot Resource api_version_properties.robot +Resource add-relationship-list.robot Library OperatingSystem Library Collections @@ -53,6 +54,13 @@ Get Connectivity Should Be Equal As Strings ${resp.status_code} 200 [Return] ${resp.json()} +Get Valid Connectivity URL + [Documentation] Return Valid Connectivity URL + [Arguments] ${connectivity_id} + ${resp}= Run A&AI Get Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id} + Should Be Equal As Strings ${resp.status_code} 200 + [Return] ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id} + Get Nodes Query Connectivity [Documentation] Return Nodes query Connectivity [Arguments] ${connectivity_id} @@ -78,3 +86,20 @@ Confirm API Not Implemented Connectivity ${resp}= Run A&AI Get Request ${AAI_CONN_API_NA_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id} Should Be Equal As Strings ${resp.status_code} 400 +Add Connectivity Relationship + [Documentation] Adds Relationship to existing Connectivity in AAI + [Arguments] ${connectivity_id} ${related_class_name} ${related_object_url} + ${put_resp}= Add Relationship ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id} ${related_class_name} ${related_object_url} + +Get Connectivity RelationshipList + [Documentation] Return relationship-list from Connectivity + [Arguments] ${connectivity_id} + ${resp}= Get RelationshipList ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id} + [Return] ${resp} + +Get Connectivity With RelationshipList + [Documentation] Return Connectivity with relationship-list + [Arguments] ${connectivity_id} + ${resp}= Get Object With Depth ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id} + [Return] ${resp} + diff --git a/robot/resources/aai/ccvpn-vpn-bindings.robot b/robot/resources/aai/ccvpn-vpn-bindings.robot new file mode 100644 index 00000000..c139f7cc --- /dev/null +++ b/robot/resources/aai/ccvpn-vpn-bindings.robot @@ -0,0 +1,108 @@ +*** Settings *** +Documentation Operations on vpn-bindings in AAI for CCVPN use case, +... using earliest API version where changes are implemented and +... latest API version where changes are not implemented + +Resource ../json_templater.robot +Resource aai_interface.robot +Resource api_version_properties.robot +Resource add-relationship-list.robot +Library OperatingSystem +Library Collections + + +*** Variables *** +${AAI_VPNB_ROOT_PATH} /network/vpn-bindings/vpn-binding +${AAI_VPNB_EXAMPLES_PATH} /examples/vpn-bindings +${AAI_VPNB_NODES_PATH} /nodes/vpn-bindings +${AAI_ADD_VPNBINDING_BODY}= robot/assets/templates/aai/add-vpn-binding.template +${AAI_VPNB_API_NA_INDEX_PATH}= ${AAI_BEIJING_INDEX_PATH} +${AAI_VPNB_API_IMPL_INDEX_PATH}= ${AAI_CASABLANCA_INDEX_PATH} + +*** Keywords *** +Create VPN Binding If Not Exists + [Documentation] Creates VPN Binding in AAI if it doesn't exist + [Arguments] ${vpn_id} + ${get_resp}= Run A&AI Get Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} + Return From Keyword If '${get_resp.status_code}' == '200' + Create VPN Binding ${vpn_id} + +Create VPN Binding + [Documentation] Creates VPN Binding in AAI + [Arguments] ${vpn_id} + ${arguments}= Create Dictionary vpn_id=${vpn_id} + ${data}= Fill JSON Template File ${AAI_ADD_VPNBINDING_BODY} ${arguments} + ${put_resp}= Run A&AI Put Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} ${data} + ${status_string}= Convert To String ${put_resp.status_code} + Should Match Regexp ${status_string} ^(201|200)$ + +Delete VPN Binding If Exists + [Documentation] Removes VPN Binding from AAI if it exists + [Arguments] ${vpn_id} + ${get_resp}= Run A&AI Get Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} + Run Keyword If '${get_resp.status_code}' == '200' Delete VPN Binding ${vpn_id} ${get_resp.json()} + +Delete VPN Binding + [Documentation] Removes VPN Binding from AAI + [Arguments] ${vpn_id} ${json} + ${resource_version}= Catenate ${json['resource-version']} + ${put_resp}= Run A&AI Delete Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} ${resource_version} + Should Be Equal As Strings ${put_resp.status_code} 204 + +Get VPN Binding + [Documentation] Return VPN Binding + [Arguments] ${vpn_id} + ${resp}= Run A&AI Get Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} + Should Be Equal As Strings ${resp.status_code} 200 + [Return] ${resp.json()} + +Get Valid VPN Binding URL + [Documentation] Return Valid VPN Binding URL + [Arguments] ${vpn_id} + ${resp}= Run A&AI Get Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} + Should Be Equal As Strings ${resp.status_code} 200 + [Return] ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} + +Get Nodes Query VPN Binding + [Documentation] Return Nodes query VPN Binding + [Arguments] ${vpn_id} + ${resp}= Run A&AI Get Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_NODES_PATH}?vpn-id=${vpn_id} + Should Be Equal As Strings ${resp.status_code} 200 + [Return] ${resp.json()} + +Get Example VPN Binding + [Documentation] Return Example VPN Binding + ${resp}= Run A&AI Get Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_EXAMPLES_PATH} + Should Be Equal As Strings ${resp.status_code} 200 + [Return] ${resp.json()} + +Confirm No VPN Binding + [Documentation] Confirm No VPN Binding + [Arguments] ${vpn_id} + ${resp}= Run A&AI Get Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} + Should Be Equal As Strings ${resp.status_code} 404 + +# Not applicable to VPN Binding as it appears in all known API versions +# Confirm API Not Implemented VPN Binding + # [Documentation] Confirm latest API version where VPN Binding is not implemented + # [Arguments] ${vpn_id} + # ${resp}= Run A&AI Get Request ${AAI_VPNB_API_NA_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} + # Should Be Equal As Strings ${resp.status_code} 400 + +Add VPN Binding Relationship + [Documentation] Adds Relationship to existing VPN Binding in AAI + [Arguments] ${vpn_id} ${related_class_name} ${related_object_url} + ${put_resp}= Add Relationship ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} ${related_class_name} ${related_object_url} + +Get VPN Binding RelationshipList + [Documentation] Return relationship-list from VPN Binding + [Arguments] ${vpn_id} + ${resp}= Get RelationshipList ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} + [Return] ${resp} + +Get VPN Binding With RelationshipList + [Documentation] Return VPN Binding with relationship-list + [Arguments] ${vpn_id} + ${resp}= Get Object With Depth ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} + [Return] ${resp} + diff --git a/robot/testsuites/aai/aai-regression-test-v14.robot b/robot/testsuites/aai/aai-regression-test-v14.robot index ab43776d..76104f8a 100644 --- a/robot/testsuites/aai/aai-regression-test-v14.robot +++ b/robot/testsuites/aai/aai-regression-test-v14.robot @@ -1,18 +1,69 @@ *** Settings *** Documentation AAI CSIT-style regression tests for CCVPN - new schema elements introduced in Casablanca release for CCVPN use case -Default Tags aai csit ccvpn -Test Timeout 10s +Test Timeout 20s Resource ${EXECDIR}/robot/resources/aai/ccvpn-connectivities.robot +Resource ${EXECDIR}/robot/resources/aai/ccvpn-vpn-bindings.robot *** Variables *** ${connectivity_id}= robot-connectivity-test-1 +${vpn_id}= robot-vpn-test-1 +${connectivity_class}= connectivity +${vpn_class}= vpn-binding *** Test Cases *** Connectivity test case + [Tags] aai csit ccvpn connectivity Confirm API Not Implemented Connectivity ${connectivity_id} Confirm No Connectivity ${connectivity_id} Create Connectivity If Not Exists ${connectivity_id} Get Connectivity ${connectivity_id} + [Teardown] Run Keywords Delete Connectivity If Exists ${connectivity_id} AND Confirm No Connectivity ${connectivity_id} + +VPN Binding test case + [Tags] aai csit ccvpn vpn-binding + Confirm No VPN Binding ${vpn_id} + Create VPN Binding If Not Exists ${vpn_id} + Get VPN Binding ${vpn_id} + [Teardown] Run Keywords Delete VPN Binding If Exists ${vpn_id} AND Confirm No VPN Binding ${vpn_id} + +Connectivity to VPN Binding Relationship test case + [Tags] aai csit ccvpn connectivity vpn-binding relationship + Confirm No Connectivity ${connectivity_id} + Confirm No VPN Binding ${vpn_id} + Create Connectivity If Not Exists ${connectivity_id} + Create VPN Binding If Not Exists ${vpn_id} + Get Connectivity ${connectivity_id} + Get VPN Binding ${vpn_id} + ${vpnbinding_url}= Get Valid VPN Binding URL ${vpn_id} + Add Connectivity Relationship ${connectivity_id} ${vpn_class} ${vpnbinding_url} + ${connectivity_rel}= Get Connectivity RelationshipList ${connectivity_id} + ${connectivity_rel_txt}= Catenate ${connectivity_rel} + Should Match Regexp ${connectivity_rel_txt} ${vpnbinding_url} + Should Match Regexp ${connectivity_rel_txt} ${vpn_class} + Get Connectivity With RelationshipList ${connectivity_id} + [Teardown] Run Keywords Delete Connectivity If Exists ${connectivity_id} AND Delete VPN Binding If Exists ${vpn_id} + +VPN Binding Relationship to Connectivity test case + [Tags] aai csit ccvpn connectivity vpn-binding relationship + Confirm No Connectivity ${connectivity_id} + Confirm No VPN Binding ${vpn_id} + Create Connectivity If Not Exists ${connectivity_id} + Create VPN Binding If Not Exists ${vpn_id} + Get Connectivity ${connectivity_id} + Get VPN Binding ${vpn_id} + ${connectivity_url}= Get Valid Connectivity URL ${connectivity_id} + Add VPN Binding Relationship ${vpn_id} ${connectivity_class} ${connectivity_url} + ${vpn_rel}= Get VPN Binding RelationshipList ${vpn_id} + ${vpn_rel_txt}= Catenate ${vpn_rel} + Should Match Regexp ${vpn_rel_txt} ${connectivity_url} + Should Match Regexp ${vpn_rel_txt} ${connectivity_class} + Get VPN Binding With RelationshipList ${vpn_id} + [Teardown] Run Keywords Delete Connectivity If Exists ${connectivity_id} AND Delete VPN Binding If Exists ${vpn_id} + +All Teardowns test case + [Tags] teardowns Delete Connectivity If Exists ${connectivity_id} + Delete VPN Binding If Exists ${vpn_id} Confirm No Connectivity ${connectivity_id} - [Teardown] Delete Connectivity If Exists ${connectivity_id} + Confirm No VPN Binding ${vpn_id} + |