1 # Copyright (c) 2008-2012 Zmanda, Inc. All Rights Reserved.
3 # This program is free software; you can redistribute it and/or modify it
4 # under the terms of the GNU General Public License version 2 as published
5 # by the Free Software Foundation.
7 # This program is distributed in the hope that it will be useful, but
8 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 # You should have received a copy of the GNU General Public License along
13 # with this program; if not, write to the Free Software Foundation, Inc.,
14 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
17 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
19 use Test::More tests => 10;
21 use lib "@amperldir@";
22 use Cwd qw(abs_path getcwd);
24 use Installcheck::Dumpcache;
25 use Installcheck::Config;
26 use Installcheck::Run qw(run run_err $diskname amdump_diag);
27 use Amanda::Config qw( :init );
34 # Run amdump with client- and server-side scripts
36 my $templog = $Installcheck::TMP . "/check-script." . $$;
44 if (!open($logfile, "<", $templog)) {
46 diag("Logfile '$templog' does not exist.");
57 diag(" Line: $linenum");
58 diag("Expected: '$exp'");
66 diag(" Line: $linenum");
67 diag("Expected: '$exp'");
76 diag(" Line: $linenum");
77 diag("Expected: EOF");
85 # check script on client
87 $testconf = Installcheck::Run::setup();
88 $testconf->add_param('autolabel', '"TESTCONF%%" empty volume_error');
90 $testconf->add_dle(<<EODLE);
91 localhost diskname1 $diskname {
96 property "atime_preserve" "no" # note underscore
101 execute-on pre-dle-amcheck, post-dle-amcheck, pre-dle-estimate, post-dle-estimate, pre-dle-backup, post-dle-backup
102 property "logfile" "$templog"
109 ok(run('amcheck', '-c', 'TESTCONF'), "amcheck runs successfully for client scripts.");
111 verify_log("amcheck invokes correct script commands",
112 "check TESTCONF pre-dle-amcheck client localhost diskname1 $diskname",
113 "check TESTCONF post-dle-amcheck client localhost diskname1 $diskname",
117 ok(run('amdump', 'TESTCONF'), "amdump runs successfully for client scripts.")
120 verify_log("amdump invokes correct script commands",
121 "estimate TESTCONF pre-dle-estimate client localhost diskname1 $diskname 0",
122 "estimate TESTCONF post-dle-estimate client localhost diskname1 $diskname 0",
123 "backup TESTCONF pre-dle-backup client localhost diskname1 $diskname 0",
124 "backup TESTCONF post-dle-backup client localhost diskname1 $diskname 0",
127 Installcheck::Run::cleanup();
129 #check script on server
130 $testconf = Installcheck::Run::setup();
131 $testconf->add_param('autolabel', '"TESTCONF%%" empty volume_error');
133 $testconf->add_dle(<<EODLE);
134 localhost diskname2 $diskname {
136 program "APPLICATION"
139 property "atime-preserve" "no"
142 plugin "amlog-script"
145 execute-on pre-host-amcheck, post-host-amcheck, pre-host-estimate, post-host-estimate, pre-host-backup, post-host-backup
146 property "logfile" "$templog"
150 $testconf->add_dle(<<EODLE);
151 localhost diskname3 $diskname {
153 program "APPLICATION"
156 property "atime-preserve" "no"
159 plugin "amlog-script"
162 execute-on pre-host-amcheck, post-host-amcheck, pre-host-estimate, post-host-estimate, pre-host-backup, post-host-backup
163 property "logfile" "$templog"
170 ok(run('amcheck', '-c', 'TESTCONF'), "amcheck runs successfully for server scripts.");
172 verify_log("amcheck invokes correct script commands",
173 "check TESTCONF pre-host-amcheck server localhost diskname3 $diskname",
174 "check TESTCONF post-host-amcheck server localhost diskname3 $diskname",
178 ok(run('amdump', 'TESTCONF'), "amdump runs successfully for server scripts.")
181 verify_log("amdump invokes correct script commands",
182 "estimate TESTCONF pre-host-estimate server localhost diskname3 $diskname",
183 "estimate TESTCONF post-host-estimate server localhost diskname3 $diskname",
184 "backup TESTCONF pre-host-backup server localhost diskname3 $diskname",
185 "backup TESTCONF post-host-backup server localhost diskname3 $diskname",
189 Installcheck::Run::cleanup();
192 $testconf = Installcheck::Run::setup();
193 $testconf->add_param('autolabel', '"TESTCONF%%" empty volume_error');
195 $testconf->add_dle(<<EODLE);
196 localhost diskname2 $diskname {
198 program "APPLICATION"
201 property "atime-preserve" "no"
204 plugin "amlog-script"
206 execute-on pre-host-amcheck
207 property "logfile" "$templog"
212 plugin "amlog-script"
214 execute-on pre-host-amcheck
215 property "logfile" "$templog"
220 plugin "amlog-script"
222 execute-on pre-host-amcheck
223 property "logfile" "$templog"
232 ok(run('amcheck', '-c', 'TESTCONF'), "amcheck runs successfully for ordered scripts.");
234 verify_log("amcheck invokes script in correct order",
235 "check TESTCONF pre-host-amcheck client localhost diskname2 $diskname 40",
236 "check TESTCONF pre-host-amcheck client localhost diskname2 $diskname 50",
237 "check TESTCONF pre-host-amcheck client localhost diskname2 $diskname 60",
242 Installcheck::Run::cleanup();