]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/query-test
Updates
[bacula/bacula] / regress / tests / query-test
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory then create some           
4 #   new files, do a Differental then a bunch of query commands
5 #   and finally restore the two files.
6 #
7 debug=0
8 if test "$debug" -eq 1 ; then
9   out="tee"
10 else
11   out="output"
12 fi
13
14 cwd=`pwd`
15 scripts/copy-test-confs
16 scripts/cleanup
17 echo "${cwd}/tmp/build" >/tmp/file-list
18 mkdir ${cwd}/tmp/build
19 cp -p ${cwd}/build/src/dird/*.c ${cwd}/tmp/build
20 cd ${cwd}/tmp
21 echo "${cwd}/tmp/build/ficheriro1.txt" >restore-list
22 echo "${cwd}/tmp/build/ficheriro2.txt" >>restore-list
23 cd ${cwd}
24
25 echo " "
26 echo " "
27 echo " === Starting query-test at `date +%R:%S` ==="
28 echo " === Starting query-test at `date +%R:%S` ===" >>working/log
29 echo " "
30
31 bin/bacula start 2>&1 >/dev/null
32 cat <<END_OF_DATA >tmp/bconcmds
33 @output /dev/null
34 messages
35 @$out tmp/log1.out
36 label storage=File volume=TestVolume001
37 label storage=File volume=TestVolume002
38 run job=CompressedTest yes
39 wait
40 messages
41 quit
42 END_OF_DATA
43 if test "$debug" -eq 1 ; then
44   bin/bacula start
45   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
46 else
47   bin/bacula start 2>&1 >/dev/null
48   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
49 fi
50 scripts/check_for_zombie_jobs storage=File
51 echo "ficheriro1.txt" >${cwd}/tmp/build/ficheriro1.txt
52 echo "ficheriro2.txt" >${cwd}/tmp/build/ficheriro2.txt
53 cat <<END_OF_DATA >tmp/bconcmds
54 @output /dev/null
55 messages
56 @$out tmp/log1.out
57 @# Force differental on the second Volume
58 update volume=TestVolume001 VolStatus=Used
59 run level=differental job=CompressedTest yes
60 wait
61 messages
62 @output
63 END_OF_DATA
64 if test "$debug" -eq 1 ; then
65   bin/bacula start
66   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
67 else
68   bin/bacula start 2>&1 >/dev/null
69   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
70 fi
71 scripts/check_for_zombie_jobs storage=File
72 echo "ficheriro2.txt" >${cwd}/tmp/build/ficheriro2.txt
73 cat <<END_OF_DATA >tmp/bconcmds
74 @output /dev/null
75 messages
76 @$out tmp/log1.out
77 run level=incremental job=CompressedTest yes
78 wait
79 messages
80 @#
81 @# Now do the queries
82 @#
83 query
84 1
85 ficheriro1.txt
86 query
87 2
88 ${cwd}/tmp/build/
89 ficheriro1.txt
90 localhost-fd
91 query
92 6
93 TestVolume001
94 query
95 7
96 1
97 query
98 8
99 localhost-fd
100 query
101 9
102 Default
103 query
104 10
105 query
106 11
107 query
108 12
109 1
110 @# 
111 @# now do a restore
112 @#
113 @$out tmp/log2.out
114 restore where=${cwd}/tmp/bacula-restores storage=File file=<${cwd}/tmp/restore-list
115 yes
116 wait
117 messages
118 @output
119 quit
120 END_OF_DATA
121 if test "$debug" -eq 1 ; then
122   bin/bacula start
123   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
124 else
125   bin/bacula start 2>&1 >/dev/null
126   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
127 fi
128 scripts/check_for_zombie_jobs storage=File
129 bin/bacula stop 2>&1 >/dev/null
130 grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
131 bstat=$?
132 grep "^  Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
133 rstat=$?
134 #
135 # Delete .c files because we will only restored the txt files
136 #
137 rm -f tmp/build/*.c
138 diff -r tmp/build tmp/bacula-restores${cwd}/tmp/build 2>&1 >/dev/null
139 if [ $? != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
140    echo " "
141    echo " "
142    echo "  !!!!! query-test Bacula source failed!!! !!!!! "
143    echo "  !!!!! query-test failed!!! !!!!! " >>test.out
144    if [ $bstat != 0 -o $rstat != 0 ] ; then
145       echo "  !!!!! Bad Job termination status     !!!!! "
146       echo "  !!!!! Bad Job termination status     !!!!! " >>test.out
147    else
148       echo "  !!!!! Restored files differ          !!!!! "
149       echo "  !!!!! Restored files differ          !!!!! " >>test.out
150    fi
151    echo " "
152 else
153    echo "  ===== query-test Bacula source OK `date +%R:%S` ===== "
154    echo "  ===== query-test OK `date +%R:%S` ===== " >>test.out
155    scripts/cleanup
156 fi