Skip to content

Instantly share code, notes, and snippets.

@strider
Created April 18, 2019 11:45
Show Gist options
  • Save strider/c945889fb97e038520dce300a0ab95fe to your computer and use it in GitHub Desktop.
Save strider/c945889fb97e038520dce300a0ab95fe to your computer and use it in GitHub Desktop.
run-validations-mistral.sh
#!/bin/bash
set -eux
set -o pipefail
### --start_docs
## Run all validations for one group name
## ======================================
## Prepare Your Environment
## ------------------------
## * Source in the undercloud credentials.
## ::
source /home/stack/stackrc
GROUP_NAME="${1:-}"
VALIDATION_NAME="${2:-}"
if [ -z "$GROUP_NAME" ]; then
echo "You must specify the validation group name."
exit 1
fi
## * Getting the list of validations belonging to the group.
## ::
if [ -z $VALIDATION_NAME ]; then
LIST_VALIDATIONS=$(openstack action execution \
run tripleo.validations.list_validations \
"{\"groups\": [\"$GROUP_NAME\"]}" | jq ".result[] | .id" | tr -d '"')
else
LIST_VALIDATIONS=$VALIDATION_NAME
fi
## * Run validations tests one by one defined in the group.
## ::
if [ -f "/home/stack/failed_tripleo_validations.log" ]; then
rm -Rf "/home/stack/failed_tripleo_validations.log"
fi
for validation_name in $LIST_VALIDATIONS; do
ID=$(openstack workflow execution create \
-f value \
-c ID \
tripleo.validations.v1.run_validation \
"{\"validation_name\": \"$validation_name\"}")
STATE=RUNNING
TRIES=0
while [ "$STATE" = RUNNING ]; do
sleep 1
STATE=$(mistral execution-get -f value -c State "$ID")
TRIES=$((TRIES+1))
if [ "$TRIES" -gt 40 ]; then
break
fi
done
STATUS=$(mistral execution-get-output "$ID" | jq .status -r)
if [ "$STATUS" != "SUCCESS" ]; then
echo "### ${validation_name} $STATUS ###" | tee -a /home/stack/failed_tripleo_validations.log
mistral execution-get-output "$ID" | jq .stderr -r 2>&1 | tee -a /home/stack/failed_tripleo_validations.log
else
mistral execution-get-output "$ID" | jq .stdout -r
fi
done
## --stop_docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment