From da7fdb4a4013397c4b47cbe76b57ae74307e16f1 Mon Sep 17 00:00:00 2001 From: garciaale Date: Fri, 17 Jul 2020 17:24:54 -0400 Subject: [PATCH] Adds Robot QUOTAS-01 test Change-Id: I38d51d0beea871808046d762f8fffb9c65e5f200 Signed-off-by: garciaale --- robot-systest/lib/project_lib.robot | 120 +++++++++++++ .../quotas_01-quota_enforcement_data.py | 25 +++ .../quotas_01-quota_enforcement.robot | 170 ++++++++++++++++++ 3 files changed, 315 insertions(+) create mode 100644 robot-systest/lib/project_lib.robot create mode 100644 robot-systest/resources/quotas_01-quota_enforcement_data.py create mode 100644 robot-systest/testsuite/quotas_01-quota_enforcement.robot diff --git a/robot-systest/lib/project_lib.robot b/robot-systest/lib/project_lib.robot new file mode 100644 index 0000000..916730d --- /dev/null +++ b/robot-systest/lib/project_lib.robot @@ -0,0 +1,120 @@ +# 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. + +*** Variables *** +${success_return_code} 0 + + +*** Keywords *** +Create Project With Quotas + [Arguments] ${project_name} ${project_quotas} + + Should Not Be Empty ${project_name} + Should Not Be Empty ${project_quotas} + ${rc} ${stdout}= Run and Return RC and Output osm project-create ${project_name} --quotas ${project_quotas} + Log ${stdout} + Should Be Equal As Integers ${rc} ${success_return_code} + [Return] ${stdout} + + +Get Project Quotas + [Arguments] ${project_name} ${quotas_name} + + Should Not Be Empty ${project_name} + Should Not Be Empty ${quotas_name} + ${rc} ${stdout}= Run and Return RC and Output osm project-show ${project_name} | grep '${quotas_name}' | awk -F ',|: ' '{print $2}' | awk '{print $1}' + Log ${stdout} + Should Be Equal As Integers ${rc} ${success_return_code} + [Return] ${stdout} + + +Update Project Quotas + [Arguments] ${project_name} ${project_quotas} + + Should Not Be Empty ${project_name} + Should Not Be Empty ${project_quotas} + ${rc} ${stdout}= Run and Return RC and Output osm project-update ${project_name} --quotas ${project_quotas} + Log ${stdout} + Should Be Equal As Integers ${rc} ${success_return_code} + + +Update Project Name + [Arguments] ${project_name} ${new_name} + + Should Not Be Empty ${project_name} + Should Not Be Empty ${new_name} + ${rc} ${stdout}= Run and Return RC and Output osm project-update ${project_name} --name ${new_name} + log ${stdout} + Should Be Equal As Integers ${rc} ${success_return_code} + + +Check If User Is Assigned To Project + [Arguments] ${user_name} ${project_name} + + Should Not Be Empty ${user_name} + Should Not Be Empty ${project_name} + ${rc} ${stdout}= Run And Return RC And Output osm user-show ${user_name} | grep "project_name" | grep "${project_name}" + Log ${stdout} + Should Be Equal As Integers ${rc} ${success_return_code} + + +Create VNFD In Project + [Documentation] Onboards a VNFD package into an OSM project. + ... Extra parameters (such as 'override') are given to this function in name=value format. These parameters will be appended to the 'osm vnfpkg-create' command with the next syntax: --param_name=param_value + + [Arguments] ${project_name} ${vnfd_pkg} ${project_user} ${user_password} @{optional_parameters} + + Should Not Be Empty ${project_name} + Should Not Be Empty ${vnfd_pkg} + Should Not Be Empty ${project_user} + Should Not Be Empty ${user_password} + + ${osm_pkg_create_command}= Set Variable osm --project ${project_name} --user ${project_user} --password ${user_password} vnfpkg-create ${vnfd_pkg} + FOR ${param} IN @{optional_parameters} + ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in optional parameters + ${osm_pkg_create_command}= Catenate ${osm_pkg_create_command} --${param_name}=${param_value} + END + + ${rc} ${stdout}= Run and Return RC and Output ${osm_pkg_create_command} + Log ${stdout} + Should Be Equal As Integers ${rc} ${success_return_code} + [Return] ${stdout} + + +Delete VNFD In Project + [Arguments] ${project_name} ${vnfd_pkg} ${project_user} ${user_password} + + Should Not Be Empty ${project_name} + Should Not Be Empty ${vnfd_pkg} + Should Not Be Empty ${project_user} + Should Not Be Empty ${user_password} + ${rc} ${stdout}= Run and Return RC and Output osm --project ${project_name} --user ${project_user} --password ${user_password} vnfpkg-delete ${vnfd_pkg} + Log ${stdout} + Should Be Equal As Integers ${rc} ${success_return_code} + + +Remove User From Project + [Arguments] ${user_name} ${project_name} + + Should Not Be Empty ${user_name} + Should Not Be Empty ${project_name} + ${rc} ${stdout}= Run And Return RC And Output osm user-update ${user_name} --remove-project ${project_name} + Log ${stdout} + Should Be Equal As Integers ${rc} ${success_return_code} + + +Delete Project + [Arguments] ${project_name} + + ${rc} ${stdout}= Run and Return RC and Output osm project-delete ${project_name} + Log ${stdout} + Should Be Equal As Integers ${rc} ${success_return_code} diff --git a/robot-systest/resources/quotas_01-quota_enforcement_data.py b/robot-systest/resources/quotas_01-quota_enforcement_data.py new file mode 100644 index 0000000..90bf709 --- /dev/null +++ b/robot-systest/resources/quotas_01-quota_enforcement_data.py @@ -0,0 +1,25 @@ +# 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. + +from pathlib import Path + +# Get ${HOME} from local machine +home = str(Path.home()) +# VNFD package to use during test +vnfd_name = 'hackfest_basic_vnf' +# Project names to use +project_1_name = 'quotas_01_proj_1' +project_2_name = 'quotas_01_proj_2' +project_3_name = 'quotas_01_proj_3' +# User name and password for project +user_name = 'quotas_01_user' +user_password = 'quotas_01_pass' diff --git a/robot-systest/testsuite/quotas_01-quota_enforcement.robot b/robot-systest/testsuite/quotas_01-quota_enforcement.robot new file mode 100644 index 0000000..a3ad7f5 --- /dev/null +++ b/robot-systest/testsuite/quotas_01-quota_enforcement.robot @@ -0,0 +1,170 @@ +# 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 [QUOTAS-01] Quota enforcement. + +Library OperatingSystem +Library String +Library Collections + +Resource %{ROBOT_DEVOPS_FOLDER}/lib/project_lib.robot + +Variables %{ROBOT_DEVOPS_FOLDER}/resources/quotas_01-quota_enforcement_data.py + +Suite Teardown Run Keyword And Ignore Error Test Cleanup + + +*** Variables *** +${success_return_code} 0 +${project_1_quotas} vnfds=1,nsds=2,ns_instances=3 +${project_2_quotas} vnfds=1,nsds=1,ns_instances=1 +${project_3_quotas} vnfds=5,nsds=,ns_instances= +${vnfd_pkg} %{PACKAGES_FOLDER}/${vnfd_name} + +*** Test Cases *** +Create First Project With Quotas + [Tags] quota_enforcement sanity regression + + Create Project With Quotas ${project_1_name} ${project_1_quotas} + ${project_1_vnfds}= Get Project Quotas ${project_1_name} vnfds + Should Be Equal As Integers 1 ${project_1_vnfds} + ${project_1_nsds}= Get Project Quotas ${project_1_name} nsds + Should Be Equal As Integers 2 ${project_1_nsds} + ${project_1_ns_instances}= Get Project Quotas ${project_1_name} ns_instances + Should Be Equal As Integers 3 ${project_1_ns_instances} + + +Create Second Project With Quotas + [Tags] quota_enforcement sanity regression + + Create Project With Quotas ${project_2_name} ${project_2_quotas} + ${project_2_vnfds}= Get Project Quotas ${project_2_name} vnfds + Should Be Equal As Integers 1 ${project_2_vnfds} + ${project_2_nsds}= Get Project Quotas ${project_2_name} nsds + Should Be Equal As Integers 1 ${project_2_nsds} + ${project_2_ns_instances}= Get Project Quotas ${project_2_name} ns_instances + Should Be Equal As Integers 1 ${project_2_ns_instances} + +Create User In Projects + [Tags] quota_enforcement sanity regression + + ${rc} ${stdout}= Run And Return RC And Output osm user-create ${user_name} --password ${user_password} --project-role-mappings ${project_1_name},project_admin --project-role-mappings ${project_2_name},project_admin + Should Be Equal As Integers ${rc} ${success_return_code} + Check If User Is Assigned To Project ${user_name} ${project_1_name} + Check If User Is Assigned To Project ${user_name} ${project_2_name} + + +Change First Project Name to Third Project Name + [Tags] quota_enforcement sanity regression + + Update Project Name ${project_1_name} ${project_3_name} + ${project_3_vnfds}= Get Project Quotas ${project_3_name} vnfds + Should Be Equal As Integers 1 ${project_3_vnfds} + ${project_3_nsds}= Get Project Quotas ${project_3_name} nsds + Should Be Equal As Integers 2 ${project_3_nsds} + ${project_3_ns_instances}= Get Project Quotas ${project_3_name} ns_instances + Should Be Equal As Integers 3 ${project_3_ns_instances} + Check If User Is Assigned To Project ${user_name} ${project_3_name} + + +Create VNFDs On Third Project Until Exceed Quota + [Tags] quota_enforcement sanity regression + + Create VNFD In Project ${project_3_name} ${vnfd_pkg} ${user_name} ${user_password} override='id=v1;name=v1' + Run Keyword And Expect Error * Create VNFD In Project ${project_3_name} ${vnfd_pkg} ${user_name} ${user_password} override='id=v2;name=v2' + + +Increase Third Project Quotas + [Tags] quota_enforcement sanity regression + + Update Project Quotas ${project_3_name} ${project_3_quotas} + ${project_3_vnfds}= Get Project Quotas ${project_3_name} vnfds + Should Be Equal As Integers 5 ${project_3_vnfds} + + +Create More VNFDs On Third Project Until Exceed Quota + [Tags] quota_enforcement sanity regression + + Create VNFD In Project ${project_3_name} ${vnfd_pkg} ${user_name} ${user_password} override='id=v2;name=v2' + Create VNFD In Project ${project_3_name} ${vnfd_pkg} ${user_name} ${user_password} override='id=v3;name=v3' + Create VNFD In Project ${project_3_name} ${vnfd_pkg} ${user_name} ${user_password} override='id=v4;name=v4' + Create VNFD In Project ${project_3_name} ${vnfd_pkg} ${user_name} ${user_password} override='id=v5;name=v5' + Run Keyword And Expect Error * Create VNFD In Project ${project_3_name} ${vnfd_pkg} ${user_name} ${user_password} override='id=v6;name=v6' + + +Create VNFDs On Second Project Until Exceed Quota + [Tags] quota_enforcement sanity regression + + Create VNFD In Project ${project_2_name} ${vnfd_pkg} ${user_name} ${user_password} override='id=vp2_1;name=vp2_1' + Run Keyword And Expect Error * Create VNFD In Project ${project_2_name} ${vnfd_pkg} ${user_name} ${user_password} override='id=vp2_2;name=vp2_2' + + +Check Project Scopes + [Tags] quota_enforcement sanity regression + + ${rc} ${stdout}= Run And Return RC And Output osm --project ${project_3_name} --password ${user_password} --user ${user_name} vnfpkg-show vp2_1 + Log ${stdout} + Should Not Be Equal As Integers ${rc} ${success_return_code} + ${rc} ${stdout}= Run And Return RC And Output osm --project ${project_2_name} --password ${user_password} --user ${user_name} vnfpkg-show v1 + Log ${stdout} + Should Not Be Equal As Integers ${rc} ${success_return_code} + + +Delete Second Project VNFD + [Tags] quota_enforcement sanity regression cleanup + + Delete VNFD In Project ${project_2_name} vp2_1 ${user_name} ${user_password} + + +Delete Third Project VNFDs + [Tags] quota_enforcement sanity regression cleanup + + Delete VNFD In Project ${project_3_name} v1 ${user_name} ${user_password} + Delete VNFD In Project ${project_3_name} v2 ${user_name} ${user_password} + Delete VNFD In Project ${project_3_name} v3 ${user_name} ${user_password} + Delete VNFD In Project ${project_3_name} v4 ${user_name} ${user_password} + Delete VNFD In Project ${project_3_name} v5 ${user_name} ${user_password} + + +Delete Second Project After Removing User From It + [Tags] quota_enforcement sanity regression cleanup + + Run Keyword And Expect Error * Delete Project ${project_2_name} + Remove User From Project ${user_name} ${project_2_name} + Delete Project ${project_2_name} + + +Delete Projects User + [Tags] quota_enforcement sanity regression cleanup + + ${rc}= Run And Return RC osm user-delete ${user_name} + + +Delete Third Project + [Tags] quota_enforcement sanity regression cleanup + + Delete Project ${project_3_name} + + +*** Keywords *** +Test Cleanup + Run Keyword If Test Failed Run Keyword And Ignore Error Delete VNFD In Project ${project_2_name} vp2_1 ${user_name} ${user_password} + Run Keyword If Test Failed Run Keyword And Ignore Error Delete VNFD In Project ${project_3_name} v1 ${user_name} ${user_password} + Run Keyword If Test Failed Run Keyword And Ignore Error Delete VNFD In Project ${project_3_name} v2 ${user_name} ${user_password} + Run Keyword If Test Failed Run Keyword And Ignore Error Delete VNFD In Project ${project_3_name} v3 ${user_name} ${user_password} + Run Keyword If Test Failed Run Keyword And Ignore Error Delete VNFD In Project ${project_3_name} v4 ${user_name} ${user_password} + Run Keyword If Test Failed Run Keyword And Ignore Error Delete VNFD In Project ${project_3_name} v5 ${user_name} ${user_password} + Run Keyword If Test Failed Run Keyword And Ignore Error Delete Project ${project_1_name} + Run Keyword If Test Failed Delete Project ${project_2_name} + Run Keyword If Test Failed Run Keyword And Ignore Error Delete Project ${project_3_name} + Run And Return RC osm user-delete ${user_name} -- 2.17.1