Imported Upstream version 3.3.3
[debian/amanda] / installcheck / amadmin.pl
1 # Copyright (c) 2009-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 => 23;
21 use strict;
22 use warnings;
23
24 use lib "@amperldir@";
25 use Installcheck::Config;
26 use Installcheck::Run qw(run run_err run_get load_vtape vtape_dir);
27 use Amanda::Device qw( :constants );
28 use Amanda::Config qw( :init :getconf );
29 use Amanda::Paths;
30 use Amanda::Debug;
31 use Amanda::Constants;
32 use Amanda::Tapelist;
33
34 my $testconf;
35
36 Amanda::Debug::dbopen("installcheck");
37 Installcheck::log_test_output();
38
39 $testconf = Installcheck::Run::setup();
40 $testconf->add_dle("localhost \"\\\\\\\\windows\\\\share\" installcheck-test");
41 $testconf->add_dle("localhost \"\\\\\\\\windows\\\\share-a\" installcheck-test");
42 $testconf->add_dle("localhost \"\\\\\\\\windows\\\\share-b\" installcheck-test");
43 $testconf->write();
44
45 config_init($CONFIG_INIT_EXPLICIT_NAME, "TESTCONF");
46 my ($cfgerr_level, @cfgerr_errors) = config_errors();
47 if ($cfgerr_level >= $CFGERR_WARNINGS) {
48     config_print_errors();
49     BAIL_OUT("config errors");
50 }
51
52 #Check ARGV argument, extra quoting because of perl.
53 like(run_get('amadmin', 'TESTCONF', 'force', 'localhost', '\\\\\\\\\\\\\\\windows\\\\\\\\share'),
54     qr/Argument '\\\\\\\\\\\\\\\\windows\\\\\\\\share' matches neither a host nor a disk; quoting may not be correct./,
55     "argv 1");
56
57 like(run_get('amadmin', 'TESTCONF', 'force', 'localhost', '\\\\\\\\windows\\\\share'),
58     qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run./,
59     "argv 2");
60
61 like(run_get('amadmin', 'TESTCONF', 'force', 'localhost', '\\\\windows\\share'),
62     qr/Argument '\\\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
63     "argv 3");
64
65 like(run_get('amadmin', 'TESTCONF', 'force', 'localhost', '\\windows\share'),
66     qr/Argument '\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
67     "argv 4");
68
69 #Check sheel quoting, extra quoting because of perl
70 like(run_get('amadmin TESTCONF force localhost \\\\\\\\\\\\\\\\windows\\\\\\\\share'),
71    qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run./,
72    "shell 1");
73
74 like(run_get('amadmin TESTCONF force localhost "\\\\\\\\\\\\\\\\windows\\\\\\\\share"'),
75    qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run./,
76    "shell 2");
77
78 like(run_get('amadmin TESTCONF force localhost \'\\\\\\\\\\\\\\\\windows\\\\\\\\share\''),
79    qr/\\\\\\\\\\\\\\\windows\\\\\\\\share' matches neither a host nor a disk; quoting may not be correct./,
80    "shell 3");
81
82 like(run_get('amadmin TESTCONF force localhost \\\\\\\\windows\\\\share'),
83    qr/Argument '\\\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
84    "shell 4");
85
86 like(run_get('amadmin TESTCONF force localhost "\\\\\\\\windows\\\\share"'),
87    qr/\\\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
88    "shell 5");
89
90 like(run_get('amadmin TESTCONF force localhost \'\\\\\\\\windows\\\\share\''),
91    qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run./,
92    "shell 6");
93
94 like(run_get('amadmin TESTCONF force localhost \\\\windows\\share'),
95    qr/Argument '\\windowsshare' matches neither a host nor a disk; quoting may not be correct./,
96    "shell 7");
97
98 like(run_get('amadmin TESTCONF force localhost "\\\\windows\\share"'),
99    qr/Argument '\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
100    "shell 8");
101
102 like(run_get('amadmin TESTCONF force localhost \'\\\\windows\\share\''),
103    qr/Argument '\\\\windows\\share' matches neither a host nor a disk; quoting may not be correct./,
104    "shell 9");
105
106 like(run_get('amadmin TESTCONF force localhost share'),
107    qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run./,
108    "shell 10");
109
110 like(run_get('amadmin TESTCONF force localhost windows'),
111    qr/amadmin: localhost:\\\\windows\\share is set to a forced level 0 at next run.
112 amadmin: localhost:\\\\windows\\share-a is set to a forced level 0 at next run.
113 amadmin: localhost:\\\\windows\\share-b is set to a forced level 0 at next run.$/,
114    "shell 11");
115
116 like(run_get('amadmin TESTCONF force localhost share-\*'),
117    qr/amadmin: localhost:\\\\windows\\share-a is set to a forced level 0 at next run.
118 amadmin: localhost:\\\\windows\\share-b is set to a forced level 0 at next run.$/,
119    "shell 12");
120
121 like(run_get('amadmin TESTCONF force localhost share-a share-a'),
122    qr/^amadmin: localhost:\\\\windows\\share-a is set to a forced level 0 at next run.$/,
123    "shell 13");
124
125 like(run_get('amadmin TESTCONF balance --days 12'),
126    qr/No data to report on yet.$/,
127    "shell 14");
128
129 like(run_get('amadmin TESTCONF force =localhost share-a'),
130    qr/^amadmin: localhost:\\\\windows\\share-a is set to a forced level 0 at next run.$/,
131    "shell 15");
132
133 like(run_get('amadmin TESTCONF force =localhost =share-a'),
134    qr/^Argument '=share-a' matches neither a host nor a disk.$/,
135    "shell 16");
136
137 like(run_get('amadmin --exact-match TESTCONF force localhost share-a'),
138    qr/^Argument '=share-a' matches neither a host nor a disk.$/,
139    "shell 17");
140
141 like(run_get('amadmin TESTCONF force =localhost \'=\\\\windows\\share-a\''),
142    qr/^amadmin: localhost:\\\\windows\\share-a is set to a forced level 0 at next run.$/,
143    "shell 18");
144
145 like(run_get('amadmin --exact-match TESTCONF force localhost \'\\\\windows\\share-a\''),
146    qr/^amadmin: localhost:\\\\windows\\share-a is set to a forced level 0 at next run.$/,
147    "shell 19");
148