Skip to content

Commit a4cd243

Browse files
committed
Improve Tempest test result handling
- Backup previous results to avoid mistaking them for new ones - Ignore docker logs check failure because it's racy - Check for failed-tests artifact and exit 1 if any tests fail
1 parent 7d2b189 commit a4cd243

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

templates/deploy-openstack.tpl

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ declare -A config_directories=(
2323
["openstack"]="$HOME/src/openstack-config"
2424
)
2525

26+
tempest_dir="$HOME/tempest-artifacts"
27+
2628
function activate_virt_env () {
2729
set +u
2830
source $${virtual_environments[$1]}
@@ -138,11 +140,36 @@ set +x
138140
export KAYOBE_AUTOMATION_SSH_PRIVATE_KEY=$(cat ~/.ssh/id_rsa)
139141
set -x
140142

143+
if [[ -d $tempest_dir ]]; then
144+
tempest_backup=$${tempest_dir}.$(date --iso-8601=minutes)
145+
echo "Found previous Tempest test results"
146+
echo "Moving to $tempest_backup"
147+
mv $tempest_dir $tempest_backup
148+
fi
149+
141150
# Run tempest
142-
sudo -E docker run --detach --rm --network host -v $${config_directories[kayobe]}:/stack/kayobe-automation-env/src/kayobe-config -v ~/tempest-artifacts:/stack/tempest-artifacts -e KAYOBE_ENVIRONMENT -e KAYOBE_VAULT_PASSWORD -e KAYOBE_AUTOMATION_SSH_PRIVATE_KEY kayobe:latest /stack/kayobe-automation-env/src/kayobe-config/.automation/pipeline/tempest.sh -e ansible_user=stack
151+
sudo -E docker run --name kayobe_tempest --detach --rm --network host -v $${config_directories[kayobe]}:/stack/kayobe-automation-env/src/kayobe-config -v $tempest_dir:/stack/tempest-artifacts -e KAYOBE_ENVIRONMENT -e KAYOBE_VAULT_PASSWORD -e KAYOBE_AUTOMATION_SSH_PRIVATE_KEY kayobe:latest /stack/kayobe-automation-env/src/kayobe-config/.automation/pipeline/tempest.sh -e ansible_user=stack
143152

144153
# During the initial deployment the seed node must receive the `gwee/rally` image before we can follow the logs.
145154
# Therefore, we must wait a reasonable amount time before attempting to do so.
146155
sleep 360
147156

148-
ssh -oStrictHostKeyChecking=no ${ ssh_user }@${ seed_addr } 'sudo docker logs --follow tempest'
157+
if ! ssh -oStrictHostKeyChecking=no ${ ssh_user }@${ seed_addr } 'sudo docker logs --follow tempest'; then
158+
echo "Failed to follow Tempest container logs after waiting 360 seconds"
159+
echo "Ignoring - this may or may not indicate an error"
160+
fi
161+
162+
# Wait for Kayobe Tempest pipeline to complete to ensure artifacts exist.
163+
sudo docker container wait kayobe_tempest
164+
165+
if [[ ! -f $tempest_dir/failed-tests ]]; then
166+
echo "Unable to find Tempest test results in $tempest_dir/failed-tests"
167+
exit 1
168+
fi
169+
170+
if [[ $(wc -l < $tempest_dir/failed-tests) -ne 0 ]]; then
171+
echo "Some Tempest tests failed"
172+
exit 1
173+
fi
174+
175+
echo "Tempest testing successful"

0 commit comments

Comments
 (0)