summaryrefslogtreecommitdiff
path: root/gate
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem.os@gmail.com>2019-06-27 13:24:33 -0400
committerEric Fried <openstack@fried.cc>2019-06-29 11:03:55 +0000
commit87365c760ee89493db87183c4c751ba5fc7b921a (patch)
tree15e84d81bc55edb6dfed8da8f4d80e47ef61b2f6 /gate
parent7b769ad403751268c60b095f722437cbed692071 (diff)
downloadnova-87365c760ee89493db87183c4c751ba5fc7b921a.tar.gz
Add integration testing for heal_allocations
This adds a simple scenario for the heal_allocations CLI to the post_test_hook script run at the end of the nova-next job. The functional testing in-tree is pretty extensive but it's always good to have real integration testing. Change-Id: If86e4796a9db3020d4fdb751e8bc771c6f98aa47 Related-Bug: #1819923
Diffstat (limited to 'gate')
-rwxr-xr-xgate/post_test_hook.sh54
1 files changed, 54 insertions, 0 deletions
diff --git a/gate/post_test_hook.sh b/gate/post_test_hook.sh
index 385d83d4f9..ef7326ab28 100755
--- a/gate/post_test_hook.sh
+++ b/gate/post_test_hook.sh
@@ -77,3 +77,57 @@ if [[ $LEAKED_ALLOCATIONS -eq 1 ]]; then
exit 1
fi
echo "Resource provider allocations were cleaned up properly."
+
+
+# Test "nova-manage placement heal_allocations" by creating a server, deleting
+# its allocations in placement, and then running heal_allocations and assert
+# the allocations were healed as expected.
+image_id=$(openstack image list -f value -c ID | awk 'NR==1{print $1}')
+flavor_id=$(openstack flavor list -f value -c ID | awk 'NR==1{print $1}')
+network_id=$(openstack network list --no-share -f value -c ID | awk 'NR==1{print $1}')
+
+echo "Creating server for heal_allocations testing"
+openstack server create --image ${image_id} --flavor ${flavor_id} \
+--nic net-id=${network_id} --wait heal-allocations-test
+server_id=$(openstack server show heal-allocations-test -f value -c id)
+
+# Make sure there are allocations for the consumer.
+allocations=$(openstack resource provider allocation show ${server_id} \
+ -c resources -f value)
+if [[ "$allocations" == "" ]]; then
+ echo "No allocations found for the server."
+ exit 2
+fi
+
+echo "Deleting allocations in placement for the server"
+openstack resource provider allocation delete ${server_id}
+
+# Make sure the allocations are gone.
+allocations=$(openstack resource provider allocation show ${server_id} \
+ -c resources -f value)
+if [[ "$allocations" != "" ]]; then
+ echo "Server allocations were not deleted."
+ exit 2
+fi
+
+echo "Healing allocations"
+# First test with the --dry-run over all instances in all cells.
+set +e
+nova-manage placement heal_allocations --verbose --dry-run
+rc=$?
+set -e
+# Since we did not create allocations because of --dry-run the rc should be 4.
+if [[ ${rc} -ne 4 ]]; then
+ echo "Expected return code 4 from heal_allocations with --dry-run"
+ exit 2
+fi
+# Now test with just the single instance and actually perform the heal.
+nova-manage placement heal_allocations --verbose --instance ${server_id}
+
+# Make sure there are allocations for the consumer.
+allocations=$(openstack resource provider allocation show ${server_id} \
+ -c resources -f value)
+if [[ "$allocations" == "" ]]; then
+ echo "Failed to heal allocations."
+ exit 2
+fi