This repository has been archived by the owner on Mar 19, 2021. It is now read-only.
/
plugin-test
executable file
·159 lines (139 loc) · 3.24 KB
/
plugin-test
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/sh
#
# Attempt to backup and restore a file with the bpipe plugin
#
TestName="plugin-test"
JobName=pluginTest
. scripts/functions
scripts/cleanup
scripts/copy-plugin-confs
make -C $src/src/plugins/filed install-test-plugin
file=encrypt-bug.jpg
rm -rf ${cwd}/tmp/*
echo "${cwd}/README" >${cwd}/tmp/file-list
start_test
cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@$out /dev/null
messages
@$out ${cwd}/tmp/log1.out
label storage=File1 volume=TestVolume001
setdebug level=150 client=$CLIENT
estimate job=$JobName level=Full
setdebug level=50 client=$CLIENT
run job=$JobName storage=File1 yes
wait
status client=$CLIENT
messages
setdebug level=50 trace=1 client=$CLIENT
run job=TestPluginTest storage=File1 yes
wait
status client=$CLIENT
messages
setdebug level=50 trace=0 client=$CLIENT
quit
END_OF_DATA
run_bareos
cat <<END_OF_DATA >${cwd}/tmp/bconcmds
messages
@#
@# now do a restore
@#
@$out ${cwd}/tmp/log2.out
setdebug level=50 client=$CLIENT
restore fileset=pluginSet where=${cwd}/tmp select all storage=File1 done
yes
wait
setdebug level=0 client=$CLIENT
messages
quit
END_OF_DATA
run_bconsole
stop_bareos
# ****FIXME**** test if the restore of the two files is OK
#
# Remove plugin so we can try the restore without the plugin
#
mv -f ${cwd}/bin/plugins/bpipe-fd.so ${cwd}/bin/plugins/bpipe-fd.sox
cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@$out ${cwd}/tmp/log2.out
@# remove plugin
@exec "sh -c 'rm -f ${cwd}/bin/plugins/bpipe-fd.so'"
@#
@# now do a restore without the plugin
@#
@$out ${cwd}/tmp/log2.out
@#setdebug level=50 client=$CLIENT
restore fileset=pluginSet where=${cwd}/tmp select all storage=File1 done
yes
wait
messages
quit
END_OF_DATA
run_bareos -d50
run_bconsole
cat <<END_OF_DATA >${cwd}/tmp/bconcmds
messages
@#
@# now do a restore
@#
@$out ${cwd}/tmp/log3.out
setdebug level=50 client=$CLIENT trace=1
restore fileset=TestPluginSet where=${cwd}/tmp select all storage=File1 done
yes
wait
setdebug level=0 client=$CLIENT trace=0
messages
quit
END_OF_DATA
run_bconsole
check_for_zombie_jobs storage=File1
stop_bareos
#
# Restore plugin
#
mv -f ${cwd}/bin/plugins/bpipe-fd.sox ${cwd}/bin/plugins/bpipe-fd.so
check_two_logs
#
# ****FIXME**** test that all three files are restored correctly
#
diff ${cwd}/${file} ${cwd}/tmp/${file}
dstat=$?
# the test-plugin should create a RestoreObject, just check
# compare restore object before/after
perl -ne '
chomp();
if (/Creating RestoreObject/) {
@elt = split(/\s/, $_, 8);
$ro{$elt[6]}{clen} = $elt[4];
$ro{$elt[6]}{cdata} = $elt[7];
} elsif (/Get RestoreObject/) {
@elt = split(/\s/, $_, 10);
$ro{$elt[7]}{glen} = $elt[4];
$ro{$elt[7]}{gdata} = $elt[9];
}
END {
$err=0;
delete $ro{"oname=RestoreOptions"};
if (scalar(keys %ro) == 0) {
$err = 1;
print "ERROR: No restore object found\n";
}
foreach my $k (keys %ro) {
if ($ro{$k}{clen} ne $ro{$k}{glen}) {
print "ERROR: $k $ro{$k}{clen} != $ro{$k}{glen}\n";
$err++;
} else {
print "OK: $k $ro{$k}{clen} == $ro{$k}{glen}\n";
}
if ($ro{$k}{cdata} ne $ro{$k}{gdata}) {
print "ERROR: $k <$ro{$k}{cdata}> != <$ro{$k}{gdata}>\n";
$err++;
} else {
print "OK: $k $ro{$k}{gdata} == $ro{$k}{gdata}\n";
}
}
exit $err;
}
' working/*.trace
estat=$?
end_test