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