Skip to content

Commit

Permalink
systemtest: test migration jobs
Browse files Browse the repository at this point in the history
use low job retention
  • Loading branch information
alaaeddineelamri committed Oct 20, 2022
1 parent a84e554 commit 6e4d649
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 2 deletions.
@@ -0,0 +1,9 @@
Job {
Name = "migrate"
Type = Migrate
Pool = Full
Selection Type = Volume
Selection Pattern = "."
Client = "bareos-fd"
Messages = Standard
}
Expand Up @@ -3,7 +3,7 @@ Pool {
Pool Type = Backup
Recycle = yes # Bareos can automatically recycle Volumes
AutoPrune = yes # Prune expired volumes
Volume Retention = 365 days # How long should the Full Backups be kept? (#06)
Volume Retention = 1 sec # How long should the Full Backups be kept? (#06)
Maximum Volume Bytes = 50G # Limit Volume size to something reasonable
Maximum Volumes = 100 # Limit number of Volumes in Pool
Label Format = "Full-" # Volumes will be labeled "Full-<volume-id>"
Expand Down
Expand Up @@ -3,7 +3,7 @@ Pool {
Pool Type = Backup
Recycle = yes # Bareos can automatically recycle Volumes
AutoPrune = yes # Prune expired volumes
Volume Retention = 365 days # How long should the Full Backups be kept? (#06)
Volume Retention = 1 sec # How long should the Full Backups be kept? (#06)
Maximum Volume Bytes = 50G # Limit Volume size to something reasonable
Maximum Volumes = 100 # Limit number of Volumes in Pool
Label Format = "Full-" # Volumes will be labeled "Full-<volume-id>"
Expand Down
100 changes: 100 additions & 0 deletions systemtests/tests/copy/testrunner-05-migrate
@@ -0,0 +1,100 @@
#!/bin/bash
set -e
set -o pipefail
set -u

TestName=05-migrate

#shellcheck source=../environment.in
. ./environment

#shellcheck source=../scripts/functions
. "${rscripts}"/functions

log="$tmp/$TestName.log"

start_test

migration_volume="TestMigrateVolume001"
query_results="$tmp/query_results.out"

cat <<END_OF_DATA >"$tmp/bconcmds"
@$out /dev/null
messages
@$out $log
label volume=TestVolume002 storage=File pool=Full
run job=backup-bareos-fd level=Full yes
run job=backup-bareos-fd level=Full yes
run job=backup-bareos-fd level=Full yes
wait
update volume=TestVolume002 volstatus=Used
messages
label volume=$migration_volume storage=File2 pool=FullCopy
run migrate yes
wait
messages
@$out $query_results
sqlquery
SELECT count(jobid) FROM job WHERE type='g';
SELECT count(jobid) FROM job WHERE type='M';
quit
END_OF_DATA

run_bconsole

expect_grep "The following 3 JobIds were chosen to be migrated: 10,11,12" \
"$log" \
"Expected jobs to be migrated do not match."

# 1 administrative job that spawns 3 migration jobs
if [[ $(grep -c "Termination:.*Migration OK" "$log") -ne "4" ]]; then
echo "Not all migration jobs finished successfully."
estat=1
fi

if [[ $(grep -c "| 3 |" "$query_results") -ne "2" ]]; then
echo "The necessary amount of migration related jobs are not available in the catalog."
estat=2
fi

rm -f $query_results

cat <<END_OF_DATA >"$tmp/bconcmds"
@$out $query_results
prune volume=TestVolume002 yes
sqlquery
SELECT count(jobid) FROM job WHERE type='M';
quit
END_OF_DATA

run_bconsole

if ! grep "| 0 |" "$query_results" ; then
echo "Migrated jobs were not deleted appropriately after volume pruning."
estat=3
fi

rm -f $query_results

cat <<END_OF_DATA >"$tmp/bconcmds"
@$out $query_results
update volume=$migration_volume volstatus=Used
prune volume=$migration_volume yes
sqlquery
SELECT count(jobid) FROM job WHERE type='g';
quit
END_OF_DATA

run_bconsole

if ! grep "| 0 |" "$query_results" ; then
echo "Migration jobs were not deleted appropriately after volume pruning."
estat=4
fi



end_test

0 comments on commit 6e4d649

Please sign in to comment.