]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/plugin-test
e2604920c24e9ed41545051258ba91ca8153ae19
[bacula/bacula] / regress / tests / plugin-test
1 #!/bin/sh
2 #
3 # Attempt to backup and restore a file with the bpipe plugin
4 #
5 TestName="plugin-test"
6 JobName=pluginTest
7 . scripts/functions
8
9 scripts/cleanup
10 scripts/copy-plugin-confs
11 make -C $src/src/plugins/fd install-test-plugin
12
13 file=encrypt-bug.jpg
14 rm -rf ${cwd}/tmp/*
15 echo "${cwd}/README" >${cwd}/tmp/file-list
16
17 start_test
18
19 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
20 @$out /dev/null
21 messages
22 @$out ${cwd}/tmp/log1.out
23 label storage=File1 volume=TestVolume001
24 setdebug level=150 client=$CLIENT
25 estimate job=$JobName level=Full
26 setdebug level=50 client=$CLIENT
27 run job=$JobName storage=File1 yes
28 wait
29 status client=$CLIENT
30 messages
31 setdebug level=50 trace=1 client=$CLIENT
32 run job=TestPluginTest storage=File1 yes
33 wait
34 status client=$CLIENT
35 messages
36 setdebug level=50 trace=0 client=$CLIENT
37 quit
38 END_OF_DATA
39
40
41 run_bacula
42
43 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
44 messages
45 @# 
46 @# now do a restore
47 @#
48 @$out ${cwd}/tmp/log2.out
49 setdebug level=50 client=$CLIENT
50 restore fileset=pluginSet where=${cwd}/tmp  select all storage=File1 done
51 yes
52 wait
53 setdebug level=0 client=$CLIENT
54 messages
55 quit
56 END_OF_DATA
57
58 run_bconsole
59
60 stop_bacula
61
62 # ****FIXME**** test if the restore of the two files is OK
63
64 #
65 # Remove plugin so we can try the restore without the plugin
66 #
67 mv -f ${cwd}/bin/plugins/bpipe-fd.so ${cwd}/bin/plugins/bpipe-fd.sox
68
69 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
70 @$out ${cwd}/tmp/log2.out
71 @# remove plugin
72 @exec "sh -c 'rm -f ${cwd}/bin/plugins/bpipe-fd.so'"
73 @# 
74 @# now do a restore without the plugin
75 @#
76 @$out ${cwd}/tmp/log2.out
77 @#setdebug level=50 client=$CLIENT
78 restore fileset=pluginSet where=${cwd}/tmp  select all storage=File1 done
79 yes
80 wait
81 messages
82 quit
83 END_OF_DATA
84
85 run_bacula -d50
86 run_bconsole
87
88 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
89 messages
90 @# 
91 @# now do a restore
92 @#
93 @$out ${cwd}/tmp/log3.out
94 setdebug level=50 client=$CLIENT trace=1
95 restore fileset=TestPluginSet where=${cwd}/tmp  select all storage=File1 done
96 yes
97 wait
98 setdebug level=0 client=$CLIENT trace=0
99 messages
100 quit
101 END_OF_DATA
102
103 run_bconsole
104
105 check_for_zombie_jobs storage=File1
106 stop_bacula
107 #
108 # Restore plugin
109 #
110 mv -f ${cwd}/bin/plugins/bpipe-fd.sox ${cwd}/bin/plugins/bpipe-fd.so
111
112 check_two_logs
113 #
114 # ****FIXME**** test that all three files are restored correctly
115 #
116 diff ${cwd}/${file} ${cwd}/tmp/${file}
117 dstat=$?
118
119 # the test-plugin should create a RestoreObject, just check 
120 # compare restore object before/after
121 perl -ne '
122  chomp();
123  if (/Creating RestoreObject/) {
124    @elt = split(/\s/, $_, 7);
125    $clen = $elt[4];
126    $cdata = $elt[6];
127    $cname = $elt[5];
128  } elsif (/Get RestoreObject/) {
129    @elt = split(/\s/, $_, 8);
130    $glen = $elt[4];
131    $gdata = $elt[7];
132    $gname = $elt[6];
133  }
134  END {
135    $err=0;
136    if ($clen ne $glen) {
137      print "ERROR: $clen != $glen\n";
138      $err++;
139    }
140    if ($cdata ne $gdata) {
141      print "ERROR: <$cdata> != <$gdata>\n";
142      $err++;
143    }
144    if ($cname ne $gname) {
145      print "ERROR: $cname != $gname\n";
146      $err++;
147    }
148    exit $err;
149  }
150 ' working/*.trace
151
152 estat=$?
153
154 end_test