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