3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
8 # Attempt to backup and restore a file with the bpipe plugin
10 TestName="plugin-test"
15 scripts/copy-plugin-confs
16 make -C $src/src/plugins/fd install-test-plugin
20 echo "${cwd}/README" >${cwd}/tmp/file-list
24 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
27 @$out ${cwd}/tmp/log1.out
28 label storage=File1 volume=TestVolume001
29 setdebug level=150 client=$CLIENT
30 estimate job=$JobName level=Full
31 setdebug level=50 client=$CLIENT
32 run job=$JobName storage=File1 yes
36 setdebug level=50 trace=1 client=$CLIENT
37 run job=TestPluginTest storage=File1 yes
39 run job=$JobName fileset=TestPluginSetAcceptFile1 storage=File1 yes
43 setdebug level=50 trace=0 client=$CLIENT
50 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
52 llist pluginrestoreconf jobid=2
54 llist pluginrestoreconf jobid=2 id=2
59 grep string1 $tmp/conf
63 string2="My other string"
67 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
72 @$out ${cwd}/tmp/log2.out
73 setdebug level=50 client=$CLIENT
74 restore fileset=pluginSet where=${cwd}/tmp select all storage=File1 done
77 setdebug level=0 client=$CLIENT
86 # ****FIXME**** test if the restore of the two files is OK
89 # Remove plugin so we can try the restore without the plugin
91 mv -f ${cwd}/bin/plugins/bpipe-fd.so ${cwd}/bin/plugins/bpipe-fd.sox
93 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
94 @$out ${cwd}/tmp/log2.out
96 @exec "sh -c 'rm -f ${cwd}/bin/plugins/bpipe-fd.so'"
98 @# now do a restore without the plugin
100 @$out ${cwd}/tmp/log2.out
101 @#setdebug level=50 client=$CLIENT
102 restore fileset=pluginSet where=${cwd}/tmp select all storage=File1 done
112 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
117 @$out ${cwd}/tmp/log3.out
118 setdebug level=50 client=$CLIENT trace=1
119 @putfile obj1 $tmp/obj
120 restore pluginrestoreconf="2:obj1" fileset=TestPluginSet where=${cwd}/tmp select all storage=File1 done
123 setdebug level=0 client=$CLIENT trace=0
130 grep "My other string" $working/*trace > /dev/null
132 print_debug "ERROR: Should find plugin restore conf"
136 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
141 @$out ${cwd}/tmp/log3.out
142 setdebug level=50 client=$CLIENT trace=1
143 restore fileset=TestPluginSet where=${cwd}/tmp select all storage=File1 done
152 setdebug level=0 client=$CLIENT trace=0
159 grep "My new string" $working/*trace > /dev/null
161 print_debug "ERROR: Should find second plugin restore conf"
165 check_for_zombie_jobs storage=File1
170 mv -f ${cwd}/bin/plugins/bpipe-fd.sox ${cwd}/bin/plugins/bpipe-fd.so
174 # ****FIXME**** test that all three files are restored correctly
176 diff ${cwd}/${file} ${cwd}/tmp/${file}
179 diff $working/restore.0 $working/torestore.0
181 print_debug "ERROR: Restore object difference found"
185 # Look if bRC_OK = 0, bRC_Skip = 7
186 grep "AcceptFile=takeme.h = 0" $working/*trace > /dev/null
188 print_debug "ERROR: AcceptFile API problem, look at takeme.h"
192 grep "excludeme.o = 7" $working/*trace > /dev/null
194 print_debug "ERROR: AcceptFile API problem, look at excludeme.o"
198 grep "excludeme.c = 7" $working/*trace > /dev/null
200 print_debug "ERROR: AcceptFile API problem, look at excludeme.c"
205 # the test-plugin should create a RestoreObject, just check
206 # compare restore object before/after
209 if (/Creating RestoreObject/) {
210 @elt = split(/\s/, $_, 7);
211 $ro{$elt[5]}{clen} = $elt[4];
212 $ro{$elt[5]}{cdata} = $elt[6];
213 } elsif (/Get RestoreObject/) {
214 @elt = split(/\s/, $_, 9);
215 $ro{$elt[6]}{glen} = $elt[4];
216 $ro{$elt[6]}{gdata} = $elt[8];
220 delete $ro{"oname=RestoreOptions"};
221 if (scalar(keys %ro) == 0) {
223 print "ERROR: No restore object found\n";
225 foreach my $k (keys %ro) {
226 if ($ro{$k}{clen} ne $ro{$k}{glen}) {
227 print "ERROR: $k $ro{$k}{clen} != $ro{$k}{glen}\n";
230 print "OK: $k $ro{$k}{clen} == $ro{$k}{glen}\n";
232 if ($ro{$k}{cdata} ne $ro{$k}{gdata}) {
233 print "ERROR: $k <$ro{$k}{cdata}> != <$ro{$k}{gdata}>\n";
236 print "OK: $k $ro{$k}{gdata} == $ro{$k}{gdata}\n";