1 # Copyright (c) 2008-2012 Zmanda, Inc. All Rights Reserved.
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # You should have received a copy of the GNU General Public License along
14 # with this program; if not, write to the Free Software Foundation, Inc.,
15 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
18 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
20 use Test::More tests => 10;
22 use lib "@amperldir@";
23 use Cwd qw(abs_path getcwd);
25 use Installcheck::Dumpcache;
26 use Installcheck::Config;
27 use Installcheck::Run qw(run run_err $diskname amdump_diag);
28 use Amanda::Config qw( :init );
35 # Run amdump with client- and server-side scripts
37 my $templog = $Installcheck::TMP . "/check-script." . $$;
45 if (!open($logfile, "<", $templog)) {
47 diag("Logfile '$templog' does not exist.");
58 diag(" Line: $linenum");
59 diag("Expected: '$exp'");
67 diag(" Line: $linenum");
68 diag("Expected: '$exp'");
77 diag(" Line: $linenum");
78 diag("Expected: EOF");
86 # check script on client
88 $testconf = Installcheck::Run::setup();
89 $testconf->add_param('autolabel', '"TESTCONF%%" empty volume_error');
91 $testconf->add_dle(<<EODLE);
92 localhost diskname1 $diskname {
97 property "atime_preserve" "no" # note underscore
100 plugin "amlog-script"
102 execute-on pre-dle-amcheck, post-dle-amcheck, pre-dle-estimate, post-dle-estimate, pre-dle-backup, post-dle-backup
103 property "logfile" "$templog"
110 ok(run('amcheck', '-c', 'TESTCONF'), "amcheck runs successfully for client scripts.");
112 verify_log("amcheck invokes correct script commands",
113 "check TESTCONF pre-dle-amcheck client localhost diskname1 $diskname",
114 "check TESTCONF post-dle-amcheck client localhost diskname1 $diskname",
118 ok(run('amdump', 'TESTCONF'), "amdump runs successfully for client scripts.")
121 verify_log("amdump invokes correct script commands",
122 "estimate TESTCONF pre-dle-estimate client localhost diskname1 $diskname 0",
123 "estimate TESTCONF post-dle-estimate client localhost diskname1 $diskname 0",
124 "backup TESTCONF pre-dle-backup client localhost diskname1 $diskname 0",
125 "backup TESTCONF post-dle-backup client localhost diskname1 $diskname 0",
128 Installcheck::Run::cleanup();
130 #check script on server
131 $testconf = Installcheck::Run::setup();
132 $testconf->add_param('autolabel', '"TESTCONF%%" empty volume_error');
134 $testconf->add_dle(<<EODLE);
135 localhost diskname2 $diskname {
137 program "APPLICATION"
140 property "atime-preserve" "no"
143 plugin "amlog-script"
146 execute-on pre-host-amcheck, post-host-amcheck, pre-host-estimate, post-host-estimate, pre-host-backup, post-host-backup
147 property "logfile" "$templog"
151 $testconf->add_dle(<<EODLE);
152 localhost diskname3 $diskname {
154 program "APPLICATION"
157 property "atime-preserve" "no"
160 plugin "amlog-script"
163 execute-on pre-host-amcheck, post-host-amcheck, pre-host-estimate, post-host-estimate, pre-host-backup, post-host-backup
164 property "logfile" "$templog"
171 ok(run('amcheck', '-c', 'TESTCONF'), "amcheck runs successfully for server scripts.");
173 verify_log("amcheck invokes correct script commands",
174 "check TESTCONF pre-host-amcheck server localhost diskname3 $diskname",
175 "check TESTCONF post-host-amcheck server localhost diskname3 $diskname",
179 ok(run('amdump', 'TESTCONF'), "amdump runs successfully for server scripts.")
182 verify_log("amdump invokes correct script commands",
183 "estimate TESTCONF pre-host-estimate server localhost diskname3 $diskname",
184 "estimate TESTCONF post-host-estimate server localhost diskname3 $diskname",
185 "backup TESTCONF pre-host-backup server localhost diskname3 $diskname",
186 "backup TESTCONF post-host-backup server localhost diskname3 $diskname",
190 Installcheck::Run::cleanup();
193 $testconf = Installcheck::Run::setup();
194 $testconf->add_param('autolabel', '"TESTCONF%%" empty volume_error');
196 $testconf->add_dle(<<EODLE);
197 localhost diskname2 $diskname {
199 program "APPLICATION"
202 property "atime-preserve" "no"
205 plugin "amlog-script"
207 execute-on pre-host-amcheck
208 property "logfile" "$templog"
213 plugin "amlog-script"
215 execute-on pre-host-amcheck
216 property "logfile" "$templog"
221 plugin "amlog-script"
223 execute-on pre-host-amcheck
224 property "logfile" "$templog"
233 ok(run('amcheck', '-c', 'TESTCONF'), "amcheck runs successfully for ordered scripts.");
235 verify_log("amcheck invokes script in correct order",
236 "check TESTCONF pre-host-amcheck client localhost diskname2 $diskname 40",
237 "check TESTCONF pre-host-amcheck client localhost diskname2 $diskname 50",
238 "check TESTCONF pre-host-amcheck client localhost diskname2 $diskname 60",
243 Installcheck::Run::cleanup();