2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
16 Documentation [QUOTAS-01] Quota enforcement.
18 Library OperatingSystem
22 Resource ../lib/project_lib.resource
23 Resource ../lib/user_lib.resource
25 Test Tags quotas_01 cluster_main daily regression
27 Suite Teardown Run Keyword And Ignore Error Suite Cleanup
31 # VNFD package to use during test
32 ${VNFD_PKG} hackfest_basic_vnf
34 # Project names and quotas to use
35 ${PROJECT_1_NAME} quotas_01_proj_1
36 ${PROJECT_2_NAME} quotas_01_proj_2
37 ${PROJECT_3_NAME} quotas_01_proj_3
38 ${PROJECT_1_QUOTAS} vnfds=1,nsds=2,ns_instances=3
39 ${PROJECT_2_QUOTAS} vnfds=1,nsds=1,ns_instances=1
40 ${PROJECT_3_QUOTAS} vnfds=5,nsds=,ns_instances=
42 # User name and password for project
43 ${USERNAME} quotas_01_user
44 ${USER_PASSWORD} Quotas_01_pass
45 ${USER_NEW_PASSWORD} Quotas_01_new_pass
47 ${SUCCESS_RETURN_CODE} 0
51 Create First Project With Quotas
52 [Documentation] Create a first project with quotas, then get the project quotas and check that they are correct.
53 Create Project With Quotas ${PROJECT_1_NAME} ${PROJECT_1_QUOTAS}
54 ${project_1_vnfds}= Get Project Quotas ${PROJECT_1_NAME} vnfds
55 Should Be Equal As Integers 1 ${project_1_vnfds}
56 ${project_1_nsds}= Get Project Quotas ${PROJECT_1_NAME} nsds
57 Should Be Equal As Integers 2 ${project_1_nsds}
58 ${project_1_ns_instances}= Get Project Quotas ${PROJECT_1_NAME} ns_instances
59 Should Be Equal As Integers 3 ${project_1_ns_instances}
61 Create Second Project With Quotas
62 [Documentation] Create a second project with quotas, then get the project quotas and check that they are correct.
63 Create Project With Quotas ${PROJECT_2_NAME} ${PROJECT_2_QUOTAS}
64 ${project_2_vnfds}= Get Project Quotas ${PROJECT_2_NAME} vnfds
65 Should Be Equal As Integers 1 ${project_2_vnfds}
66 ${project_2_nsds}= Get Project Quotas ${PROJECT_2_NAME} nsds
67 Should Be Equal As Integers 1 ${project_2_nsds}
68 ${project_2_ns_instances}= Get Project Quotas ${PROJECT_2_NAME} ns_instances
69 Should Be Equal As Integers 1 ${project_2_ns_instances}
71 Create User In Projects
72 [Documentation] Create a user with role project_admin in both projects.
73 ${rc} ${stdout}= Run And Return RC And Output osm user-create ${USERNAME} --password ${USER_PASSWORD} --project-role-mappings ${PROJECT_1_NAME},project_admin --project-role-mappings ${PROJECT_2_NAME},project_admin
75 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
76 Check If User Is Assigned To Project ${USERNAME} ${PROJECT_1_NAME}
77 Check If User Is Assigned To Project ${USERNAME} ${PROJECT_2_NAME}
78 Update User Password ${USERNAME} ${USER_PASSWORD} ${USER_NEW_PASSWORD}
80 Change First Project Name to Third Project Name
81 [Documentation] Rename first project. From now on, the project will be considered for the tests a third project.
82 Update Project Name ${PROJECT_1_NAME} ${PROJECT_3_NAME}
83 ${project_3_vnfds}= Get Project Quotas ${PROJECT_3_NAME} vnfds
84 Should Be Equal As Integers 1 ${project_3_vnfds}
85 ${project_3_nsds}= Get Project Quotas ${PROJECT_3_NAME} nsds
86 Should Be Equal As Integers 2 ${project_3_nsds}
87 ${project_3_ns_instances}= Get Project Quotas ${PROJECT_3_NAME} ns_instances
88 Should Be Equal As Integers 3 ${project_3_ns_instances}
89 Check If User Is Assigned To Project ${USERNAME} ${PROJECT_3_NAME}
91 Create VNFDs On Third Project Until Exceed Quota
92 [Documentation] Upload VNF packages in the third project.
93 Create VNFD In Project ${PROJECT_3_NAME} '%{PACKAGES_FOLDER}/${VNFD_PKG}' ${USERNAME} ${USER_NEW_PASSWORD} override='id=v1;product-name=v1'
94 Run Keyword And Expect Error * Create VNFD In Project ${PROJECT_3_NAME} '%{PACKAGES_FOLDER}/${VNFD_PKG}' ${USERNAME} ${USER_NEW_PASSWORD} override='id=v2;product-name=v2'
96 Increase Third Project Quotas
97 [Documentation] Update the quotas of the third project.
98 Update Project Quotas ${PROJECT_3_NAME} ${PROJECT_3_QUOTAS}
99 ${project_3_vnfds}= Get Project Quotas ${PROJECT_3_NAME} vnfds
100 Should Be Equal As Integers 5 ${project_3_vnfds}
102 Create More VNFDs On Third Project Until Exceed Quota
103 [Documentation] Upload VNF packages in the third project until the quota is reached, so that an error is obtained.
104 Create VNFD In Project ${PROJECT_3_NAME} '%{PACKAGES_FOLDER}/${VNFD_PKG}' ${USERNAME} ${USER_NEW_PASSWORD} override='id=v2;product-name=v2'
105 Create VNFD In Project ${PROJECT_3_NAME} '%{PACKAGES_FOLDER}/${VNFD_PKG}' ${USERNAME} ${USER_NEW_PASSWORD} override='id=v3;product-name=v3'
106 Create VNFD In Project ${PROJECT_3_NAME} '%{PACKAGES_FOLDER}/${VNFD_PKG}' ${USERNAME} ${USER_NEW_PASSWORD} override='id=v4;product-name=v4'
107 Create VNFD In Project ${PROJECT_3_NAME} '%{PACKAGES_FOLDER}/${VNFD_PKG}' ${USERNAME} ${USER_NEW_PASSWORD} override='id=v5;product-name=v5'
108 Run Keyword And Expect Error * Create VNFD In Project ${PROJECT_3_NAME} '%{PACKAGES_FOLDER}/${VNFD_PKG}' ${USERNAME} ${USER_NEW_PASSWORD} override='id=v6;product-name=v6'
110 Create VNFDs On Second Project Until Exceed Quota
111 [Documentation] Upload VNF packages in the second project until the quota is reached, so that an error is obtained.
112 Create VNFD In Project ${PROJECT_2_NAME} '%{PACKAGES_FOLDER}/${VNFD_PKG}' ${USERNAME} ${USER_NEW_PASSWORD} override='id=vp2_1;product-name=vp2_1'
113 Run Keyword And Expect Error * Create VNFD In Project ${PROJECT_2_NAME} '%{PACKAGES_FOLDER}/${VNFD_PKG}' ${USERNAME} ${USER_NEW_PASSWORD} override='id=vp2_2;product-name=vp2_2'
116 [Documentation] Check that the user can see a VNF package in both projects.
117 ${rc} ${stdout}= Run And Return RC And Output osm --project ${PROJECT_3_NAME} --password ${USER_NEW_PASSWORD} --user ${USERNAME} vnfpkg-show vp2_1
119 Should Not Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
120 ${rc} ${stdout}= Run And Return RC And Output osm --project ${PROJECT_2_NAME} --password ${USER_NEW_PASSWORD} --user ${USERNAME} vnfpkg-show v1
122 Should Not Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
124 Delete Second Project VNFD
125 [Documentation] Delete VNF packages from second project.
127 Delete VNFD In Project ${PROJECT_2_NAME} vp2_1 ${USERNAME} ${USER_NEW_PASSWORD}
129 Delete Third Project VNFDs
130 [Documentation] Delete VNF packages from third project.
132 Delete VNFD In Project ${PROJECT_3_NAME} v1 ${USERNAME} ${USER_NEW_PASSWORD}
133 Delete VNFD In Project ${PROJECT_3_NAME} v2 ${USERNAME} ${USER_NEW_PASSWORD}
134 Delete VNFD In Project ${PROJECT_3_NAME} v3 ${USERNAME} ${USER_NEW_PASSWORD}
135 Delete VNFD In Project ${PROJECT_3_NAME} v4 ${USERNAME} ${USER_NEW_PASSWORD}
136 Delete VNFD In Project ${PROJECT_3_NAME} v5 ${USERNAME} ${USER_NEW_PASSWORD}
138 Delete Second Project After Removing User From It
139 [Documentation] Delete user from second project, then delete the second project.
141 Run Keyword And Expect Error * Delete Project ${PROJECT_2_NAME}
142 Remove User From Project ${USERNAME} ${PROJECT_2_NAME}
143 Delete Project ${PROJECT_2_NAME}
146 [Documentation] Delete user.
148 ${rc}= Run And Return RC osm user-delete ${USERNAME}
152 [Documentation] Delete third project.
154 Delete Project ${PROJECT_3_NAME}
159 [Documentation] Test Suite Cleanup: Deleting VNF packages, projects and users.
160 Run Keyword If Any Tests Failed Run Keyword And Ignore Error Delete VNFD In Project ${PROJECT_2_NAME} vp2_1 ${USERNAME} ${USER_NEW_PASSWORD}
161 Run Keyword If Any Tests Failed Run Keyword And Ignore Error Delete VNFD In Project ${PROJECT_3_NAME} v1 ${USERNAME} ${USER_NEW_PASSWORD}
162 Run Keyword If Any Tests Failed Run Keyword And Ignore Error Delete VNFD In Project ${PROJECT_3_NAME} v2 ${USERNAME} ${USER_NEW_PASSWORD}
163 Run Keyword If Any Tests Failed Run Keyword And Ignore Error Delete VNFD In Project ${PROJECT_3_NAME} v3 ${USERNAME} ${USER_NEW_PASSWORD}
164 Run Keyword If Any Tests Failed Run Keyword And Ignore Error Delete VNFD In Project ${PROJECT_3_NAME} v4 ${USERNAME} ${USER_NEW_PASSWORD}
165 Run Keyword If Any Tests Failed Run Keyword And Ignore Error Delete VNFD In Project ${PROJECT_3_NAME} v5 ${USERNAME} ${USER_NEW_PASSWORD}
166 Run Keyword If Any Tests Failed Run Keyword And Ignore Error Delete Project ${PROJECT_1_NAME}
167 Run Keyword If Any Tests Failed Delete Project ${PROJECT_2_NAME}
168 Run Keyword If Any Tests Failed Run Keyword And Ignore Error Delete Project ${PROJECT_3_NAME}
169 Run And Return RC osm user-delete ${USERNAME}