|
Packit Service |
392537 |
# Copyright (c) 2014-2016 Carbonite, Inc. All Rights Reserved.
|
|
Packit Service |
392537 |
#
|
|
Packit Service |
392537 |
# This program is free software; you can redistribute it and/or
|
|
Packit Service |
392537 |
# modify it under the terms of the GNU General Public License
|
|
Packit Service |
392537 |
# as published by the Free Software Foundation; either version 2
|
|
Packit Service |
392537 |
# of the License, or (at your option) any later version.
|
|
Packit Service |
392537 |
#
|
|
Packit Service |
392537 |
# This program is distributed in the hope that it will be useful, but
|
|
Packit Service |
392537 |
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
Packit Service |
392537 |
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
Packit Service |
392537 |
# for more details.
|
|
Packit Service |
392537 |
#
|
|
Packit Service |
392537 |
# You should have received a copy of the GNU General Public License along
|
|
Packit Service |
392537 |
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
Packit Service |
392537 |
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
Packit Service |
392537 |
#
|
|
Packit Service |
392537 |
# Contact information: Carbonite Inc., 756 N Pastoria Ave
|
|
Packit Service |
392537 |
# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
use Test::More;
|
|
Packit Service |
392537 |
use File::Path;
|
|
Packit Service |
392537 |
use strict;
|
|
Packit Service |
392537 |
use warnings;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
use lib '@amperldir@';
|
|
Packit Service |
392537 |
use Installcheck;
|
|
Packit Service |
392537 |
use Installcheck::Dumpcache;
|
|
Packit Service |
392537 |
use Installcheck::Config;
|
|
Packit Service |
392537 |
use Installcheck::Run qw(run run_err $diskname amdump_diag check_amreport check_amstatus);
|
|
Packit Service |
392537 |
use Installcheck::Catalogs;
|
|
Packit Service |
392537 |
use Amanda::Paths;
|
|
Packit Service |
392537 |
use Amanda::Device qw( :constants );
|
|
Packit Service |
392537 |
use Amanda::Debug;
|
|
Packit Service |
392537 |
use Amanda::MainLoop;
|
|
Packit Service |
392537 |
use Amanda::Config qw( :init :getconf config_dir_relative );
|
|
Packit Service |
392537 |
use Amanda::Changer;
|
|
Packit Service |
392537 |
use Cwd;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
eval 'use Installcheck::Rest;';
|
|
Packit Service |
392537 |
if ($@) {
|
|
Packit Service |
392537 |
plan skip_all => "Can't load Installcheck::Rest: $@";
|
|
Packit Service |
392537 |
exit 1;
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
eval "require Time::HiRes;";
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# set up debugging so debug output doesn't interfere with test results
|
|
Packit Service |
392537 |
Amanda::Debug::dbopen("installcheck");
|
|
Packit Service |
392537 |
Installcheck::log_test_output();
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# and disable Debug's die() and warn() overrides
|
|
Packit Service |
392537 |
Amanda::Debug::disable_die_override();
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $rest = Installcheck::Rest->new();
|
|
Packit Service |
392537 |
if ($rest->{'error'}) {
|
|
Packit Service |
392537 |
plan skip_all => "Can't start JSON Rest server: $rest->{'error'}: see " . Amanda::Debug::dbfn();
|
|
Packit Service |
392537 |
exit 1;
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
plan tests => 37;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $reply;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $config_dir = $Amanda::Paths::CONFIG_DIR;
|
|
Packit Service |
392537 |
my $amperldir = $Amanda::Paths::amperldir;
|
|
Packit Service |
392537 |
my $testconf;
|
|
Packit Service |
392537 |
my $diskfile;
|
|
Packit Service |
392537 |
my $infodir;
|
|
Packit Service |
392537 |
my $timestamp;
|
|
Packit Service |
392537 |
my $tracefile;
|
|
Packit Service |
392537 |
my $logfile;
|
|
Packit Service |
392537 |
my $hostname = `hostname`;
|
|
Packit Service |
392537 |
chomp $hostname;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$testconf = Installcheck::Run::setup();
|
|
Packit Service |
392537 |
$testconf->add_param('autolabel', '"TESTCONF%%" empty volume_error');
|
|
Packit Service |
392537 |
$testconf->add_param('columnspec', '"Dumprate=1:-8:1,TapeRate=1:-8:1"');
|
|
Packit Service |
392537 |
$testconf->add_dle(<
|
|
Packit Service |
392537 |
localhost diskname2 $diskname {
|
|
Packit Service |
392537 |
installcheck-test
|
|
Packit Service |
392537 |
program "APPLICATION"
|
|
Packit Service |
392537 |
compress server custom
|
|
Packit Service |
392537 |
server-custom-compress "$Amanda::Constants::COMPRESS_PATH"
|
|
Packit Service |
392537 |
# encrypt server
|
|
Packit Service |
392537 |
# server-encrypt "$Amanda::Constants::COMPRESS_PATH"
|
|
Packit Service |
392537 |
# server-decrypt-option ""
|
|
Packit Service |
392537 |
application {
|
|
Packit Service |
392537 |
plugin "amrandom"
|
|
Packit Service |
392537 |
property "SIZE" "262144"
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
holdingdisk never
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
EODLE
|
|
Packit Service |
392537 |
$testconf->write();
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
config_init($CONFIG_INIT_EXPLICIT_NAME, "TESTCONF");
|
|
Packit Service |
392537 |
$diskfile = Amanda::Config::config_dir_relative(getconf($CNF_DISKFILE));
|
|
Packit Service |
392537 |
$infodir = getconf($CNF_INFOFILE);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$reply = $rest->post("http://localhost:5001/amanda/v1.0/configs/TESTCONF/runs/amdump","");
|
|
Packit Service |
392537 |
foreach my $message (@{$reply->{'body'}}) {
|
|
Packit Service |
392537 |
if (defined $message and defined $message->{'code'}) {
|
|
Packit Service |
392537 |
if ($message->{'code'} == 2000003) {
|
|
Packit Service |
392537 |
$timestamp = $message->{'timestamp'};
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
if ($message->{'code'} == 2000001) {
|
|
Packit Service |
392537 |
$tracefile = $message->{'tracefile'};
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
if ($message->{'code'} == 2000000) {
|
|
Packit Service |
392537 |
$logfile = $message->{'logfile'};
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
#wait until it is done
|
|
Packit Service |
392537 |
do {
|
|
Packit Service |
392537 |
Time::HiRes::sleep(0.5);
|
|
Packit Service |
392537 |
$reply = $rest->get("http://localhost:5001/amanda/v1.0/configs/TESTCONF/runs");
|
|
Packit Service |
392537 |
} while ($reply->{'body'}[0]->{'code'} == 2000004 and
|
|
Packit Service |
392537 |
$reply->{'body'}[0]->{'status'} ne 'done');
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# get REST report
|
|
Packit Service |
392537 |
$reply = $rest->get("http://localhost:5001/amanda/v1.0/configs/TESTCONF/report?logfile=$logfile");
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'severity'}, 'success', 'severity is success');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'code'}, '1900001', 'code is 1900001');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'head'}->{'hostname'}, $hostname , 'hostname is correct');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'head'}->{'exit_status'}, '0' , 'exit_status is correct');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'head'}->{'status'}, 'done' , 'status is correct');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'head'}->{'org'}, 'DailySet1' , 'org is correct');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'head'}->{'config_name'}, 'TESTCONF' , 'config_name is correct');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'head'}->{'timestamp'}, $timestamp , 'timestamp is correct');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'notes'}->[1], ' planner: Adding new disk localhost:diskname2.' , 'notes[1] is correct') || diag("notes: " . Data::Dumper::Dumper($reply->{'body'}->[0]->{'report'}->{'notes'}));
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'notes'}->[2], ' taper: Slot 1 without label can be labeled' , 'notes[2] is correct') || diag("notes: " . Data::Dumper::Dumper($reply->{'body'}->[0]->{'report'}->{'notes'}));
|
|
Packit Service |
392537 |
#is($reply->{'body'}->[0]->{'report'}->{'notes'}->[3], ' taper: tape TESTCONF01 kb 94 fm 1 [OK]' , 'notes[3] is correct') || diag("notes: " . Data::Dumper::Dumper($reply->{'body'}->[0]->{'report'}->{'notes'}));
|
|
Packit Service |
392537 |
ok(!exists $reply->{'body'}->[0]->{'report'}->{'notes'}->[4], 'no notes[4]') || diag("notes: " . Data::Dumper::Dumper($reply->{'body'}->[0]->{'report'}->{'notes'}));
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'usage_by_tape'}->[0]->{'nb'}, '1' , 'one dle on tape 0');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'usage_by_tape'}->[0]->{'nc'}, '1' , 'one part on tape 0');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'usage_by_tape'}->[0]->{'tape_label'}, 'TESTCONF01' , 'label tape_label on tape 0');
|
|
Packit Service |
392537 |
#is($reply->{'body'}->[0]->{'report'}->{'usage_by_tape'}->[0]->{'size'}, '94' , 'size 94 on tape 0');
|
|
Packit Service |
392537 |
ok(!exists $reply->{'body'}->[0]->{'report'}->{'usage_by_tape'}->[1], 'only one tape');
|
|
Packit Service |
392537 |
is_deeply($reply->{'body'}->[0]->{'report'}->{'tapeinfo'}->{'storage'}->{'TESTCONF'}->{'use'}, [ 'TESTCONF01'], 'use TESTCONF');
|
|
Packit Service |
392537 |
#is_deeply($reply->{'body'}->[0]->{'report'}->{'statistic'}->{'tape_size'}, { 'full' => '94',
|
|
Packit Service |
392537 |
# 'total' => '94',
|
|
Packit Service |
392537 |
# 'incr' => '0' }, 'tape_size is correct');
|
|
Packit Service |
392537 |
is_deeply($reply->{'body'}->[0]->{'report'}->{'statistic'}->{'parts_taped'}, { 'full' => '1',
|
|
Packit Service |
392537 |
'total' => '1',
|
|
Packit Service |
392537 |
'incr' => '0' }, 'parts_taped is correct');
|
|
Packit Service |
392537 |
is_deeply($reply->{'body'}->[0]->{'report'}->{'statistic'}->{'dles_taped'}, { 'full' => '1',
|
|
Packit Service |
392537 |
'total' => '1',
|
|
Packit Service |
392537 |
'incr' => '0' }, 'dles_taped is correct');
|
|
Packit Service |
392537 |
is_deeply($reply->{'body'}->[0]->{'report'}->{'statistic'}->{'dles_dumped'}, { 'full' => '1',
|
|
Packit Service |
392537 |
'total' => '1',
|
|
Packit Service |
392537 |
'incr' => '0' }, 'dles_dumped is correct');
|
|
Packit Service |
392537 |
is_deeply($reply->{'body'}->[0]->{'report'}->{'statistic'}->{'original_size'}, { 'full' => '256',
|
|
Packit Service |
392537 |
'total' => '256',
|
|
Packit Service |
392537 |
'incr' => '0' }, 'original_size is correct');
|
|
Packit Service |
392537 |
#is_deeply($reply->{'body'}->[0]->{'report'}->{'statistic'}->{'output_size'}, { 'full' => '94',
|
|
Packit Service |
392537 |
# 'total' => '94',
|
|
Packit Service |
392537 |
# 'incr' => '0' }, 'output_size is correct');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'statistic'}->{'dumpdisks'}, '', 'dumpdisks is correct');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'statistic'}->{'tapedisks'}, '', 'tapedisks is correct');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'statistic'}->{'tapeparts'}, '', 'tapeparts is correct');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'summary'}->[0]->{'backup_level'}, '0', 'backup_level is correct');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'summary'}->[0]->{'disk_name'}, 'diskname2', 'disk_name is correct');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'summary'}->[0]->{'hostname'}, 'localhost', 'hostname is correct');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'summary'}->[0]->{'dump_orig_kb'}, '256', 'dump_orig_kb is correct');
|
|
Packit Service |
392537 |
#is($reply->{'body'}->[0]->{'report'}->{'summary'}->[0]->{'dump_out_kb'}, '94', 'dump_out_kb is correct');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'report'}->{'summary'}->[0]->{'dle_status'}, 'full', 'dle_status is correct');
|
|
Packit Service |
392537 |
ok(!exists $reply->{'body'}->[0]->{'report'}->{'summary'}->[1], 'Only one summary');
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$reply = $rest->get("http://localhost:5001/amanda/v1.0/configs/TESTCONF/status?tracefile=$tracefile");
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'severity'}, 'info', 'severity is info');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'code'}, '1800000', 'code is 1800000');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'status'}->{'dead_run'}, '1', 'dead_run is correct');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'status'}->{'exit_status'}, '0', 'exit_status is correct');
|
|
Packit Service |
392537 |
$reply->{'body'}->[0]->{'status'}->{'dles'}->{'localhost'}->{'diskname2'}->{$timestamp}->{'chunk_time'} = undef;
|
|
Packit Service |
392537 |
$reply->{'body'}->[0]->{'status'}->{'dles'}->{'localhost'}->{'diskname2'}->{$timestamp}->{'dump_time'} = undef;
|
|
Packit Service |
392537 |
$reply->{'body'}->[0]->{'status'}->{'dles'}->{'localhost'}->{'diskname2'}->{$timestamp}->{'storage'}->{'TESTCONF'}->{'taper_time'} = undef;
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'status'}->{'dles'}->{'localhost'}->{'diskname2'}->{$timestamp}->{'status'}, '21', 'status 21 is good');
|
|
Packit Service |
392537 |
is($reply->{'body'}->[0]->{'status'}->{'dles'}->{'localhost'}->{'diskname2'}->{$timestamp}->{'storage'}->{'TESTCONF'}->{'status'}, '21', 'storage status 21 is good');
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$rest->stop();
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $testdir = "$Installcheck::TMP/amfetchdump-installcheck/files";
|
|
Packit Service |
392537 |
rmtree($testdir);
|
|
Packit Service |
392537 |
mkpath($testdir);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $origdir = getcwd;
|
|
Packit Service |
392537 |
chdir($testdir);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(run('amfetchdump', 'TESTCONF', 'localhost'),
|
|
Packit Service |
392537 |
"amfetchdump restore a client compressed dump");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(-f "$testdir/localhost.diskname2.$timestamp.0", "file exists");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
chdir("$origdir");
|
|
Packit Service |
392537 |
rmtree($testdir);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
Installcheck::Run::cleanup();
|