b685eba7d35c0fd36d3e3e0ef096cb37a2860238
[debian/amanda] / installcheck / amdump.pl
1 # Copyright (c) 2008 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
21 use lib "@amperldir@";
22 use Installcheck::Dumpcache;
23 use Installcheck::Config;
24 use Installcheck::Run qw(run run_err $diskname amdump_diag);
25 use Amanda::Config qw( :init );
26 use Amanda::Paths;
27
28 my $testconf;
29
30 # Just run amdump.
31
32 $testconf = Installcheck::Run::setup();
33 $testconf->add_param('autolabel', '"TESTCONF%%" empty volume_error');
34
35 # one program "GNUTAR"
36 $testconf->add_dle(<<EODLE);
37 localhost diskname1 $diskname {
38     installcheck-test
39     program "GNUTAR"
40 }
41 EODLE
42
43 # and one with the amgtar application
44 $testconf->add_dle(<<EODLE);
45 localhost diskname2 $diskname {
46     installcheck-test
47     program "APPLICATION"
48     application {
49         plugin "amgtar"
50         property "ATIME-PRESERVE" "NO"
51     }
52 }
53 EODLE
54 $testconf->write();
55
56 ok(run('amdump', 'TESTCONF'), "amdump runs successfully")
57     or amdump_diag();
58
59 # Dump a nonexistant client, and see amdump fail.
60 $testconf = Installcheck::Run::setup();
61 $testconf->add_dle('does-not-exist.example.com / installcheck-test');
62 $testconf->write();
63
64 ok(!run('amdump', 'TESTCONF'), "amdump fails with nonexistent client");
65
66 #check failure in validate_optstr.
67 $testconf = Installcheck::Run::setup();
68 $testconf->add_dle(<<EODLE);
69 localhost diskname2 $diskname {
70     installcheck-test
71     program "APPLICATION"
72     application {
73         plugin "amgtar"
74         property "ATIME-PRESERVE" "NO"
75     }
76     compress client custom
77 }
78 EODLE
79 $testconf->write();
80
81 ok(!run("$amlibexecdir/planner", 'TESTCONF'), "amdump fails in validate_optstr");
82 open(my $logfile, "<", "$CONFIG_DIR/TESTCONF/log/log")
83         or die("opening log: $!");
84 my $logline = grep(/^\S+ planner localhost diskname2 \d* 0 \[client custom compression with no compression program specified\]/, <$logfile>);
85 ok($logline, "planner fail without 'client custom compression with no compression program specified'");
86
87 Installcheck::Run::cleanup();