|
59 | 59 | purge_db
|
60 | 60 |
|
61 | 61 | # We need to get the admin credentials to run the OSC CLIs for Placement.
|
62 |
| -set +x |
63 |
| -source $BASE/devstack/openrc admin |
64 |
| -set -x |
| 62 | +export OS_CLOUD=devstack-admin |
65 | 63 |
|
66 | 64 | # Verify whether instances were archived from all cells. Admin credentials are
|
67 | 65 | # needed to list deleted instances across all projects.
|
@@ -271,3 +269,66 @@ set -e
|
271 | 269 | # Verify whether online data migrations run after archiving will succeed.
|
272 | 270 | # See for more details: https://bugs.launchpad.net/nova/+bug/1824435
|
273 | 271 | $MANAGE db online_data_migrations
|
| 272 | + |
| 273 | + |
| 274 | +# Test global registered unified limits by updating registered limits and |
| 275 | +# attempting to create resources. Because these quota limits are global, we |
| 276 | +# can't test them in tempest because modifying global limits can cause other |
| 277 | +# tests running in parallel to fail. |
| 278 | +echo "Testing unified limits registered limits" |
| 279 | + |
| 280 | +# Get the registered limits IDs. |
| 281 | +reglimit_ids_names=$(openstack registered limit list -f value -c "ID" -c "Resource Name") |
| 282 | + |
| 283 | +# Put them in a map to lookup ID from name for subsequent limit set commands. |
| 284 | +# Requires Bash 4. |
| 285 | +declare -A id_name_map |
| 286 | +while read id name |
| 287 | + do id_name_map["$name"]="$id" |
| 288 | +done <<< "$reglimit_ids_names" |
| 289 | + |
| 290 | +# Server metadata items |
| 291 | +# |
| 292 | +# Set the quota to 1. |
| 293 | +metadata_items_id="${id_name_map["server_metadata_items"]}" |
| 294 | + |
| 295 | +bash -c "unset OS_USERNAME OS_TENANT_NAME OS_PROJECT_NAME; |
| 296 | + openstack --os-cloud devstack-system-admin registered limit set \ |
| 297 | + --default-limit 1 $metadata_items_id" |
| 298 | + |
| 299 | +# Create a server. Should succeed with one metadata item. |
| 300 | +openstack --os-compute-api-version 2.37 \ |
| 301 | + server create --image ${image_id} --flavor ${flavor_id} --nic none \ |
| 302 | + --property cool=true --wait metadata-items-test1 |
| 303 | + |
| 304 | +# Try to create another server with two metadata items. This should fail. |
| 305 | +set +e |
| 306 | +output=$(openstack --os-compute-api-version 2.37 \ |
| 307 | + server create --image ${image_id} --flavor ${flavor_id} --nic none \ |
| 308 | + --property cool=true --property location=fridge \ |
| 309 | + --wait metadata-items-test2) |
| 310 | +rc=$? |
| 311 | +set -e |
| 312 | +# Return code should be 1 if server create failed. |
| 313 | +if [[ ${rc} -ne 1 ]]; then |
| 314 | + echo "Expected return code 1 from server create with two metadata items" |
| 315 | + exit 2 |
| 316 | +fi |
| 317 | +# Verify it's a quota error. |
| 318 | +if [[ ! "HTTP 403" =~ "$output" ]]; then |
| 319 | + echo "Expected HTTP 403 from server create with two metadata items" |
| 320 | + exit 2 |
| 321 | +fi |
| 322 | + |
| 323 | +# Increase the quota limit to two. |
| 324 | +bash -c "unset OS_USERNAME OS_TENANT_NAME OS_PROJECT_NAME; |
| 325 | + openstack --os-cloud devstack-system-admin registered limit set \ |
| 326 | + --default-limit 2 $metadata_items_id" |
| 327 | + |
| 328 | +# Second server create should succeed now. |
| 329 | +openstack --os-compute-api-version 2.37 \ |
| 330 | + server create --image ${image_id} --flavor ${flavor_id} --nic none \ |
| 331 | + --property cool=true --property location=fridge --wait metadata-items-test2 |
| 332 | + |
| 333 | +# Delete the servers. |
| 334 | +openstack server delete metadata-items-test1 metadata-items-test2 |
0 commit comments