Skip to content

Commit a8d2b24

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Add integration testing for heal_allocations"
2 parents d540903 + 87365c7 commit a8d2b24

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

gate/post_test_hook.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,57 @@ if [[ $LEAKED_ALLOCATIONS -eq 1 ]]; then
7777
exit 1
7878
fi
7979
echo "Resource provider allocations were cleaned up properly."
80+
81+
82+
# Test "nova-manage placement heal_allocations" by creating a server, deleting
83+
# its allocations in placement, and then running heal_allocations and assert
84+
# the allocations were healed as expected.
85+
image_id=$(openstack image list -f value -c ID | awk 'NR==1{print $1}')
86+
flavor_id=$(openstack flavor list -f value -c ID | awk 'NR==1{print $1}')
87+
network_id=$(openstack network list --no-share -f value -c ID | awk 'NR==1{print $1}')
88+
89+
echo "Creating server for heal_allocations testing"
90+
openstack server create --image ${image_id} --flavor ${flavor_id} \
91+
--nic net-id=${network_id} --wait heal-allocations-test
92+
server_id=$(openstack server show heal-allocations-test -f value -c id)
93+
94+
# Make sure there are allocations for the consumer.
95+
allocations=$(openstack resource provider allocation show ${server_id} \
96+
-c resources -f value)
97+
if [[ "$allocations" == "" ]]; then
98+
echo "No allocations found for the server."
99+
exit 2
100+
fi
101+
102+
echo "Deleting allocations in placement for the server"
103+
openstack resource provider allocation delete ${server_id}
104+
105+
# Make sure the allocations are gone.
106+
allocations=$(openstack resource provider allocation show ${server_id} \
107+
-c resources -f value)
108+
if [[ "$allocations" != "" ]]; then
109+
echo "Server allocations were not deleted."
110+
exit 2
111+
fi
112+
113+
echo "Healing allocations"
114+
# First test with the --dry-run over all instances in all cells.
115+
set +e
116+
nova-manage placement heal_allocations --verbose --dry-run
117+
rc=$?
118+
set -e
119+
# Since we did not create allocations because of --dry-run the rc should be 4.
120+
if [[ ${rc} -ne 4 ]]; then
121+
echo "Expected return code 4 from heal_allocations with --dry-run"
122+
exit 2
123+
fi
124+
# Now test with just the single instance and actually perform the heal.
125+
nova-manage placement heal_allocations --verbose --instance ${server_id}
126+
127+
# Make sure there are allocations for the consumer.
128+
allocations=$(openstack resource provider allocation show ${server_id} \
129+
-c resources -f value)
130+
if [[ "$allocations" == "" ]]; then
131+
echo "Failed to heal allocations."
132+
exit 2
133+
fi

0 commit comments

Comments
 (0)