-
Notifications
You must be signed in to change notification settings - Fork 256
/
testrunner
executable file
·124 lines (91 loc) · 3.07 KB
/
testrunner
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
set -e
set -o pipefail
set -u
#
# This systemtest tests the mariadb plugin functionality
# of the Bareos FD by using the supplied module
# BareosFdPluginMariabackup.py
#
TestName="$(basename "$(pwd)")"
export TestName
#shellcheck source=../environment.in
. ./environment
#shellcheck source=../scripts/functions
. "${rscripts}"/functions
skip_if_root
JobName=backup-bareos-fd
MARIABACKUP="${MARIABACKUP_BINARY} --defaults-file=mysqldefaults"
mariabackup_test_db="${db_name}_mariabackup"
# override MYSQL_*_BINARY variables to be able to use mysql.sh
MYSQL_DAEMON_BINARY="${MARIADB_DAEMON_BINARY}"
MYSQL_CLIENT_BINARY="${MARIADB_CLIENT_BINARY}"
#shellcheck source=../scripts/mysql.sh
. "${rscripts}"/mysql.sh
"${rscripts}"/cleanup
"${rscripts}"/setup
start_test
mysql_init
mysql_server_start
echo "create database ${mariabackup_test_db}" | $MYSQL_CLIENT
echo "CREATE TABLE test ( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, data VARCHAR(100), created TIMESTAMP DEFAULT NOW()) " | $MYSQL_CLIENT "${mariabackup_test_db}"
echo "insert into test (data) VALUES ('test entry 1') " | $MYSQL_CLIENT "${mariabackup_test_db}"
cat <<END_OF_DATA >"$tmp/bconcmds"
@$out $tmp/log1.out
run job=$JobName yes
wait JobName=$JobName
status dir
run job=$JobName level=Incremental yes
wait JobName=$JobName
status dir
END_OF_DATA
# insert data and run incremental
echo "insert into test (data) VALUES ('test entry 2') " | $MYSQL_CLIENT "${mariabackup_test_db}"
run_bareos "$@"
cat <<END_OF_DATA2 >"$tmp/bconcmds"
@# run incremental again without any new data
run job=$JobName yes
wait JobName=$JobName
status dir
wait
messages
quit
END_OF_DATA2
run_bareos "$@"
cat <<END_OF_DATA3 >"$tmp/bconcmds"
restore client=bareos-fd fileset=MariaBackupTest yes restorejob=RestoreFile select all done
@$out $tmp/log2.out
wait
END_OF_DATA3
run_bareos "$@"
mysql_server_stop
# Check if mariabackup has extracted some files at least
# TODO: verify that mariabackup --prepare works and eventually do complete datbase restore
ls -lR "$tmp/bareos-restores/_mariabackup/"
if [ -z "$(ls -A "$tmp"/bareos-restores/_mariabackup/)" ]; then
echo "No restore data found"
estat=1
fi
# create new empty data dir
rm -Rf mysql/data/*
mkdir -p mysql/data/
TARGETDIR=$(find ./tmp/bareos-restores/_mariabackup/4/ -type d -name '*001')
INCDIR1=$(find ./tmp/bareos-restores/_mariabackup/4/ -type d -name '*002')
INCDIR2=$(find ./tmp/bareos-restores/_mariabackup/4/ -type d -name '*002')
${MARIABACKUP} --prepare --target-dir=${TARGETDIR}
# after prepare a file is left in data dir, this seems to be a bug
rm -Rf mysql/data/*
${MARIABACKUP} --copy-back --target-dir=${TARGETDIR} --incremental-dir=${INCDIR1} --incremental-dir=${INCDIR2}
mysql_server_start
if ! echo "SELECT * from test " | $MYSQL_CLIENT "${mariabackup_test_db}" | grep "test entry 1"; then
echo "test entry 1 not found"
estat=2
fi
if ! echo "SELECT * from test " | $MYSQL_CLIENT "${mariabackup_test_db}" | grep "test entry 2"; then
echo "test entry 2 not found"
estat=3
fi
check_for_zombie_jobs storage=File
mysql_server_stop
check_two_logs
end_test