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