From: garciadeblas Date: Tue, 27 Jun 2023 09:21:05 +0000 (+0200) Subject: Rename sol003_common_lib to rest_lib and move variables to sol003_01 testsuite X-Git-Tag: release-v14.0-start~5 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=68eac4adc72e599c83053a8806dfd61986237369;p=osm%2Ftests.git Rename sol003_common_lib to rest_lib and move variables to sol003_01 testsuite Change-Id: I1bb45dfe6fd5915798ad859eb23ff8d11be5a4f4 Signed-off-by: garciadeblas --- diff --git a/robot-systest/lib/rest_lib.robot b/robot-systest/lib/rest_lib.robot new file mode 100644 index 0000000..7541a52 --- /dev/null +++ b/robot-systest/lib/rest_lib.robot @@ -0,0 +1,99 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License + +*** Settings *** +Documentation Library with sol003 keywords and variables . + +Library RequestsLibrary +Library JsonValidator +Library yaml +Library JSONLibrary +Library String +Library OperatingSystem +Resource %{ROBOT_DEVOPS_FOLDER}/lib/vim_lib.robot +Variables %{ROBOT_DEVOPS_FOLDER}/resources/sol003_01-vnf_lifecycle_management.py + +*** Variables *** +@{success_status_code_list} 200 201 202 204 +${auth_token_uri} /osm/admin/v1/tokens +${HOST} ${EMPTY} + +*** Keywords *** +Get Auth Token + [Tags] auth_token + Get Hostname + Create Session osmhit ${HOST} disable_warnings=1 + &{headers} Create Dictionary Content-Type=application/json Accept=application/json + &{data} Create Dictionary username=${osm_user} password=${osm_password} project-id=${osm_project} + ${resp}= Post On Session osmhit ${auth_token_uri} json=${data} headers=${headers} + Log ${resp} + Pass Execution If ${resp.status_code} in ${success_status_code_list} Get Auth Token completed + Set Suite Variable ${token_status_code} ${resp.status_code} + ${access_token}= Get Value From Json ${resp.json()} $..id + Set Test Variable ${access_token} ${access_token[0]} + Set Test Variable ${token_response} ${resp} + sleep 2s + +Set Dockerized Host + [Arguments] ${env_host} + Set Suite Variable ${HOST} https://${env_host} + +Set Standalone Host + [Arguments] ${env_host} + Set Suite Variable ${HOST} https://${env_host}:9999 + +Read Directory + [Documentation] To Read Current Direct ory + ${Directory}= Replace String ${CURDIR} lib resources/ + ${json_path}= Set Variable ${Directory} + [Return] ${JsonPath} + +Post Api Request + [Arguments] ${PostApi} + [Documentation] Keword to Post API Request + Create Session APISession ${HOST} + &{headers} Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${access_token} + ${request_response}= Post On Session APISession ${PostApi} json=${updated_json_obj} headers=${headers} + Set Suite Variable ${request_response} + ${response_statuscode} Convert To String ${request_response.status_code} + Set Suite Variable ${response_statuscode} + +Get Hostname + [Documentation] Keyword to get the default osm Hostname + ${nbi_host}= Get Environment Variable OSM_HOSTNAME + ${passed}= Run Keyword And Return Status Should Contain ${nbi_host} : + Run Keyword If ${passed} Set Dockerized Host ${nbi_host} + ... ELSE Set Standalone Host ${nbi_host} + +Get ID + [Arguments] ${Key} + Pass Execution If ${request_response.status_code} in ${success_status_code_list} Get Auth Token completed + ${id}= Get Value From Json ${request_response.json()} $..${Key} + Set Suite Variable ${value} ${id[0]} + [Return] ${value} + +Update Json Value + [Arguments] ${JsonInput} ${key} + ${json_path}= Read Directory + ${json_obj}= Load JSON From File ${json_path}/${JsonInput} + ${updated_json_obj}= JSONLibrary.Update Value To Json ${json_obj} $..${key} ${created_vim_account_id} + Set Suite Variable ${updated_json_obj} + +Get Api Request + [Arguments] ${uri} + [Documentation] Keyword to Get API Request + Create Session Session ${HOST} + &{headers} Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${access_token} + ${request_response}= Get On Session Session ${uri} headers=${Headers} + Set Suite Variable ${request_response} + ${response_statuscode} Convert To String ${request_response.status_code} + Set Suite Variable ${response_statuscode} diff --git a/robot-systest/lib/sol003_common_lib.robot b/robot-systest/lib/sol003_common_lib.robot deleted file mode 100644 index d233498..0000000 --- a/robot-systest/lib/sol003_common_lib.robot +++ /dev/null @@ -1,103 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License - -*** Settings *** -Documentation Library with sol003 keywords and variables . - -Library RequestsLibrary -Library JsonValidator -Library yaml -Library JSONLibrary -Library String -Library OperatingSystem -Resource %{ROBOT_DEVOPS_FOLDER}/lib/vim_lib.robot -Variables %{ROBOT_DEVOPS_FOLDER}/resources/sol003_01-vnf_lifecycle_management.py - -*** Variables *** -@{success_status_code_list} 200 201 202 204 -${descriptor_content_type_gzip} application/gzip -${auth_token_uri} /osm/admin/v1/tokens -${HOST} ${EMPTY} -${vnf_instance_uri} /osm/vnflcm/v1/vnf_instances -${vnf_instantiate_uri} /osm/vnflcm/v1/vnf_instances -${vnf_instance_lcm_ops} /osm/vnflcm/v1/vnf_lcm_op_occs - -*** Keywords *** -Get Auth Token - [Tags] auth_token - Get Hostname - Create Session osmhit ${HOST} disable_warnings=1 - &{headers} Create Dictionary Content-Type=application/json Accept=application/json - &{data} Create Dictionary username=${osm_user} password=${osm_password} project-id=${osm_project} - ${resp}= Post On Session osmhit ${auth_token_uri} json=${data} headers=${headers} - Log ${resp} - Pass Execution If ${resp.status_code} in ${success_status_code_list} Get Auth Token completed - Set Suite Variable ${token_status_code} ${resp.status_code} - ${access_token}= Get Value From Json ${resp.json()} $..id - Set Test Variable ${access_token} ${access_token[0]} - Set Test Variable ${token_response} ${resp} - sleep 2s - -Set Dockerized Host - [Arguments] ${env_host} - Set Suite Variable ${HOST} https://${env_host} - -Set Standalone Host - [Arguments] ${env_host} - Set Suite Variable ${HOST} https://${env_host}:9999 - -Read Directory - [Documentation] To Read Current Direct ory - ${Directory}= Replace String ${CURDIR} lib resources/ - ${json_path}= Set Variable ${Directory} - [Return] ${JsonPath} - -Post Api Request - [Arguments] ${PostApi} - [Documentation] Keword to Post API Request - Create Session APISession ${HOST} - &{headers} Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${access_token} - ${request_response}= Post On Session APISession ${PostApi} json=${updated_json_obj} headers=${headers} - Set Suite Variable ${request_response} - ${response_statuscode} Convert To String ${request_response.status_code} - Set Suite Variable ${response_statuscode} - -Get HostName - [Documentation] Keyword to get the default osm Hostname - ${nbi_host}= Get Environment Variable OSM_HOSTNAME - ${passed}= Run Keyword And Return Status Should Contain ${nbi_host} : - Run Keyword If ${passed} Set Dockerized Host ${nbi_host} - ... ELSE Set Standalone Host ${nbi_host} - -Get ID - [Arguments] ${Key} - Pass Execution If ${request_response.status_code} in ${success_status_code_list} Get Auth Token completed - ${id}= Get Value From Json ${request_response.json()} $..${Key} - Set Suite Variable ${value} ${id[0]} - [Return] ${value} - -Update Json Value - [Arguments] ${JsonInput} ${key} - ${json_path}= Read Directory - ${json_obj}= Load JSON From File ${json_path}/${JsonInput} - ${updated_json_obj}= JSONLibrary.Update Value To Json ${json_obj} $..${key} ${created_vim_account_id} - Set Suite Variable ${updated_json_obj} - -Get Api Request - [Arguments] ${uri} - [Documentation] Keyword to Get API Request - Create Session Session ${HOST} - &{headers} Create Dictionary Content-Type=application/json Accept=application/json Authorization=Bearer ${access_token} - ${request_response}= Get On Session Session ${uri} headers=${Headers} - Set Suite Variable ${request_response} - ${response_statuscode} Convert To String ${request_response.status_code} - Set Suite Variable ${response_statuscode} diff --git a/robot-systest/testsuite/sol003_01-vnf-lifecycle-management.robot b/robot-systest/testsuite/sol003_01-vnf-lifecycle-management.robot index 750ea84..9dfcd76 100644 --- a/robot-systest/testsuite/sol003_01-vnf-lifecycle-management.robot +++ b/robot-systest/testsuite/sol003_01-vnf-lifecycle-management.robot @@ -21,7 +21,7 @@ Library yaml Library JsonValidator Library JSONLibrary -Resource %{ROBOT_DEVOPS_FOLDER}/lib/sol003_common_lib.robot +Resource %{ROBOT_DEVOPS_FOLDER}/lib/rest_lib.robot Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnf_lib.robot @@ -33,6 +33,12 @@ Suite Teardown Run Keyword And Ignore Error Suite Cleanup *** Variables *** +# SOL003 API URI paths +${vnf_instance_uri} /osm/vnflcm/v1/vnf_instances +${vnf_instantiate_uri} /osm/vnflcm/v1/vnf_instances +${vnf_instance_lcm_ops} /osm/vnflcm/v1/vnf_lcm_op_occs + +# NS and VNF descriptor package folder and ids ${vnfd_pkg} hackfest_basic_metrics_vnf ${vnfd_name} hackfest_basic_metrics-vnf