[CI] Add mariadb backup into mariadb scenario

We are not testing mariadb backup, let's test
it in mariadb scenario.

Change-Id: I81d6ee944b3ed0e75129772bb993ce7a6147c3e8
This commit is contained in:
Michal Arbet 2024-09-18 14:38:51 +02:00
parent 49cebeaf4d
commit 50cc656d60
2 changed files with 49 additions and 0 deletions

View File

@ -133,6 +133,7 @@ enable_fluentd: "yes"
enable_mariadb: "yes"
enable_memcached: "no"
enable_rabbitmq: "no"
enable_mariabackup: "yes"
{% endif %}
{% if scenario == "cephadm" %}

View File

@ -30,9 +30,57 @@ function test_recovery {
mariadb_recovery
}
function test_backup {
echo "Performing full backup"
kolla-ansible -i ${RAW_INVENTORY} -vvv mariadb_backup --full
# Sleep for 30 seconds, not because it's absolutely necessary.
# The full backup is already completed at this point, as the
# ansible job is waiting for the completion of the backup script
# in the container on the controller side. Its more of an
# attempt at a "sort of" simulation of the usual elapsed time
# since the last full backup for the incremental job, as some
# data gets written within those 30 seconds.
echo "Sleeping for 30 seconds"
sleep 30
kolla-ansible -i ${RAW_INVENTORY} -vvv mariadb_backup --incremental
}
function test_backup_with_retries {
# Retry test_backup up to 3 times if it fails
local max_retries=3
local attempt=1
while [[ $attempt -le $max_retries ]]; do
echo "Attempt $attempt of $max_retries for test_backup"
set +o errexit # Temporarily disable errexit for retry logic
test_backup
result=$?
set -o errexit # Re-enable errexit after the attempt
if [[ $result -eq 0 ]]; then
echo "test_backup succeeded on attempt $attempt"
return 0 # Exit the function if test_backup succeeds
else
echo "test_backup failed on attempt $attempt"
fi
if [[ $attempt -lt $max_retries ]]; then
echo "Sleeping for 30 seconds before the next attempt"
sleep 30 # Wait for 30 seconds before retrying
fi
attempt=$((attempt + 1))
done
echo "test_backup failed after $max_retries attempts"
return 1 # Return an error if all attempts fail
}
function test_mariadb_logged {
RAW_INVENTORY=/etc/kolla/inventory
source $KOLLA_ANSIBLE_VENV_PATH/bin/activate
test_backup_with_retries
test_recovery
}