|
Packit |
23ab03 |
# Copyright (c) 2014-2016 Carbonite, Inc. All Rights Reserved.
|
|
Packit |
23ab03 |
#
|
|
Packit |
23ab03 |
# This program is free software; you can redistribute it and/or
|
|
Packit |
23ab03 |
# modify it under the terms of the GNU General Public License
|
|
Packit |
23ab03 |
# as published by the Free Software Foundation; either version 2
|
|
Packit |
23ab03 |
# of the License, or (at your option) any later version.
|
|
Packit |
23ab03 |
#
|
|
Packit |
23ab03 |
# This program is distributed in the hope that it will be useful, but
|
|
Packit |
23ab03 |
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
Packit |
23ab03 |
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
Packit |
23ab03 |
# for more details.
|
|
Packit |
23ab03 |
#
|
|
Packit |
23ab03 |
# You should have received a copy of the GNU General Public License along
|
|
Packit |
23ab03 |
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
Packit |
23ab03 |
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
Packit |
23ab03 |
#
|
|
Packit |
23ab03 |
# Contact information: Carbonite Inc., 756 N Pastoria Ave
|
|
Packit |
23ab03 |
# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
use Test::More;
|
|
Packit |
23ab03 |
use File::Path;
|
|
Packit |
23ab03 |
use strict;
|
|
Packit |
23ab03 |
use warnings;
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
use POSIX;
|
|
Packit |
23ab03 |
use Socket;
|
|
Packit |
23ab03 |
use IO::Socket::UNIX;
|
|
Packit |
23ab03 |
use lib '@amperldir@';
|
|
Packit |
23ab03 |
use Installcheck;
|
|
Packit |
23ab03 |
use Installcheck::Dumpcache;
|
|
Packit |
23ab03 |
use Installcheck::Config;
|
|
Packit |
23ab03 |
use Amanda::Paths;
|
|
Packit |
23ab03 |
use Amanda::Device qw( :constants );
|
|
Packit |
23ab03 |
use Amanda::Debug;
|
|
Packit |
23ab03 |
use Amanda::MainLoop;
|
|
Packit |
23ab03 |
use Amanda::Config qw( :init :getconf config_dir_relative );
|
|
Packit |
23ab03 |
use Amanda::Changer;
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
if (!Amanda::Util::built_with_component("client")) {
|
|
Packit |
23ab03 |
plan skip_all => "Not build with client";
|
|
Packit |
23ab03 |
exit 1;
|
|
Packit |
23ab03 |
}
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
eval 'use Installcheck::Rest;';
|
|
Packit |
23ab03 |
if ($@) {
|
|
Packit |
23ab03 |
plan skip_all => "Can't load Installcheck::Rest: $@";
|
|
Packit |
23ab03 |
exit 1;
|
|
Packit |
23ab03 |
}
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
# set up debugging so debug output doesn't interfere with test results
|
|
Packit |
23ab03 |
Amanda::Debug::dbopen("installcheck");
|
|
Packit |
23ab03 |
Installcheck::log_test_output();
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
# and disable Debug's die() and warn() overrides
|
|
Packit |
23ab03 |
Amanda::Debug::disable_die_override();
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
my $rest = Installcheck::Rest->new();
|
|
Packit |
23ab03 |
if ($rest->{'error'}) {
|
|
Packit |
23ab03 |
plan skip_all => "Can't start JSON Rest server: $rest->{'error'}: see " . Amanda::Debug::dbfn();
|
|
Packit |
23ab03 |
exit 1;
|
|
Packit |
23ab03 |
}
|
|
Packit |
23ab03 |
plan tests => 6;
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
my $reply;
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
my $amperldir = $Amanda::Paths::amperldir;
|
|
Packit |
23ab03 |
my $testconf;
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
$testconf = Installcheck::Run::setup();
|
|
Packit |
23ab03 |
$testconf->write();
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
#CODE 3700012
|
|
Packit |
23ab03 |
#my $test_dir = "$Installcheck::TMP/test_amgtar_discover";
|
|
Packit |
23ab03 |
# Using /tmp because socket path length are limited to 108
|
|
Packit |
23ab03 |
my $test_dir;
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
if (File::Temp->can('newdir')) {
|
|
Packit |
23ab03 |
$test_dir = File::Temp->newdir('test_amgtar_discoverXXXXXX',
|
|
Packit |
23ab03 |
DIR => '/tmp',
|
|
Packit |
23ab03 |
CLEANUP => 1);
|
|
Packit |
23ab03 |
} else {
|
|
Packit |
23ab03 |
$test_dir = "/tmp/test_amgtar_discover$$";
|
|
Packit |
23ab03 |
rmtree $test_dir;
|
|
Packit |
23ab03 |
mkdir $test_dir;
|
|
Packit |
23ab03 |
}
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
$reply = $rest->get("http://localhost:5001/amanda/v1.0/services/discover?host=localhost&auth=local&application=amgtar&diskdevice=$test_dir/does_not_exists");
|
|
Packit |
23ab03 |
is_deeply (Installcheck::Rest::remove_source_line($reply),
|
|
Packit |
23ab03 |
{ body =>
|
|
Packit |
23ab03 |
[ { 'source_filename' => "amgtar.c",
|
|
Packit |
23ab03 |
'severity' => $Amanda::Message::ERROR,
|
|
Packit |
23ab03 |
'message' => "Can't open disk '$test_dir/does_not_exists': No such file or directory",
|
|
Packit |
23ab03 |
'diskname' => "$test_dir/does_not_exists",
|
|
Packit |
23ab03 |
'merrno' => '2',
|
|
Packit |
23ab03 |
'errnocode' => 'ENOENT',
|
|
Packit |
23ab03 |
'errnostr' => 'No such file or directory',
|
|
Packit |
23ab03 |
'process' => 'amgtar',
|
|
Packit |
23ab03 |
'running_on' => 'amanda-client',
|
|
Packit |
23ab03 |
'component' => 'application',
|
|
Packit |
23ab03 |
'module' => 'amgtar',
|
|
Packit |
23ab03 |
'code' => '3700012'
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
],
|
|
Packit |
23ab03 |
http_code => 200,
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
"test_dir do not exists") || diag("reply: " . Data::Dumper::Dumper($reply));
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
$reply = $rest->get("http://localhost:5001/amanda/v1.0/services/discover?host=localhost&auth=local&application=amgtar&diskdevice=$test_dir");
|
|
Packit |
23ab03 |
is_deeply (Installcheck::Rest::remove_source_line($reply),
|
|
Packit |
23ab03 |
{ body =>
|
|
Packit |
23ab03 |
[ { 'source_filename' => "amgtar.c",
|
|
Packit |
23ab03 |
'severity' => $Amanda::Message::ERROR,
|
|
Packit |
23ab03 |
'message' => "no senddiscover result to list",
|
|
Packit |
23ab03 |
'diskname' => "$test_dir",
|
|
Packit |
23ab03 |
'process' => 'amgtar',
|
|
Packit |
23ab03 |
'running_on' => 'amanda-client',
|
|
Packit |
23ab03 |
'component' => 'application',
|
|
Packit |
23ab03 |
'module' => 'amgtar',
|
|
Packit |
23ab03 |
'code' => '3100006'
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
],
|
|
Packit |
23ab03 |
http_code => 200,
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
"test_dir is empty") || diag("reply: " . Data::Dumper::Dumper($reply));
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
mkdir "$test_dir/dir";
|
|
Packit |
23ab03 |
open (my $fh, ">$test_dir/file");
|
|
Packit |
23ab03 |
close $fh;
|
|
Packit |
23ab03 |
symlink "file", "$test_dir/symlinkfile";
|
|
Packit |
23ab03 |
symlink "file", "$test_dir/symlinkdir";
|
|
Packit |
23ab03 |
link "$test_dir/file", "$test_dir/linkfile";
|
|
Packit |
23ab03 |
mkfifo "$test_dir/fifo", "0700";
|
|
Packit |
23ab03 |
my $SOCK_PATH = "$test_dir/socket";
|
|
Packit |
23ab03 |
my $server = IO::Socket::UNIX->new(
|
|
Packit |
23ab03 |
Type => SOCK_STREAM(),
|
|
Packit |
23ab03 |
Local => $SOCK_PATH,
|
|
Packit |
23ab03 |
Listen => 1,
|
|
Packit |
23ab03 |
);
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
socket(my $socket, PF_UNIX, SOCK_STREAM, 0);
|
|
Packit |
23ab03 |
bind $socket, sockaddr_un("$test_dir/socket");
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
$reply = $rest->get("http://localhost:5001/amanda/v1.0/services/discover?host=localhost&auth=local&application=amgtar&diskdevice=$test_dir");
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
my @sorted = sort { $a->{dle_name} cmp $b->{dle_name} } @{$reply->{'body'}};
|
|
Packit |
23ab03 |
$reply->{body} = \@sorted;
|
|
Packit |
23ab03 |
is_deeply (Installcheck::Rest::remove_source_line($reply),
|
|
Packit |
23ab03 |
{ body =>
|
|
Packit |
23ab03 |
[ { 'source_filename' => "amgtar.c",
|
|
Packit |
23ab03 |
'severity' => $Amanda::Message::INFO,
|
|
Packit |
23ab03 |
'message' => 'senddiscover result',
|
|
Packit |
23ab03 |
'diskname' => "$test_dir",
|
|
Packit |
23ab03 |
'file_type' => 'dir',
|
|
Packit |
23ab03 |
'dle_name' => "dir",
|
|
Packit |
23ab03 |
'full_path' => "$test_dir/dir",
|
|
Packit |
23ab03 |
'process' => 'amgtar',
|
|
Packit |
23ab03 |
'running_on' => 'amanda-client',
|
|
Packit |
23ab03 |
'component' => 'application',
|
|
Packit |
23ab03 |
'module' => 'amgtar',
|
|
Packit |
23ab03 |
'code' => '3100005'
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
{ 'source_filename' => "amgtar.c",
|
|
Packit |
23ab03 |
'severity' => $Amanda::Message::INFO,
|
|
Packit |
23ab03 |
'message' => 'senddiscover result',
|
|
Packit |
23ab03 |
'file_type' => 'fifo',
|
|
Packit |
23ab03 |
'diskname' => "$test_dir",
|
|
Packit |
23ab03 |
'dle_name' => "fifo",
|
|
Packit |
23ab03 |
'full_path' => "$test_dir/fifo",
|
|
Packit |
23ab03 |
'process' => 'amgtar',
|
|
Packit |
23ab03 |
'running_on' => 'amanda-client',
|
|
Packit |
23ab03 |
'component' => 'application',
|
|
Packit |
23ab03 |
'module' => 'amgtar',
|
|
Packit |
23ab03 |
'code' => '3100005'
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
{ 'source_filename' => "amgtar.c",
|
|
Packit |
23ab03 |
'severity' => $Amanda::Message::INFO,
|
|
Packit |
23ab03 |
'message' => 'senddiscover result',
|
|
Packit |
23ab03 |
'file_type' => 'regular',
|
|
Packit |
23ab03 |
'diskname' => "$test_dir",
|
|
Packit |
23ab03 |
'dle_name' => "file",
|
|
Packit |
23ab03 |
'full_path' => "$test_dir/file",
|
|
Packit |
23ab03 |
'process' => 'amgtar',
|
|
Packit |
23ab03 |
'running_on' => 'amanda-client',
|
|
Packit |
23ab03 |
'component' => 'application',
|
|
Packit |
23ab03 |
'module' => 'amgtar',
|
|
Packit |
23ab03 |
'code' => '3100005'
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
{ 'source_filename' => "amgtar.c",
|
|
Packit |
23ab03 |
'severity' => $Amanda::Message::INFO,
|
|
Packit |
23ab03 |
'message' => 'senddiscover result',
|
|
Packit |
23ab03 |
'file_type' => 'regular',
|
|
Packit |
23ab03 |
'diskname' => "$test_dir",
|
|
Packit |
23ab03 |
'dle_name' => "linkfile",
|
|
Packit |
23ab03 |
'full_path' => "$test_dir/linkfile",
|
|
Packit |
23ab03 |
'process' => 'amgtar',
|
|
Packit |
23ab03 |
'running_on' => 'amanda-client',
|
|
Packit |
23ab03 |
'component' => 'application',
|
|
Packit |
23ab03 |
'module' => 'amgtar',
|
|
Packit |
23ab03 |
'code' => '3100005'
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
{ 'source_filename' => "amgtar.c",
|
|
Packit |
23ab03 |
'severity' => $Amanda::Message::INFO,
|
|
Packit |
23ab03 |
'message' => 'senddiscover result',
|
|
Packit |
23ab03 |
'file_type' => 'socket',
|
|
Packit |
23ab03 |
'diskname' => "$test_dir",
|
|
Packit |
23ab03 |
'dle_name' => "socket",
|
|
Packit |
23ab03 |
'full_path' => "$test_dir/socket",
|
|
Packit |
23ab03 |
'process' => 'amgtar',
|
|
Packit |
23ab03 |
'running_on' => 'amanda-client',
|
|
Packit |
23ab03 |
'component' => 'application',
|
|
Packit |
23ab03 |
'module' => 'amgtar',
|
|
Packit |
23ab03 |
'code' => '3100005'
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
{ 'source_filename' => "amgtar.c",
|
|
Packit |
23ab03 |
'severity' => $Amanda::Message::INFO,
|
|
Packit |
23ab03 |
'message' => 'senddiscover result',
|
|
Packit |
23ab03 |
'file_type' => 'link',
|
|
Packit |
23ab03 |
'diskname' => "$test_dir",
|
|
Packit |
23ab03 |
'dle_name' => "symlinkdir",
|
|
Packit |
23ab03 |
'full_path' => "$test_dir/symlinkdir",
|
|
Packit |
23ab03 |
'process' => 'amgtar',
|
|
Packit |
23ab03 |
'running_on' => 'amanda-client',
|
|
Packit |
23ab03 |
'component' => 'application',
|
|
Packit |
23ab03 |
'module' => 'amgtar',
|
|
Packit |
23ab03 |
'code' => '3100005'
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
{ 'source_filename' => "amgtar.c",
|
|
Packit |
23ab03 |
'severity' => $Amanda::Message::INFO,
|
|
Packit |
23ab03 |
'message' => 'senddiscover result',
|
|
Packit |
23ab03 |
'file_type' => 'link',
|
|
Packit |
23ab03 |
'diskname' => "$test_dir",
|
|
Packit |
23ab03 |
'dle_name' => "symlinkfile",
|
|
Packit |
23ab03 |
'full_path' => "$test_dir/symlinkfile",
|
|
Packit |
23ab03 |
'process' => 'amgtar',
|
|
Packit |
23ab03 |
'running_on' => 'amanda-client',
|
|
Packit |
23ab03 |
'component' => 'application',
|
|
Packit |
23ab03 |
'module' => 'amgtar',
|
|
Packit |
23ab03 |
'code' => '3100005'
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
],
|
|
Packit |
23ab03 |
http_code => 200,
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
"test_dir") || diag("reply: " . Data::Dumper::Dumper($reply));
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
#test a diskdevice that end with a /
|
|
Packit |
23ab03 |
my $diskname .= $test_dir . '/';
|
|
Packit |
23ab03 |
$reply = $rest->get("http://localhost:5001/amanda/v1.0/services/discover?host=localhost&auth=local&application=amgtar&diskdevice=$diskname");
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
@sorted = sort { $a->{dle_name} cmp $b->{dle_name} } @{$reply->{'body'}};
|
|
Packit |
23ab03 |
$reply->{body} = \@sorted;
|
|
Packit |
23ab03 |
is_deeply (Installcheck::Rest::remove_source_line($reply),
|
|
Packit |
23ab03 |
{ body =>
|
|
Packit |
23ab03 |
[ { 'source_filename' => "amgtar.c",
|
|
Packit |
23ab03 |
'severity' => $Amanda::Message::INFO,
|
|
Packit |
23ab03 |
'message' => 'senddiscover result',
|
|
Packit |
23ab03 |
'file_type' => 'dir',
|
|
Packit |
23ab03 |
'diskname' => "$diskname",
|
|
Packit |
23ab03 |
'dle_name' => "dir",
|
|
Packit |
23ab03 |
'full_path' => "$test_dir/dir",
|
|
Packit |
23ab03 |
'process' => 'amgtar',
|
|
Packit |
23ab03 |
'running_on' => 'amanda-client',
|
|
Packit |
23ab03 |
'component' => 'application',
|
|
Packit |
23ab03 |
'module' => 'amgtar',
|
|
Packit |
23ab03 |
'code' => '3100005'
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
{ 'source_filename' => "amgtar.c",
|
|
Packit |
23ab03 |
'severity' => $Amanda::Message::INFO,
|
|
Packit |
23ab03 |
'message' => 'senddiscover result',
|
|
Packit |
23ab03 |
'file_type' => 'fifo',
|
|
Packit |
23ab03 |
'diskname' => "$diskname",
|
|
Packit |
23ab03 |
'dle_name' => "fifo",
|
|
Packit |
23ab03 |
'full_path' => "$test_dir/fifo",
|
|
Packit |
23ab03 |
'process' => 'amgtar',
|
|
Packit |
23ab03 |
'running_on' => 'amanda-client',
|
|
Packit |
23ab03 |
'component' => 'application',
|
|
Packit |
23ab03 |
'module' => 'amgtar',
|
|
Packit |
23ab03 |
'code' => '3100005'
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
{ 'source_filename' => "amgtar.c",
|
|
Packit |
23ab03 |
'severity' => $Amanda::Message::INFO,
|
|
Packit |
23ab03 |
'message' => 'senddiscover result',
|
|
Packit |
23ab03 |
'file_type' => 'regular',
|
|
Packit |
23ab03 |
'diskname' => "$diskname",
|
|
Packit |
23ab03 |
'dle_name' => "file",
|
|
Packit |
23ab03 |
'full_path' => "$test_dir/file",
|
|
Packit |
23ab03 |
'process' => 'amgtar',
|
|
Packit |
23ab03 |
'running_on' => 'amanda-client',
|
|
Packit |
23ab03 |
'component' => 'application',
|
|
Packit |
23ab03 |
'module' => 'amgtar',
|
|
Packit |
23ab03 |
'code' => '3100005'
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
{ 'source_filename' => "amgtar.c",
|
|
Packit |
23ab03 |
'severity' => $Amanda::Message::INFO,
|
|
Packit |
23ab03 |
'message' => 'senddiscover result',
|
|
Packit |
23ab03 |
'file_type' => 'regular',
|
|
Packit |
23ab03 |
'diskname' => "$diskname",
|
|
Packit |
23ab03 |
'dle_name' => "linkfile",
|
|
Packit |
23ab03 |
'full_path' => "$test_dir/linkfile",
|
|
Packit |
23ab03 |
'process' => 'amgtar',
|
|
Packit |
23ab03 |
'running_on' => 'amanda-client',
|
|
Packit |
23ab03 |
'component' => 'application',
|
|
Packit |
23ab03 |
'module' => 'amgtar',
|
|
Packit |
23ab03 |
'code' => '3100005'
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
{ 'source_filename' => "amgtar.c",
|
|
Packit |
23ab03 |
'severity' => $Amanda::Message::INFO,
|
|
Packit |
23ab03 |
'message' => 'senddiscover result',
|
|
Packit |
23ab03 |
'file_type' => 'socket',
|
|
Packit |
23ab03 |
'diskname' => "$diskname",
|
|
Packit |
23ab03 |
'dle_name' => "socket",
|
|
Packit |
23ab03 |
'full_path' => "$test_dir/socket",
|
|
Packit |
23ab03 |
'process' => 'amgtar',
|
|
Packit |
23ab03 |
'running_on' => 'amanda-client',
|
|
Packit |
23ab03 |
'component' => 'application',
|
|
Packit |
23ab03 |
'module' => 'amgtar',
|
|
Packit |
23ab03 |
'code' => '3100005'
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
{ 'source_filename' => "amgtar.c",
|
|
Packit |
23ab03 |
'severity' => $Amanda::Message::INFO,
|
|
Packit |
23ab03 |
'message' => 'senddiscover result',
|
|
Packit |
23ab03 |
'file_type' => 'link',
|
|
Packit |
23ab03 |
'diskname' => "$diskname",
|
|
Packit |
23ab03 |
'dle_name' => "symlinkdir",
|
|
Packit |
23ab03 |
'full_path' => "$test_dir/symlinkdir",
|
|
Packit |
23ab03 |
'process' => 'amgtar',
|
|
Packit |
23ab03 |
'running_on' => 'amanda-client',
|
|
Packit |
23ab03 |
'component' => 'application',
|
|
Packit |
23ab03 |
'module' => 'amgtar',
|
|
Packit |
23ab03 |
'code' => '3100005'
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
{ 'source_filename' => "amgtar.c",
|
|
Packit |
23ab03 |
'severity' => $Amanda::Message::INFO,
|
|
Packit |
23ab03 |
'message' => 'senddiscover result',
|
|
Packit |
23ab03 |
'file_type' => 'link',
|
|
Packit |
23ab03 |
'diskname' => "$diskname",
|
|
Packit |
23ab03 |
'dle_name' => "symlinkfile",
|
|
Packit |
23ab03 |
'full_path' => "$test_dir/symlinkfile",
|
|
Packit |
23ab03 |
'process' => 'amgtar',
|
|
Packit |
23ab03 |
'running_on' => 'amanda-client',
|
|
Packit |
23ab03 |
'component' => 'application',
|
|
Packit |
23ab03 |
'module' => 'amgtar',
|
|
Packit |
23ab03 |
'code' => '3100005'
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
],
|
|
Packit |
23ab03 |
http_code => 200,
|
|
Packit |
23ab03 |
},
|
|
Packit |
23ab03 |
"test_dir/") || diag("reply: " . Data::Dumper::Dumper($reply));
|
|
Packit |
23ab03 |
rmtree($test_dir);
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
my $dev_dir = "/dev";
|
|
Packit |
23ab03 |
$dev_dir = '/devices/isa/fdc@1,3f0' if -e '/devices/isa/fdc@1,3f0';
|
|
Packit |
23ab03 |
$reply = $rest->get("http://localhost:5001/amanda/v1.0/services/discover?host=localhost&auth=local&application=amgtar&diskdevice=$dev_dir");
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
@sorted = sort { $a->{dle_name} cmp $b->{dle_name} } @{$reply->{'body'}};
|
|
Packit |
23ab03 |
$reply->{body} = \@sorted;
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
my $bad_block = 0;
|
|
Packit |
23ab03 |
my $bad_char = 0;
|
|
Packit |
23ab03 |
foreach my $message (@{$reply->{'body'}}) {
|
|
Packit |
23ab03 |
-l $message->{'full_path'};
|
|
Packit |
23ab03 |
if (-b _) {
|
|
Packit |
23ab03 |
if ($message->{'file_type'} ne 'block') {
|
|
Packit |
23ab03 |
$bad_block++;
|
|
Packit |
23ab03 |
diag("message: " . Data::Dumper::Dumper($message));
|
|
Packit |
23ab03 |
} else {
|
|
Packit |
23ab03 |
#diag("found a block device");
|
|
Packit |
23ab03 |
}
|
|
Packit |
23ab03 |
} elsif ($message->{'file_type'} eq 'block') {
|
|
Packit |
23ab03 |
$bad_block++;
|
|
Packit |
23ab03 |
diag("message: " . Data::Dumper::Dumper($message));
|
|
Packit |
23ab03 |
} elsif (-c _) {
|
|
Packit |
23ab03 |
if ($message->{'file_type'} ne 'char') {
|
|
Packit |
23ab03 |
$bad_char++;
|
|
Packit |
23ab03 |
diag("message: " . Data::Dumper::Dumper($message));
|
|
Packit |
23ab03 |
} else {
|
|
Packit |
23ab03 |
#diag("found a char device");
|
|
Packit |
23ab03 |
}
|
|
Packit |
23ab03 |
} elsif ($message->{'file_type'} eq 'char') {
|
|
Packit |
23ab03 |
$bad_char++;
|
|
Packit |
23ab03 |
diag("message: " . Data::Dumper::Dumper($message));
|
|
Packit |
23ab03 |
}
|
|
Packit |
23ab03 |
}
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
is($bad_block, 0, "found bad block");
|
|
Packit |
23ab03 |
is($bad_char, 0, "found bad char");
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
close($socket);
|
|
Packit |
23ab03 |
rmtree $test_dir;
|
|
Packit |
23ab03 |
|
|
Packit |
23ab03 |
$rest->stop();
|
|
Packit |
23ab03 |
|