-# Copyright (c) 2007, 2008, 2009, 2010 Zmanda, Inc. All Rights Reserved.
+# Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved.
#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 as published
-# by the Free Software Foundation.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
-use Test::More tests => 204;
+use Test::More tests => 224;
use strict;
use warnings;
use Data::Dumper;
'plugin' => '"script-email"',
'execute-on' => 'pre-host-backup, post-host-backup',
'execute-where' => 'client',
- 'property' => '"mailto" "amandabackup" "amanda"',
+ 'property' => '"mailto" "backup" "amanda"',
]);
$testconf->add_device('my_device', [
'comment' => '"my device is mine, not yours"',
'property' => '"testprop" "testval"',
'device_property' => '"testdprop" "testdval"',
]);
+$testconf->add_interactivity('my_interactivity', [
+ 'comment' => '"my interactivity is mine, not yours"',
+ 'plugin' => '"MY-interactivity"',
+ 'property' => '"testprop" "testval"',
+]);
+
+$testconf->add_taperscan('my_taperscan', [
+ 'comment' => '"my taperscan is mine, not yours"',
+ 'plugin' => '"MY-taperscan"',
+ 'property' => '"testprop" "testval"',
+]);
$testconf->write();
[ sort(qw(
mydump-type second_dumptype third_dumptype
NO-COMPRESS COMPRESS-FAST COMPRESS-BEST COMPRESS-CUST
- SRVCOMPRESS BSD-AUTH NO-RECORD NO-HOLD
+ SRVCOMPRESS BSD-AUTH BSDTCP-AUTH NO-RECORD NO-HOLD
NO-FULL
)) ],
"getconf_list lists all dumptypes (including defaults)");
[ sort("my_changer") ],
"getconf_list lists all changers");
+$dc = lookup_interactivity("my_interactivity");
+ok($dc, "found my_interactivity");
+is(interactivity_name($dc), "my_interactivity",
+ "my_interactivity knows its name");
+is(interactivity_getconf($dc, $INTERACTIVITY_COMMENT), 'my interactivity is mine, not yours',
+ "interactivity comment");
+is(interactivity_getconf($dc, $INTERACTIVITY_PLUGIN), 'MY-interactivity',
+ "interactivity plugin");
+is_deeply(interactivity_getconf($dc, $INTERACTIVITY_PROPERTY),
+ { 'testprop' => {
+ 'priority' => 0,
+ 'values' => [ 'testval' ],
+ 'append' => 0,
+ }
+ }, "interactivity properties represented correctly");
+
+is_deeply([ sort(+getconf_list("interactivity")) ],
+ [ sort("my_interactivity") ],
+ "getconf_list lists all interactivity");
+
+$dc = lookup_taperscan("my_taperscan");
+ok($dc, "found my_taperscan");
+is(taperscan_name($dc), "my_taperscan",
+ "my_taperscan knows its name");
+is(taperscan_getconf($dc, $TAPERSCAN_COMMENT), 'my taperscan is mine, not yours',
+ "taperscan comment");
+is(taperscan_getconf($dc, $TAPERSCAN_PLUGIN), 'MY-taperscan',
+ "taperscan plugin");
+is_deeply(taperscan_getconf($dc, $TAPERSCAN_PROPERTY),
+ { 'testprop' => {
+ 'priority' => 0,
+ 'values' => [ 'testval' ],
+ 'append' => 0,
+ }
+ }, "taperscan properties represented correctly");
+
+is_deeply([ sort(+getconf_list("taperscan")) ],
+ [ sort("my_taperscan") ],
+ "getconf_list lists all taperscan");
+
+
##
# Test config overwrites (using the config from above)
my $pid = open(my $kid, "-|");
die "Can't fork: $!" unless defined($pid);
if (!$pid) {
- Amanda::Config::dump_configuration();
+ Amanda::Config::dump_configuration(1, 0);
exit 1;
}
my $dump_first_line = <$kid>;
is($dump_filename, $fn,
"config filename is included correctly");
-like($dump, qr/DEVICE_PROPERTY\s+"foo" "bar"\n/i,
- "DEVICE_PROPERTY appears in dump output");
+like($dump, qr/DEVICE-PROPERTY\s+"foo" "bar"\n/i,
+ "DEVICE-PROPERTY appears in dump output");
-like($dump, qr/AMRECOVER_CHECK_LABEL\s+(yes|no)/i,
- "AMRECOVER_CHECK_LABEL has a trailing space");
+like($dump, qr/AMRECOVER-CHECK-LABEL\s+(yes|no)/i,
+ "AMRECOVER-CHECK-LABEL has a trailing space");
-like($dump, qr/AMRECOVER_CHECK_LABEL\s+(yes|no)/i,
- "AMRECOVER_CHECK_LABEL has a trailing space");
+like($dump, qr/AMRECOVER-CHECK-LABEL\s+(yes|no)/i,
+ "AMRECOVER-CHECK-LABEL has a trailing space");
like($dump, qr/EXCLUDE\s+LIST "foo" "bar" "true" "star"/i,
"EXCLUDE LIST is in the dump");
"INCLUDE LIST is in the dump");
like($dump, qr/INCLUDE\s+FILE OPTIONAL "rhyme"/i,
"INCLUDE FILE is in the dump");
-like($dump, qr/RECOVERY_LIMIT.*SAME-HOST/i,
+like($dump, qr/RECOVERY-LIMIT.*SAME-HOST/i,
"RECOVERY-LIST is in the dump");
##
$testconf = Installcheck::Config->new();
$testconf->add_param('recovery-limit', '"foo" "bar"');
$testconf->add_dumptype('rl1', [
- 'recovery-limit' => 'same-host',
+ 'recovery-limit' => 'same-host server',
]);
$testconf->add_dumptype('rl2', [
'recovery-limit' => '"somehost"',
]);
$testconf->add_dumptype('rl3', [
- 'recovery-limit' => 'same-host "somehost"',
+ 'recovery-limit' => 'same-host server "somehost"',
]);
$testconf->add_dumptype('rl4', [
'recovery-limit' => '"foohost" same-host',
$dtyp = lookup_dumptype("rl1");
is_deeply(dumptype_getconf($dtyp, $DUMPTYPE_RECOVERY_LIMIT),
- [ undef ],
+ [ "SAMEHOST-SAMEHOST-SAMEHOST", "SERVER-SERVER-SERVER" ],
"same-host => undef in list");
$dtyp = lookup_dumptype("rl2");
$dtyp = lookup_dumptype("rl3");
is_deeply(dumptype_getconf($dtyp, $DUMPTYPE_RECOVERY_LIMIT),
- [ undef, "somehost" ],
+ [ "SAMEHOST-SAMEHOST-SAMEHOST", "SERVER-SERVER-SERVER", "somehost" ],
"hostname and same-host parsed correctly");
$dtyp = lookup_dumptype("rl4");
is_deeply(dumptype_getconf($dtyp, $DUMPTYPE_RECOVERY_LIMIT),
- [ undef, "foohost" ], # note that the order is an implementation detail
+ [ "SAMEHOST-SAMEHOST-SAMEHOST", "foohost" ], # note that the order is an implementation detail
".. even if same-host comes last");
}
+##
+# Check out dump-limit parsing
+
+$testconf = Installcheck::Config->new();
+$testconf->add_dumptype('dl1', [
+ 'dump-limit' => 'same-host',
+]);
+$testconf->add_dumptype('dl2', [
+ 'dump-limit' => 'server',
+]);
+$testconf->add_dumptype('dl3', [
+ 'dump-limit' => 'same-host server',
+]);
+$testconf->write();
+
+$cfg_result = config_init($CONFIG_INIT_EXPLICIT_NAME, "TESTCONF");
+is($cfg_result, $CFGERR_OK,
+ "dump-limit config loaded")
+ or diag_config_errors();
+SKIP: {
+ skip "error loading config", 5 unless $cfg_result == $CFGERR_OK;
+ my $dtyp;
+
+ $dtyp = lookup_dumptype("dl1");
+ is_deeply(dumptype_getconf($dtyp, $DUMPTYPE_DUMP_LIMIT),
+ [ "SAMEHOST-SAMEHOST-SAMEHOST" ],
+ "same-host => \"SAMEHOST-SAMEHOST-SAMEHOST\" in list");
+
+ $dtyp = lookup_dumptype("dl2");
+ is_deeply(dumptype_getconf($dtyp, $DUMPTYPE_DUMP_LIMIT),
+ [ "SERVER-SERVER-SERVER" ],
+ "server => \"SERVER-SERVER-SERVER\" in list");
+
+ $dtyp = lookup_dumptype("dl3");
+ is_deeply(dumptype_getconf($dtyp, $DUMPTYPE_DUMP_LIMIT),
+ [ "SAMEHOST-SAMEHOST-SAMEHOST", "SERVER-SERVER-SERVER" ],
+ "same-host and server");
+}
+
+$testconf->add_dumptype('dl4', [
+ 'dump-limit' => 'same-host server "somehost"',
+]);
+$testconf->write();
+$cfg_result = config_init($CONFIG_INIT_EXPLICIT_NAME, "TESTCONF");
+isnt($cfg_result, $CFGERR_OK,
+ "dump-limit do not accept hostname");
+
##
# Try an autolabel with a template and 'any'
);
for my $pn (@prop_names) {
- is_deeply($properties->{$pn->{'val'}}->{values}, [ "VALUE" ]);
+ is_deeply($properties->{$pn->{'val'}}->{values}, [ "VALUE" ], "property $pn->{'val'}");
}
+$testconf = Installcheck::Config->new();
+$testconf->add_client_config_param('amdump-server', '"amdump.localhost"');
+$testconf->add_client_config_param('index-server', '"index.localhost"');
+$testconf->add_client_config_param('tape-server', '"tape.localhost"');
+$testconf->write();
+config_init($CONFIG_INIT_CLIENT | $CONFIG_INIT_EXPLICIT_NAME, "TESTCONF");
+my $amdump_server = getconf($CNF_AMDUMP_SERVER);
+is ($amdump_server, "amdump.localhost", "amdump-server is \"amdump.localhost\"");
+my $index_server = getconf($CNF_INDEX_SERVER);
+is ($index_server, "index.localhost", "index-server is \"index.localhost\"");
+my $tape_server = getconf($CNF_TAPE_SERVER);
+is ($tape_server, "tape.localhost", "amdump is \"tape.localhost\"");
+