Imported Upstream version 3.3.3
[debian/amanda] / installcheck / amstatus.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 => 12;
21 use strict;
22 use warnings;
23
24 use lib "@amperldir@";
25 use Installcheck;
26 use Installcheck::Run qw( run run_get );
27 use Installcheck::Catalogs;
28 use Amanda::Paths;
29 use Amanda::Constants;
30
31 my $cat;
32 my $testconf = Installcheck::Run::setup();
33 $testconf->write();
34
35 ## try a few various options with a pretty normal logfile
36
37 $cat = Installcheck::Catalogs::load('normal');
38 $cat->install();
39
40 ok(run('amstatus', 'TESTCONF'),
41     "plain amstatus runs without error");
42 like($Installcheck::Run::stdout,
43     qr{clienthost:/some/dir\s*0\s*100k\s*finished\s*\(13:01:53\)},
44     "output is reasonable");
45
46 ok(run('amstatus', 'TESTCONF', '--summary'),
47     "amstatus --summary runs without error");
48 unlike($Installcheck::Run::stdout,
49     qr{clienthost:/some/dir\s*0\s*100k\s*finished\s*\(13:01:53\)},
50     "output does not contain the finished dump");
51 like($Installcheck::Run::stdout,
52     qr{taped\s+:\s+1\s+},
53     "output contains summary info");
54
55 ## now test a file with spaces and other funny characters in filenames
56
57 $cat = Installcheck::Catalogs::load('quoted');
58 $cat->install();
59
60 ok(run('amstatus', 'TESTCONF'),
61     "amstatus runs without error with quoted disknames");
62 like($Installcheck::Run::stdout,
63     # note that amstatus' output is quoted, so backslashes are doubled
64     qr{clienthost:"C:\\\\Some Dir\\\\"\s*0\s*100k\s*finished\s*\(13:01:53\)},
65     "output is correct");
66
67 ## now test a chunker partial result
68
69 $cat = Installcheck::Catalogs::load('chunker-partial');
70 $cat->install();
71
72 ok(!run('amstatus', 'TESTCONF'),
73     "amstatus return error with chunker partial");
74 is($Installcheck::Run::exit_code, 4,
75     "correct exit code for chunker partial");
76 like($Installcheck::Run::stdout,
77     qr{localhost:/etc 0\s*80917k dump failed: dumper: \[/usr/sbin/tar returned error\], finished \(7:49:53\)},
78     "output is correct");
79
80 ## now test a taper-parallel-write > 1
81
82 $cat = Installcheck::Catalogs::load('taper-parallel-write');
83 $cat->install();
84
85 ok(run('amstatus', 'TESTCONF'),
86     "amstatus with taper-parallel-write runs without error");
87 like($Installcheck::Run::stdout,
88     qr{\s*tape 3\s*:\s*1\s*142336k\s*142336k \(  5.82\%\) amstatus_test_3-AA-003 \(1 chunks\)},
89     "output is correct");