Imported Upstream version 3.3.3
[debian/amanda] / installcheck / amoverview.pl
1 # Copyright (c) 2007-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::Config;
26 use Installcheck::Dumpcache;
27 use Installcheck::Catalogs;
28 use Installcheck::Run qw(run run_get run_err $diskname);
29 use Amanda::Paths;
30 use Amanda::Debug;
31
32 Amanda::Debug::dbopen("installcheck");
33
34 ##
35 # First, try amoverview without a config
36
37 ok(!run('amoverview'),
38     "amoverview with no arguments returns an error exit status");
39 like($Installcheck::Run::stderr, qr/\AUSAGE:/i,
40     ".. and gives usage message on stderr");
41
42 ##
43 # Now try it against a cached dump
44
45 Installcheck::Dumpcache::load("multi");
46
47 like(run_get('amoverview', 'TESTCONF'),
48     # this pattern is pretty loose, but that's OK
49     qr{
50         \s+date\s+\d\d\s+
51         host\s+disk\s+\d\d\s+
52         localhos\s+/.*\s+00\s+
53         localhos\s+/.*\s+01
54     }mxs,
55     "amoverview of the 'multi' dump looks good");
56
57 Installcheck::Run::cleanup();
58
59 ##
60 # And some cached catalogs
61
62 my $testconf = Installcheck::Run::setup();
63 $testconf->write();
64
65 my $cat = Installcheck::Catalogs::load("bigdb");
66 $cat->install();
67
68 like(run_get('amoverview', 'TESTCONF', '--skipmissed'),
69     qr{
70 \s*              date      \s+ 01\s+02\s+03\s+03\s+04\s+05\s+05\s+06\s+07 \s+
71 \s*  host \s+    disk      \s+ 11\s+22\s+11\s+13\s+14\s+11\s+15\s+16\s+22 \s+
72 \s*
73 \s*  lovelace\s+ /home/ada \s+  -\s+ -\s+ -\s+ -\s+ -\s+ -\s+ -\s+ -\s+ 3 \s+
74 \s*  otherbox\s+ /direct   \s+  -\s+ -\s+ -\s+ -\s+ -\s+ -\s+ 0\s+ -\s+ - \s+
75 \s*  otherbox\s+ /lib      \s+  -\s+ -\s+ -\s+ 0\s+1E\s+ 0\s+ -\s+ -\s+ - \s+
76 \s*  otherbox\s+ /usr/bin  \s+  -\s+ -\s+00\s+ -\s+ -\s+ 0\s+ -\s+ -\s+ - \s+
77 \s*  somebox \s+ /lib      \s+  0\s+ 0\s+ -\s+ 0\s+ -\s+ -\s+ 0\s+ E\s+ - \s+
78 \s*  somebox \s+ /usr/bin  \s+  -\s+ -\s+ -\s+ 1\s+ -\s+ -\s+ 1\s+ 1\s+ -
79     }mxs,
80     "amoverview of the bigdb catalog looks right");