1 # Copyright (c) 2008, 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 => 13;
23 use lib "@amperldir@";
24 use Amanda::Config qw( :init :getconf );
26 use Installcheck::Config;
30 $testconf = Installcheck::Config->new();
31 $testconf->add_dumptype("mytype", [
32 "compress" => "server",
33 "starttime" => "1830",
34 "amandad_path" => "\"/path/to/amandad\"",
36 $testconf->add_interface("eth1", []);
37 $testconf->add_dle("otherbox /home mytype");
38 $testconf->add_dle("otherbox /disk1 mytype");
39 $testconf->add_dle("otherbox /disk2 mytype");
40 $testconf->add_dle(<<EOF);
47 if (config_init($CONFIG_INIT_EXPLICIT_NAME, "TESTCONF") != $CFGERR_OK) {
48 config_print_errors();
52 is(Amanda::Disklist::read_disklist(), $CFGERR_OK,
53 "read_disklist returns CFGERR_OK")
54 or die("Error loading disklist");
58 $x = Amanda::Disklist::get_host("otherbox");
59 ok($x, "get_host returns a host");
60 is($x->{'auth'}, 'BSD', "..host has correct auth");
61 is_deeply([ sort @{$x->{'disks'}} ],
62 [ sort "/disk1", "/disk2", "/home" ],
64 is(interface_name($x->{'interface'}->{'config'}), "default", "..and correct interface");
66 $d = $x->get_disk("/home");
67 is($d->{'name'}, "/home", "host->get_disk() works");
69 @list = $x->all_disks();
70 is_deeply([ sort map { $_->{'name'} } @list ],
71 [ sort "/disk1", "/disk2", "/home" ],
72 "host->all_disks returns all disk objects");
74 @list = Amanda::Disklist::all_hosts();
75 is_deeply([ sort( map { $_->{'hostname'} } @list ) ],
76 [ sort qw(myhost otherbox) ],
77 "all_hosts returns correct hosts");
79 $x = Amanda::Disklist::get_disk("myhost", "/mydisk");
80 ok($x, "get_disk returns a disk");
81 is($x->{'name'}, "/mydisk", "..and it's the right one");
83 @list = Amanda::Disklist::all_disks();
84 is(scalar @list, 4, "all_lists returns 4 disks");
86 $x = Amanda::Disklist::get_interface("eth1");
87 is(interface_name($x->{'config'}), "eth1", "get_interface returns an interface");
89 @list = Amanda::Disklist::all_interfaces();
90 is(scalar @list, 2, "all_interfaces returns two interfaces");