Browse Source

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
tags/20.0.0.0rc1
Matt Riedemann 3 months ago
parent
commit
87365c760e
1 changed files with 54 additions and 0 deletions
  1. 54
    0
      gate/post_test_hook.sh

+ 54
- 0
gate/post_test_hook.sh View File

@@ -77,3 +77,57 @@ if [[ $LEAKED_ALLOCATIONS -eq 1 ]]; then
77 77
     exit 1
78 78
 fi
79 79
 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

Loading…
Cancel
Save