Skip to content

Commit 1c9de9c

Browse files
committed
Verify archive_deleted_rows --all-cells in post test hook
We are already running archive_deleted_rows in the gate, but we are not verifying whether all instance records, for example, were actually successfully removed from the databases (cell0 and cell1). This adds the --all-cells option to our archive_deleted_rows runs and verifies that instance records were successfully removed from all cell databases. It is not sufficient to check only for return code 0 because archive_deleted_rows will still return 0 when it misses archiving records in cell databases. Related-Bug: #1719487 Change-Id: If133b12bf02d708c099504a88b474dce0bdb0f00
1 parent 97b8cb3 commit 1c9de9c

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

gate/post_test_hook.sh

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ function archive_deleted_rows {
1010
return 1
1111
fi
1212
for i in `seq 30`; do
13-
$MANAGE $* db archive_deleted_rows --verbose --max_rows 1000 --before "$(date -d tomorrow)"
13+
if [[ $i -eq 1 ]]; then
14+
# This is just a test wrinkle to make sure we're covering the
15+
# non-all-cells (cell0) case, as we're not passing in the cell1
16+
# config.
17+
$MANAGE $* db archive_deleted_rows --verbose --max_rows 50 --before "$(date -d tomorrow)"
18+
else
19+
$MANAGE $* db archive_deleted_rows --verbose --max_rows 1000 --before "$(date -d tomorrow)" --all-cells
20+
fi
1421
RET=$?
1522
if [[ $RET -gt 1 ]]; then
1623
echo Archiving failed with result $RET
@@ -36,17 +43,11 @@ function purge_db {
3643
BASE=${BASE:-/opt/stack}
3744
source ${BASE}/devstack/functions-common
3845
source ${BASE}/devstack/lib/nova
39-
cell_conf=$(conductor_conf 1)
40-
# NOTE(danms): We need to pass the main config to get the api db
41-
# bits, and then also the cell config for the cell1 db (instead of
42-
# the cell0 config that is in the main config file). Later files
43-
# take precedence.
44-
conf="--config-file $NOVA_CONF --config-file $cell_conf"
4546

4647
# This needs to go before 'set -e' because otherwise the intermediate runs of
4748
# 'nova-manage db archive_deleted_rows' returning 1 (normal and expected) would
4849
# cause this script to exit and fail.
49-
archive_deleted_rows $conf
50+
archive_deleted_rows
5051

5152
set -e
5253

@@ -59,6 +60,17 @@ set +x
5960
source $BASE/devstack/openrc admin
6061
set -x
6162

63+
# Verify whether instances were archived from all cells. Admin credentials are
64+
# needed to list deleted instances across all projects.
65+
echo "Verifying that instances were archived from all cells"
66+
deleted_servers=$(openstack server list --deleted --all-projects -c ID -f value)
67+
68+
# Fail if any deleted servers were found.
69+
if [[ -n "$deleted_servers" ]]; then
70+
echo "There were unarchived instances found after archiving; failing."
71+
exit 1
72+
fi
73+
6274
# TODO(mriedem): Consider checking for instances in ERROR state because
6375
# if there are any, we would expect them to retain allocations in Placement
6476
# and therefore we don't really need to check for leaked allocations.

0 commit comments

Comments
 (0)