Imported Upstream version 3.2.0
[debian/amanda] / installcheck / amdump.pl
1 # Copyright (c) 2008, 2010 Zmanda, Inc.  All Rights Reserved.
2 #
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.
6 #
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
10 # for more details.
11 #
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
15 #
16 # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
17 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
18
19 use Test::More tests => 4;
20 use strict;
21 use warnings;
22
23 use lib "@amperldir@";
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 );
28 use Amanda::Paths;
29
30 my $testconf;
31
32 # Just run amdump.
33
34 $testconf = Installcheck::Run::setup();
35 $testconf->add_param('autolabel', '"TESTCONF%%" empty volume_error');
36
37 # one program "GNUTAR"
38 $testconf->add_dle(<<EODLE);
39 localhost diskname1 $diskname {
40     installcheck-test
41     program "GNUTAR"
42 }
43 EODLE
44
45 # and one with the amgtar application
46 $testconf->add_dle(<<EODLE);
47 localhost diskname2 $diskname {
48     installcheck-test
49     program "APPLICATION"
50     application {
51         plugin "amgtar"
52         property "ATIME-PRESERVE" "NO"
53     }
54 }
55 EODLE
56 $testconf->write();
57
58 ok(run('amdump', 'TESTCONF'), "amdump runs successfully")
59     or amdump_diag();
60
61 # Dump a nonexistant client, and see amdump fail.
62 $testconf = Installcheck::Run::setup();
63 $testconf->add_dle('does-not-exist.example.com / installcheck-test');
64 $testconf->write();
65
66 ok(!run('amdump', 'TESTCONF'), "amdump fails with nonexistent client");
67
68 #check failure in validate_optstr.
69 $testconf = Installcheck::Run::setup();
70 $testconf->add_dle(<<EODLE);
71 localhost diskname2 $diskname {
72     installcheck-test
73     program "APPLICATION"
74     application {
75         plugin "amgtar"
76         property "ATIME-PRESERVE" "NO"
77     }
78     compress client custom
79 }
80 EODLE
81 $testconf->write();
82
83 ok(!run("$amlibexecdir/planner", 'TESTCONF'), "amdump fails in validate_optstr");
84 open(my $logfile, "<", "$CONFIG_DIR/TESTCONF/log/log")
85         or die("opening log: $!");
86 my $logline = grep(/^\S+ planner localhost diskname2 \d* 0 \[client custom compression with no compression program specified\]/, <$logfile>);
87 ok($logline, "planner fail without 'client custom compression with no compression program specified'");
88
89 Installcheck::Run::cleanup();