1 # Copyright (c) 2010-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 => 4;
24 use lib "@amperldir@";
28 use Installcheck::Config;
29 use Installcheck::Run qw(run run_err $diskname);
34 Amanda::Debug::dbopen("installcheck");
39 # write a fake holding file to holding disk, for amflush to flush
40 sub write_holding_file {
41 my ($host, $disk) = @_;
43 my $datestamp = "20100102030405";
44 my $filename = "$Installcheck::Run::holdingdir/$datestamp/$host-somefile";
46 my $hdr = Amanda::Header->new();
47 $hdr->{'type'} = $Amanda::Header::F_DUMPFILE;
48 $hdr->{'datestamp'} = $datestamp;
49 $hdr->{'dumplevel'} = 0;
50 $hdr->{'name'} = $host;
51 $hdr->{'disk'} = $disk;
52 $hdr->{'program'} = "INSTALLCHECK";
54 mkpath($Installcheck::Run::holdingdir);
55 mkpath("$Installcheck::Run::holdingdir/$datestamp");
56 open(my $fh, ">", $filename) or die("opening '$filename': $!");
57 print $fh $hdr->to_string(32768,32768);
58 print $fh "some data!\n";
62 Installcheck::Run::cleanup();
63 $testconf = Installcheck::Run::setup();
64 $testconf->add_param("autolabel", '"TESTCONF%%" any');
65 $testconf->add_dle("localhost $diskname installcheck-test");
68 # add a holding file that's in the disklist
69 write_holding_file("localhost", $Installcheck::Run::diskname);
71 ok(run("$sbindir/amflush", '-f', '-b', 'TESTCONF'),
72 "amflush runs successfully")
73 or diag($Installcheck::Run::stderr);
75 # check that there's a vtape file where we expect to see one
76 $vtape_dir = Installcheck::Run::vtape_dir(1);
77 ok(<$vtape_dir/00001.*>, "..and dump appears on vtapes");
79 Installcheck::Run::cleanup();
80 $testconf = Installcheck::Run::setup();
81 $testconf->add_param("autolabel", '"TESTCONF%%" any');
82 # don't add anything to the disklist; it should still flush it
85 # add a holding file that's not in the disklist
86 write_holding_file("localhost", $Installcheck::Run::diskname);
88 ok(run("$sbindir/amflush", '-f', '-b', 'TESTCONF'),
89 "amflush runs successfully")
90 or diag($Installcheck::Run::stderr);
92 # check that there's a vtape file where we expect to see one
93 $vtape_dir = Installcheck::Run::vtape_dir(1);
94 ok(<$vtape_dir/00001.*>, "..and dump appears on vtapes");
96 #Installcheck::Run::cleanup();