|
# cat unattended-loop-create_and_delete-pB
|
|
#!/bin/bash
|
|
|
|
WORK_WINDOW="4h"
|
|
WAIT_WINDOW="4h"
|
|
|
|
mkdir -v logs
|
|
|
|
for i in {1..42}; do
|
|
|
|
printf "\n[%02d - %s] - START\n\n" "${i}" "$(date)"
|
|
|
|
# Unlock tests.
|
|
rm -fv /tmp/stop-tests-create-snapshots-with-data /tmp/stop-tests
|
|
|
|
# If it's an odd run, delete snapshots, if it's an even run create snapshots.
|
|
if [[ $(( i % 2 )) == 0 ]]; then
|
|
# Even - crate
|
|
printf "\n"
|
|
echo ./create_snapshot.sh
|
|
printf "\n"
|
|
time ././create_snapshot.sh
|
|
else
|
|
# Odd - delete
|
|
printf "\n"
|
|
echo ./delete_random_snapshots.sh
|
|
time ./delete_random_snapshots.sh
|
|
printf "\n"
|
|
fi
|
|
|
|
# Sleep and stop tests.
|
|
printf "\nBefore entering work window:\n\n"
|
|
printf "\t%s\n\t%s\n" "$(date)" "$(uptime)"
|
|
sleep "${WORK_WINDOW}"
|
|
printf "\nAfter leaving work window:\n\n"
|
|
printf "\t%s\n\t%s\n" "$(date)" "$(uptime)"
|
|
touch /tmp/stop-tests-create-snapshots-with-data /tmp/stop-tests
|
|
|
|
# Sleep to give the cluster time to recover/catch up.
|
|
printf "\nBefore entering rest window:\n\n"
|
|
printf "\t%s\n\t%s\n" "$(date)" "$(uptime)"
|
|
sleep "${WAIT_WINDOW}"
|
|
printf "\nAfter leaving rest window:\n\n"
|
|
printf "\t%s\n\t%s\n" "$(date)" "$(uptime)"
|
|
|
|
printf "\n[%02d - %s] - END\n\n" "${i}" "$(date)"
|
|
done |& tee logs/unattended-loop-create_and_delete-pB-${HOSTNAME}-$(date +%Y%m%d-%H%M%S).log
|
|
|
|
|
|
# cat testing-modify-delete-random-snapshots-pB
|
|
#!/bin/bash
|
|
#
|
|
# testing-modify-delete-random-snapshots-pB
|
|
#
|
|
|
|
# Version: 20181129-00
|
|
|
|
DATE="$(date "+%Y%m%d-%H%M%S")"
|
|
|
|
RBD_POOL=test-rbd0
|
|
|
|
declare -i work_counter
|
|
|
|
[[ -d /mnt/rbd ]] || mkdir /mnt/rbd
|
|
|
|
get_rbd_name()
|
|
{
|
|
printf "vpayno-sparse-%050d" ${1}
|
|
} # get_rbd_name()
|
|
|
|
worker()
|
|
{
|
|
local -i id="${1}"
|
|
|
|
rbd_name=$(get_rbd_name ${id})
|
|
|
|
printf "\n(%07d) %s\n\n" ${id} "${rbd_name}"
|
|
|
|
printf "Checking to see if %s/%s exists...\n" "${RBD_POOL}" "${rbd_name}"
|
|
if ! grep -q "^${rbd_name}$" /root/rbd-list.txt; then
|
|
printf "RBD does not exist, skipping ...\n"
|
|
return
|
|
fi
|
|
|
|
printf "Creating RBD lock ...\n"
|
|
echo rbd lock add ${RBD_POOL}/${rbd_name} vpayno
|
|
time if ! rbd lock add ${RBD_POOL}/${rbd_name} vpayno; then
|
|
printf "Getting lock failed, skipping ...\n"
|
|
return
|
|
fi
|
|
|
|
# Grab the oldest snapshot name.
|
|
snap_name="$(rbd snap ls ${RBD_POOL}/${rbd_name} | awk '/^[0-9][0-9]/ { print $2 }' | head -n 1)"
|
|
|
|
printf "last snapshot: %s\n" "${snap_name}"
|
|
|
|
printf "Removing snapshot ...\n"
|
|
echo rbd snap remove ${RBD_POOL}/${rbd_name}@${snap_name}
|
|
time rbd snap remove ${RBD_POOL}/${rbd_name}@${snap_name}
|
|
|
|
printf "\n"
|
|
|
|
rbd lock list ${RBD_POOL}/${rbd_name}
|
|
|
|
printf "Removing RBD lock ...\n"
|
|
echo rbd lock remove ${RBD_POOL}/${rbd_name} $(rbd lock list ${RBD_POOL}/${rbd_name} | awk '/^client/ { print $2" "$1 }')
|
|
time rbd lock remove ${RBD_POOL}/${rbd_name} $(rbd lock list ${RBD_POOL}/${rbd_name} | awk '/^client/ { print $2" "$1 }')
|
|
|
|
rbd lock list ${RBD_POOL}/${rbd_name}
|
|
|
|
printf "\n"
|
|
} # worker()
|
|
|
|
time for i in {0..999999}; do
|
|
|
|
id="$(shuf -i 0-499999 -n 1)"
|
|
echo worker ${id}
|
|
worker ${id} &
|
|
let work_counter++
|
|
|
|
#break
|
|
|
|
sleep 0.5s
|
|
|
|
if [[ $(( ${i} % 6 )) -eq 0 ]]; then
|
|
|
|
jobs
|
|
time wait
|
|
|
|
printf "\n# of worker threads that have completed: %d\n\n" "${work_counter}"
|
|
|
|
echo sleeping...
|
|
sleep 15s
|
|
|
|
fi
|
|
|
|
[[ -f /tmp/stop-tests ]] && break
|
|
|
|
done
|
|
|
|
jobs
|
|
time wait
|