|
Packit Service |
392537 |
# Copyright (c) 2008-2012 Zmanda, Inc. All Rights Reserved.
|
|
Packit Service |
392537 |
# Copyright (c) 2013-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 tests => 634;
|
|
Packit Service |
392537 |
use File::Path qw( mkpath rmtree );
|
|
Packit Service |
392537 |
use Sys::Hostname;
|
|
Packit Service |
392537 |
use Carp;
|
|
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::Mock;
|
|
Packit Service |
392537 |
use Installcheck::Config;
|
|
Packit Service |
392537 |
use Amanda::Debug;
|
|
Packit Service |
392537 |
use Amanda::Device qw( :constants );
|
|
Packit Service |
392537 |
use Amanda::Config qw( :getconf :init );
|
|
Packit Service |
392537 |
use Amanda::Xfer qw( :constants );
|
|
Packit Service |
392537 |
use Amanda::Header qw( :constants );
|
|
Packit Service |
392537 |
use Amanda::Paths;
|
|
Packit Service |
392537 |
use Amanda::Constants;
|
|
Packit Service |
392537 |
use Amanda::Util;
|
|
Packit Service |
392537 |
use Amanda::MainLoop;
|
|
Packit Service |
392537 |
use IO::Socket;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $dev;
|
|
Packit Service |
392537 |
my $dev_name;
|
|
Packit Service |
392537 |
my ($vtape1, $vtape2);
|
|
Packit Service |
392537 |
my ($input_filename, $output_filename) =
|
|
Packit Service |
392537 |
( "$Installcheck::TMP/input.tmp", "$Installcheck::TMP/output.tmp" );
|
|
Packit Service |
392537 |
my $taperoot = "$Installcheck::TMP/Amanda_Device_test_tapes";
|
|
Packit Service |
392537 |
my $diskflatroot = "$Installcheck::TMP/Amanda_Device_test_diskflat";
|
|
Packit Service |
392537 |
my $testconf;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# we'll need some vtapes..
|
|
Packit Service |
392537 |
sub mkvtape {
|
|
Packit Service |
392537 |
my ($num) = @_;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $mytape = "$taperoot/$num";
|
|
Packit Service |
392537 |
if (-d $mytape) { rmtree($mytape); }
|
|
Packit Service |
392537 |
mkpath("$mytape/data");
|
|
Packit Service |
392537 |
return $mytape;
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# we'll need some diskflat..
|
|
Packit Service |
392537 |
sub mkdiskflat {
|
|
Packit Service |
392537 |
my ($num) = @_;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $mytape = "$diskflatroot/TESTCONF$num";
|
|
Packit Service |
392537 |
if (-e $mytape) { unlink($mytape); }
|
|
Packit Service |
392537 |
mkpath("$diskflatroot");
|
|
Packit Service |
392537 |
return $mytape;
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# make up a fake dumpfile_t to write with
|
|
Packit Service |
392537 |
my $dumpfile = Amanda::Header->new();
|
|
Packit Service |
392537 |
$dumpfile->{type} = $Amanda::Header::F_DUMPFILE;
|
|
Packit Service |
392537 |
$dumpfile->{datestamp} = "20070102030405";
|
|
Packit Service |
392537 |
$dumpfile->{dumplevel} = 0;
|
|
Packit Service |
392537 |
$dumpfile->{compressed} = 1;
|
|
Packit Service |
392537 |
$dumpfile->{name} = "localhost";
|
|
Packit Service |
392537 |
$dumpfile->{disk} = "/home";
|
|
Packit Service |
392537 |
$dumpfile->{program} = "INSTALLCHECK";
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $write_file_count = 5;
|
|
Packit Service |
392537 |
sub write_file {
|
|
Packit Service |
392537 |
my ($seed, $length, $filenum) = @_;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dumpfile->{'datestamp'} = "2000010101010$filenum";
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start_file($dumpfile),
|
|
Packit Service |
392537 |
"start file $filenum")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->file(), $filenum,
|
|
Packit Service |
392537 |
"Device has correct filenum");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
croak ("selected file size $length is *way* too big")
|
|
Packit Service |
392537 |
unless ($length < 1024*1024*10);
|
|
Packit Service |
392537 |
ok(Amanda::Device::write_random_to_device($seed, $length, $dev),
|
|
Packit Service |
392537 |
"write random data");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
if(ok($dev->in_file(),
|
|
Packit Service |
392537 |
"still in_file")) {
|
|
Packit Service |
392537 |
ok($dev->finish_file(),
|
|
Packit Service |
392537 |
"finish_file")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
} else {
|
|
Packit Service |
392537 |
pass("not in file, so not calling finish_file");
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $verify_file_count = 4;
|
|
Packit Service |
392537 |
sub verify_file {
|
|
Packit Service |
392537 |
my ($seed, $length, $filenum) = @_;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(my $read_dumpfile = $dev->seek_file($filenum),
|
|
Packit Service |
392537 |
"seek to file $filenum")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
is($dev->file(), $filenum,
|
|
Packit Service |
392537 |
"device is really at file $filenum");
|
|
Packit Service |
392537 |
ok(header_for($read_dumpfile, $filenum),
|
|
Packit Service |
392537 |
"header is correct")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
ok(Amanda::Device::verify_random_from_device($seed, $length, $dev),
|
|
Packit Service |
392537 |
"verified file contents");
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
sub header_for {
|
|
Packit Service |
392537 |
my ($hdr, $filenum) = @_;
|
|
Packit Service |
392537 |
return ($hdr and $hdr->{'datestamp'} eq "2000010101010$filenum");
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# properties test
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my @common_properties = (
|
|
Packit Service |
392537 |
'appendable',
|
|
Packit Service |
392537 |
'block_size',
|
|
Packit Service |
392537 |
'canonical_name',
|
|
Packit Service |
392537 |
'concurrency',
|
|
Packit Service |
392537 |
'max_block_size',
|
|
Packit Service |
392537 |
'medium_access_type',
|
|
Packit Service |
392537 |
'min_block_size',
|
|
Packit Service |
392537 |
'partial_deletion',
|
|
Packit Service |
392537 |
'full_deletion',
|
|
Packit Service |
392537 |
'streaming',
|
|
Packit Service |
392537 |
);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
sub properties_include {
|
|
Packit Service |
392537 |
my ($got, $should_include, $msg) = @_;
|
|
Packit Service |
392537 |
my %got = map { $_->{'name'}, 1 } @$got;
|
|
Packit Service |
392537 |
my @missing = grep { !defined($got{$_}) } @$should_include;
|
|
Packit Service |
392537 |
if (@missing) {
|
|
Packit Service |
392537 |
fail($msg);
|
|
Packit Service |
392537 |
diag(" Expected properties: " . join(", ", @$should_include));
|
|
Packit Service |
392537 |
diag(" Got properties: " . join(", ", @$got));
|
|
Packit Service |
392537 |
diag(" Missing properties: " . join(", ", @missing));
|
|
Packit Service |
392537 |
} else {
|
|
Packit Service |
392537 |
pass($msg);
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
####
|
|
Packit Service |
392537 |
## get stuff set up
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$testconf = Installcheck::Config->new();
|
|
Packit Service |
392537 |
$testconf->write();
|
|
Packit Service |
392537 |
config_init($CONFIG_INIT_EXPLICIT_NAME, 'TESTCONF') == $CFGERR_OK
|
|
Packit Service |
392537 |
or die("Could not load configuration");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# put the debug messages somewhere
|
|
Packit Service |
392537 |
Amanda::Debug::dbopen("installcheck");
|
|
Packit Service |
392537 |
Installcheck::log_test_output();
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
####
|
|
Packit Service |
392537 |
## Test errors a little bit
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new("foobar:");
|
|
Packit Service |
392537 |
isnt($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"creation of a bogus 'foobar:' device fails");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new("rait:{{");
|
|
Packit Service |
392537 |
isnt($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"creation of a bogus 'rait:{{' device fails");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new("rait:{a,b");
|
|
Packit Service |
392537 |
isnt($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"creation of a bogus 'rait:{a,b' device fails");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
####
|
|
Packit Service |
392537 |
## first, test out the 'null' device.
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev_name = "null:";
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"create null device")
|
|
Packit Service |
392537 |
or diag $dev->error_or_status();
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, "NULL1", "19780615010203"),
|
|
Packit Service |
392537 |
"start null device in write mode")
|
|
Packit Service |
392537 |
or diag $dev->error_or_status();
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# try properties
|
|
Packit Service |
392537 |
properties_include([ $dev->property_list() ], [ @common_properties ],
|
|
Packit Service |
392537 |
"necessary properties listed on null device");
|
|
Packit Service |
392537 |
is($dev->property_get("canonical_name"), "null:",
|
|
Packit Service |
392537 |
"property_get(canonical_name) on null device");
|
|
Packit Service |
392537 |
is($dev->property_get("caNONical-name"), "null:",
|
|
Packit Service |
392537 |
"property_get(caNONical-name) on null device (case, dash-insensitivity)");
|
|
Packit Service |
392537 |
is_deeply([ $dev->property_get("canonical_name") ],
|
|
Packit Service |
392537 |
[ "null:", $PROPERTY_SURETY_GOOD, $PROPERTY_SOURCE_DEFAULT ],
|
|
Packit Service |
392537 |
"extended property_get returns correct surety/source");
|
|
Packit Service |
392537 |
for my $prop ($dev->property_list()) {
|
|
Packit Service |
392537 |
next unless $prop->{'name'} eq 'canonical_name';
|
|
Packit Service |
392537 |
is($prop->{'description'},
|
|
Packit Service |
392537 |
"The most reliable device name to use to refer to this device.",
|
|
Packit Service |
392537 |
"property info for canonical name is correct");
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
ok(!$dev->property_get("full_deletion"),
|
|
Packit Service |
392537 |
"property_get(full_deletion) on null device");
|
|
Packit Service |
392537 |
is($dev->property_get("comment"), undef,
|
|
Packit Service |
392537 |
"no comment by default");
|
|
Packit Service |
392537 |
ok(!$dev->property_set("comment", "well, that was silly"),
|
|
Packit Service |
392537 |
"set comment property");
|
|
Packit Service |
392537 |
is($dev->property_get("comment"), "well, that was silly",
|
|
Packit Service |
392537 |
"comment correctly stored");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# and write a file to it
|
|
Packit Service |
392537 |
write_file(0xabcde, 1024*256, 1);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# (don't finish the device, testing the finalize method's cleanup)
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
####
|
|
Packit Service |
392537 |
## Now some full device tests
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
## VFS device
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$vtape1 = mkvtape(1);
|
|
Packit Service |
392537 |
$dev_name = "file:$vtape1";
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
properties_include([ $dev->property_list() ],
|
|
Packit Service |
392537 |
[ @common_properties, 'max_volume_usage' ],
|
|
Packit Service |
392537 |
"necessary properties listed on vfs device");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# play with properties a little bit
|
|
Packit Service |
392537 |
is($dev->property_set("comment", 16), undef,
|
|
Packit Service |
392537 |
"set an string property to an integer");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("comment", 16.0), undef,
|
|
Packit Service |
392537 |
"set an string property to a float");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("comment", "hi mom"), undef,
|
|
Packit Service |
392537 |
"set an string property to a string");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("comment", "32768"), undef,
|
|
Packit Service |
392537 |
"set an integer property to a simple string");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("comment", "32k"), undef,
|
|
Packit Service |
392537 |
"set an integer property to a string with a unit");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("block_size", 32768), undef,
|
|
Packit Service |
392537 |
"set an integer property to an integer");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("invalid-property-name", 32768), "No such device-property",
|
|
Packit Service |
392537 |
"set an invalid-property-name");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("block-size", "toto"), "The value is no allowed",
|
|
Packit Service |
392537 |
"set an illegal value");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("block-size", "128km"), "The value is no allowed",
|
|
Packit Service |
392537 |
"set an illegal value");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("streaming", "toto"), "Not allowed to set property",
|
|
Packit Service |
392537 |
"set streaming");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev->read_label();
|
|
Packit Service |
392537 |
ok($dev->status() & $DEVICE_STATUS_VOLUME_UNLABELED,
|
|
Packit Service |
392537 |
"initially unlabeled")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, "TESTCONF13", undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!($dev->status() & $DEVICE_STATUS_VOLUME_UNLABELED),
|
|
Packit Service |
392537 |
"not unlabeled anymore")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
for (my $i = 1; $i <= 3; $i++) {
|
|
Packit Service |
392537 |
write_file(0x2FACE, $dev->block_size()*10+17, $i);
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after write")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev->read_label();
|
|
Packit Service |
392537 |
ok(!($dev->status()),
|
|
Packit Service |
392537 |
"no error, at all, from read_label")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# append one more copy, to test ACCESS_APPEND
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_APPEND, undef, undef),
|
|
Packit Service |
392537 |
"start in append mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
write_file(0xD0ED0E, $dev->block_size()*4, 4);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after append")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# try reading the third file back, creating a new device
|
|
Packit Service |
392537 |
# object first, and skipping the read-label step.
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = undef;
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: re-create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_READ, undef, undef),
|
|
Packit Service |
392537 |
"start in read mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
verify_file(0x2FACE, $dev->block_size()*10+17, 3);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
{
|
|
Packit Service |
392537 |
# try two seek_file's in a row
|
|
Packit Service |
392537 |
my $hdr = $dev->seek_file(3);
|
|
Packit Service |
392537 |
is($hdr? $hdr->{'type'} : -1, $Amanda::Header::F_DUMPFILE, "seek_file the first time");
|
|
Packit Service |
392537 |
$hdr = $dev->seek_file(3);
|
|
Packit Service |
392537 |
is($hdr? $hdr->{'type'} : -1, $Amanda::Header::F_DUMPFILE, "seek_file the second time");
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after read")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# test erase
|
|
Packit Service |
392537 |
ok($dev->erase(),
|
|
Packit Service |
392537 |
"erase device")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->erase(),
|
|
Packit Service |
392537 |
"erase device (again)")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after erase")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# test monitor_free_space property (testing the monitoring would require a
|
|
Packit Service |
392537 |
# dedicated partition for the tests - it's not worth it)
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->property_get("monitor_free_space"),
|
|
Packit Service |
392537 |
"monitor_free_space property is set by default");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("monitor_free_space", 0), undef,
|
|
Packit Service |
392537 |
"monitor_free_space property can be set to false");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!$dev->property_get("monitor_free_space"),
|
|
Packit Service |
392537 |
"monitor_free_space property value 'sticks'");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# test the LEOM functionality
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = undef;
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: re-create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
is($dev->property_set("MAX_VOLUME_USAGE", "512k"), undef,
|
|
Packit Service |
392537 |
"set MAX_VOLUME_USAGE to test LEOM");
|
|
Packit Service |
392537 |
is($dev->property_set("LEOM", 1), undef,
|
|
Packit Service |
392537 |
"set LEOM");
|
|
Packit Service |
392537 |
is($dev->property_set("ENFORCE_MAX_VOLUME_USAGE", 0), undef,
|
|
Packit Service |
392537 |
"set ENFORCE_MAX_VOLUME_USAGE");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, 'TESTCONF23', undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start_file($dumpfile),
|
|
Packit Service |
392537 |
"start file 1")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(Amanda::Device::write_random_to_device(0xCAFE, 440*1024, $dev),
|
|
Packit Service |
392537 |
"write random data into the early-warning zone");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!$dev->is_eom,
|
|
Packit Service |
392537 |
"device does not indicates LEOM after writing when ENFORCE_MAX_VOLUME_USAGE is FALSE");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish_file(),
|
|
Packit Service |
392537 |
"..but a finish_file is allowed to complete")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after LEOM test")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = undef;
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: re-create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
is($dev->property_set("MAX_VOLUME_USAGE", "512k"), undef,
|
|
Packit Service |
392537 |
"set MAX_VOLUME_USAGE to test LEOM");
|
|
Packit Service |
392537 |
is($dev->property_set("LEOM", 1), undef,
|
|
Packit Service |
392537 |
"set LEOM");
|
|
Packit Service |
392537 |
is($dev->property_set("ENFORCE_MAX_VOLUME_USAGE", 1), undef,
|
|
Packit Service |
392537 |
"set ENFORCE_MAX_VOLUME_USAGE");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, 'TESTCONF23', undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start_file($dumpfile),
|
|
Packit Service |
392537 |
"start file 1")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!$dev->is_eom,
|
|
Packit Service |
392537 |
"device does not indicate LEOM before writing");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(Amanda::Device::write_random_to_device(0xCAFE, 440*1024, $dev),
|
|
Packit Service |
392537 |
"write random data into the early-warning zone");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->is_eom,
|
|
Packit Service |
392537 |
"device indicates LEOM after writing");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish_file(),
|
|
Packit Service |
392537 |
"..but a finish_file is allowed to complete")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after LEOM test")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = undef;
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: re-create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
is($dev->property_set("MAX_VOLUME_USAGE", "512k"), undef,
|
|
Packit Service |
392537 |
"set MAX_VOLUME_USAGE to test LEOM");
|
|
Packit Service |
392537 |
is($dev->property_set("LEOM", 1), undef,
|
|
Packit Service |
392537 |
"set LEOM");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, 'TESTCONF23', undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start_file($dumpfile),
|
|
Packit Service |
392537 |
"start file 1")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!$dev->is_eom,
|
|
Packit Service |
392537 |
"device does not indicate LEOM before writing");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(Amanda::Device::write_random_to_device(0xCAFE, 440*1024, $dev),
|
|
Packit Service |
392537 |
"write random data into the early-warning zone");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->is_eom,
|
|
Packit Service |
392537 |
"device indicates LEOM after writing as default value of ENFORCE_MAX_VOLUME_USAGE is true for vfs device");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish_file(),
|
|
Packit Service |
392537 |
"..but a finish_file is allowed to complete")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after LEOM test")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = undef;
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: re-create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
is($dev->property_set("MAX_VOLUME_USAGE", "160k"), undef,
|
|
Packit Service |
392537 |
"set MAX_VOLUME_USAGE to test LEOM while writing the first header");
|
|
Packit Service |
392537 |
is($dev->property_set("LEOM", 1), undef,
|
|
Packit Service |
392537 |
"set LEOM");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, 'TESTCONF23', undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start_file($dumpfile),
|
|
Packit Service |
392537 |
"start file 1")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->is_eom,
|
|
Packit Service |
392537 |
"device indicates LEOM after writing first header");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish_file(),
|
|
Packit Service |
392537 |
"..but a finish_file is allowed to complete")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after LEOM test")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
####
|
|
Packit Service |
392537 |
## Now some full device tests
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
## DISKFLAT device
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $diskflat1 = mkdiskflat(13);
|
|
Packit Service |
392537 |
$dev_name = "diskflat:$diskflat1";
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
properties_include([ $dev->property_list() ],
|
|
Packit Service |
392537 |
[ @common_properties, 'max_volume_usage' ],
|
|
Packit Service |
392537 |
"necessary properties listed on diskflat device");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# play with properties a little bit
|
|
Packit Service |
392537 |
is($dev->property_set("comment", 16), undef,
|
|
Packit Service |
392537 |
"set an string property to an integer");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("comment", 16.0), undef,
|
|
Packit Service |
392537 |
"set an string property to a float");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("comment", "hi mom"), undef,
|
|
Packit Service |
392537 |
"set an string property to a string");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("comment", "32768"), undef,
|
|
Packit Service |
392537 |
"set an integer property to a simple string");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("comment", "32k"), undef,
|
|
Packit Service |
392537 |
"set an integer property to a string with a unit");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("block_size", 32768), undef,
|
|
Packit Service |
392537 |
"set an integer property to an integer");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("invalid-property-name", 32768), "No such device-property",
|
|
Packit Service |
392537 |
"set an invalid-property-name");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev->read_label();
|
|
Packit Service |
392537 |
ok($dev->status() & $DEVICE_STATUS_VOLUME_UNLABELED,
|
|
Packit Service |
392537 |
"initially unlabeled")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, "TESTCONF13", undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!($dev->status() & $DEVICE_STATUS_VOLUME_UNLABELED),
|
|
Packit Service |
392537 |
"not unlabeled anymore")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
write_file(0x2FACE, $dev->block_size()*10+17, 1);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# try to write a second file
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!$dev->start_file($dumpfile),
|
|
Packit Service |
392537 |
"start_file of seconf file failed")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->error_or_status() eq "Can't write more than one file to the diskflat device",
|
|
Packit Service |
392537 |
"error message is correct")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after write")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev->read_label();
|
|
Packit Service |
392537 |
ok(!($dev->status()),
|
|
Packit Service |
392537 |
"no error, at all, from read_label")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# try reading the first file back, creating a new device
|
|
Packit Service |
392537 |
# object first, and skipping the read-label step.
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = undef;
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: re-create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_READ, undef, undef),
|
|
Packit Service |
392537 |
"start in read mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
verify_file(0x2FACE, $dev->block_size()*10+17, 1);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after read")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# test erase
|
|
Packit Service |
392537 |
ok($dev->erase(),
|
|
Packit Service |
392537 |
"erase device")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->erase(),
|
|
Packit Service |
392537 |
"erase device (again)")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after erase")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# test monitor_free_space property (testing the monitoring would require a
|
|
Packit Service |
392537 |
# dedicated partition for the tests - it's not worth it)
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->property_get("monitor_free_space"),
|
|
Packit Service |
392537 |
"monitor_free_space property is set by default");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("monitor_free_space", 0), undef,
|
|
Packit Service |
392537 |
"monitor_free_space property can be set to false");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!$dev->property_get("monitor_free_space"),
|
|
Packit Service |
392537 |
"monitor_free_space property value 'sticks'");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# test the LEOM functionality
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = undef;
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: re-create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
is($dev->property_set("MAX_VOLUME_USAGE", "512k"), undef,
|
|
Packit Service |
392537 |
"set MAX_VOLUME_USAGE to test LEOM");
|
|
Packit Service |
392537 |
is($dev->property_set("LEOM", 1), undef,
|
|
Packit Service |
392537 |
"set LEOM");
|
|
Packit Service |
392537 |
is($dev->property_set("ENFORCE_MAX_VOLUME_USAGE", 0), undef,
|
|
Packit Service |
392537 |
"set ENFORCE_MAX_VOLUME_USAGE");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, 'TESTCONF23', undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start_file($dumpfile),
|
|
Packit Service |
392537 |
"start file 1")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(Amanda::Device::write_random_to_device(0xCAFE, 440*1024, $dev),
|
|
Packit Service |
392537 |
"write random data into the early-warning zone");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!$dev->is_eom,
|
|
Packit Service |
392537 |
"device does not indicates LEOM after writing when ENFORCE_MAX_VOLUME_USAGE is FALSE");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish_file(),
|
|
Packit Service |
392537 |
"..but a finish_file is allowed to complete")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after LEOM test")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = undef;
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: re-create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
is($dev->property_set("MAX_VOLUME_USAGE", "512k"), undef,
|
|
Packit Service |
392537 |
"set MAX_VOLUME_USAGE to test LEOM");
|
|
Packit Service |
392537 |
is($dev->property_set("LEOM", 1), undef,
|
|
Packit Service |
392537 |
"set LEOM");
|
|
Packit Service |
392537 |
is($dev->property_set("ENFORCE_MAX_VOLUME_USAGE", 1), undef,
|
|
Packit Service |
392537 |
"set ENFORCE_MAX_VOLUME_USAGE");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, 'TESTCONF23', undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start_file($dumpfile),
|
|
Packit Service |
392537 |
"start file 1")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!$dev->is_eom,
|
|
Packit Service |
392537 |
"device does not indicate LEOM before writing");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(Amanda::Device::write_random_to_device(0xCAFE, 440*1024, $dev),
|
|
Packit Service |
392537 |
"write random data into the early-warning zone");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->is_eom,
|
|
Packit Service |
392537 |
"device indicates LEOM after writing");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish_file(),
|
|
Packit Service |
392537 |
"..but a finish_file is allowed to complete")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after LEOM test")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = undef;
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: re-create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
is($dev->property_set("MAX_VOLUME_USAGE", "512k"), undef,
|
|
Packit Service |
392537 |
"set MAX_VOLUME_USAGE to test LEOM");
|
|
Packit Service |
392537 |
is($dev->property_set("LEOM", 1), undef,
|
|
Packit Service |
392537 |
"set LEOM");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, 'TESTCONF23', undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start_file($dumpfile),
|
|
Packit Service |
392537 |
"start file 1")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!$dev->is_eom,
|
|
Packit Service |
392537 |
"device does not indicate LEOM before writing");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(Amanda::Device::write_random_to_device(0xCAFE, 440*1024, $dev),
|
|
Packit Service |
392537 |
"write random data into the early-warning zone");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->is_eom,
|
|
Packit Service |
392537 |
"device indicates LEOM after writing as default value of ENFORCE_MAX_VOLUME_USAGE is true for vfs device");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish_file(),
|
|
Packit Service |
392537 |
"..but a finish_file is allowed to complete")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after LEOM test")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = undef;
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: re-create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
is($dev->property_set("MAX_VOLUME_USAGE", "160k"), undef,
|
|
Packit Service |
392537 |
"set MAX_VOLUME_USAGE to test LEOM while writing the first header");
|
|
Packit Service |
392537 |
is($dev->property_set("LEOM", 1), undef,
|
|
Packit Service |
392537 |
"set LEOM");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, 'TESTCONF23', undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start_file($dumpfile),
|
|
Packit Service |
392537 |
"start file 1")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->is_eom,
|
|
Packit Service |
392537 |
"device indicates LEOM after writing first header");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish_file(),
|
|
Packit Service |
392537 |
"..but a finish_file is allowed to complete")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after LEOM test")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
## dvdrw device
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
SKIP: {
|
|
Packit Service |
392537 |
skip "not built with ndmp and server", 7 unless
|
|
Packit Service |
392537 |
$Amanda::Constants::AMANDA_DEVICES =~ /dvdrw/;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$vtape1 = mkvtape(1);
|
|
Packit Service |
392537 |
$dev_name = "dvdrw:$vtape1:/dev/scd0";
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
properties_include([ $dev->property_list() ],
|
|
Packit Service |
392537 |
[ @common_properties, 'max_volume_usage' ],
|
|
Packit Service |
392537 |
"necessary properties listed on vfs device");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# play with properties a little bit
|
|
Packit Service |
392537 |
is($dev->property_set("DVDRW_GROWISOFS_COMMAND", "/path/to/growisofs"), undef,
|
|
Packit Service |
392537 |
"set DVDRW_GROWISOFS_COMMAND");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("dvdrw_mount_command", "/path/to/mount"), undef,
|
|
Packit Service |
392537 |
"set dvdrw_mount_command");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("dvdrw_umount_command", "/path/to/umount"), undef,
|
|
Packit Service |
392537 |
"set dvdrw_umount_command");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("block_size", 32768), undef,
|
|
Packit Service |
392537 |
"set an integer property to an integer");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("invalid-property-name", 32768), 'No such device-property',
|
|
Packit Service |
392537 |
"set an invalid-property-name");
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
####
|
|
Packit Service |
392537 |
## Test a RAIT device of two vfs devices.
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
($vtape1, $vtape2) = (mkvtape(1), mkvtape(2));
|
|
Packit Service |
392537 |
$dev_name = "rait:file:{$vtape1,$vtape2}";
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->configure(1), "configure device");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
properties_include([ $dev->property_list() ], [ @common_properties ],
|
|
Packit Service |
392537 |
"necessary properties listed on rait device");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_get("block_size"), 32768, # (RAIT default)
|
|
Packit Service |
392537 |
"rait device calculates a default block size correctly");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("block_size", 524288), undef,
|
|
Packit Service |
392537 |
"rait device accepts an explicit block size");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_get("block_size"), 32768*16,
|
|
Packit Service |
392537 |
"..and remembers it");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("max_volume_usage", 32768*1000), undef,
|
|
Packit Service |
392537 |
"rait device accepts property MAX_VOLUME_USAGE");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_get("max_volume_usage"), 32768*1000,
|
|
Packit Service |
392537 |
"..and remembers it");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev->read_label();
|
|
Packit Service |
392537 |
ok($dev->status() & $DEVICE_STATUS_VOLUME_UNLABELED,
|
|
Packit Service |
392537 |
"initially unlabeled")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, "TESTCONF13", undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!($dev->status() & $DEVICE_STATUS_VOLUME_UNLABELED),
|
|
Packit Service |
392537 |
"not unlabeled anymore")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
for (my $i = 1; $i <= 3; $i++) {
|
|
Packit Service |
392537 |
write_file(0x2FACE, $dev->block_size()*10+17, $i);
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after write")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev->read_label();
|
|
Packit Service |
392537 |
ok(!($dev->status()),
|
|
Packit Service |
392537 |
"no error, at all, from read_label")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# append one more copy, to test ACCESS_APPEND
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_APPEND, undef, undef),
|
|
Packit Service |
392537 |
"start in append mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
write_file(0xD0ED0E, $dev->block_size()*4, 4);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after append")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# try reading the third file back, creating a new device
|
|
Packit Service |
392537 |
# object first, and skipping the read-label step.
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = undef;
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: re-create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_READ, undef, undef),
|
|
Packit Service |
392537 |
"start in read mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
verify_file(0x2FACE, $dev->block_size()*10+17, 3);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after read")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_READ, undef, undef),
|
|
Packit Service |
392537 |
"start in read mode after missing volume")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# corrupt the device somehow and hope it keeps working
|
|
Packit Service |
392537 |
rmtree("$taperoot/1");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
verify_file(0x2FACE, $dev->block_size()*10+17, 3);
|
|
Packit Service |
392537 |
verify_file(0xD0ED0E, $dev->block_size()*4, 4);
|
|
Packit Service |
392537 |
verify_file(0x2FACE, $dev->block_size()*10+17, 2);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device read after missing volume")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!($dev->start($ACCESS_WRITE, "TESTCONF29", undef)),
|
|
Packit Service |
392537 |
"start in write mode fails with missing volume")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
undef $dev;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev_name = "rait:{file:$vtape2,MISSING}";
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_READ, undef, undef),
|
|
Packit Service |
392537 |
"start in read mode with MISSING")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
verify_file(0x2FACE, $dev->block_size()*10+17, 3);
|
|
Packit Service |
392537 |
verify_file(0xD0ED0E, $dev->block_size()*4, 4);
|
|
Packit Service |
392537 |
verify_file(0x2FACE, $dev->block_size()*10+17, 2);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device read with MISSING")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!($dev->start($ACCESS_WRITE, "TESTCONF29", undef)),
|
|
Packit Service |
392537 |
"start in write mode fails with MISSING")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
undef $dev;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new_rait_from_children(
|
|
Packit Service |
392537 |
Amanda::Device->new("file:$vtape2"), undef);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!($dev->start($ACCESS_WRITE, "TESTCONF29", undef)),
|
|
Packit Service |
392537 |
"start a RAIT device in write mode fails, when created with 'undef'")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# Make two devices with different labels, should get a
|
|
Packit Service |
392537 |
# message accordingly.
|
|
Packit Service |
392537 |
($vtape1, $vtape2) = (mkvtape(1), mkvtape(2));
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $n = 13;
|
|
Packit Service |
392537 |
for $dev_name ("file:$vtape1", "file:$vtape2") {
|
|
Packit Service |
392537 |
my $dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: Open successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, "TESTCONF$n", undef),
|
|
Packit Service |
392537 |
"wrote label 'TESTCONF$n'");
|
|
Packit Service |
392537 |
ok($dev->finish(), "finished device");
|
|
Packit Service |
392537 |
$n++;
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new_rait_from_children(
|
|
Packit Service |
392537 |
Amanda::Device->new("file:$vtape1"),
|
|
Packit Service |
392537 |
Amanda::Device->new("file:$vtape2"));
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"new_rait_from_children: Open successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev->read_label();
|
|
Packit Service |
392537 |
ok($dev->status() & $DEVICE_STATUS_VOLUME_ERROR,
|
|
Packit Service |
392537 |
"Label mismatch error handled correctly")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# Use some config to set a block size on a child device
|
|
Packit Service |
392537 |
($vtape1, $vtape2) = (mkvtape(1), mkvtape(2));
|
|
Packit Service |
392537 |
$dev_name = "rait:{file:$vtape1,mytape2}";
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$testconf = Installcheck::Config->new();
|
|
Packit Service |
392537 |
$testconf->add_device("mytape2", [
|
|
Packit Service |
392537 |
"tapedev" => "\"file:$vtape2\"",
|
|
Packit Service |
392537 |
"device_property" => "\"BLOCK_SIZE\" \"64k\""
|
|
Packit Service |
392537 |
]);
|
|
Packit Service |
392537 |
$testconf->write();
|
|
Packit Service |
392537 |
config_init($CONFIG_INIT_EXPLICIT_NAME, 'TESTCONF') == $CFGERR_OK
|
|
Packit Service |
392537 |
or die("Could not load configuration");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->configure(1), "configure device");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_get("block_size"), 65536,
|
|
Packit Service |
392537 |
"rait device calculates a block size from its children correctly");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# Test an S3 device if the proper environment variables are set
|
|
Packit Service |
392537 |
my $S3_SECRET_KEY = $ENV{'INSTALLCHECK_S3_SECRET_KEY'};
|
|
Packit Service |
392537 |
my $S3_ACCESS_KEY = $ENV{'INSTALLCHECK_S3_ACCESS_KEY'};
|
|
Packit Service |
392537 |
my $DEVPAY_SECRET_KEY = $ENV{'INSTALLCHECK_DEVPAY_SECRET_KEY'};
|
|
Packit Service |
392537 |
my $DEVPAY_ACCESS_KEY = $ENV{'INSTALLCHECK_DEVPAY_ACCESS_KEY'};
|
|
Packit Service |
392537 |
my $DEVPAY_USER_TOKEN = $ENV{'INSTALLCHECK_DEVPAY_USER_TOKEN'};
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $run_s3_tests = defined $S3_SECRET_KEY && defined $S3_ACCESS_KEY;
|
|
Packit Service |
392537 |
my $run_devpay_tests = defined $DEVPAY_SECRET_KEY &&
|
|
Packit Service |
392537 |
defined $DEVPAY_ACCESS_KEY && $DEVPAY_USER_TOKEN;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $s3_make_device_count = 7;
|
|
Packit Service |
392537 |
sub s3_make_device($$) {
|
|
Packit Service |
392537 |
my ($dev_name, $kind) = @_;
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my @s3_props = ( 's3_access_key', 's3_secret_key' );
|
|
Packit Service |
392537 |
push @s3_props, 's3_user_token' if ($kind eq "devpay");
|
|
Packit Service |
392537 |
properties_include([ $dev->property_list() ], [ @common_properties, @s3_props ],
|
|
Packit Service |
392537 |
"necessary properties listed on s3 device");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set('BLOCK_SIZE', 32768*2), undef,
|
|
Packit Service |
392537 |
"set block size")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# might as well save a few cents while testing this property..
|
|
Packit Service |
392537 |
is($dev->property_set('S3_STORAGE_CLASS', 'REDUCED_REDUNDANCY'), undef,
|
|
Packit Service |
392537 |
"set storage class")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
if ($kind eq "s3") {
|
|
Packit Service |
392537 |
# use regular S3 credentials
|
|
Packit Service |
392537 |
is($dev->property_set('S3_ACCESS_KEY', $S3_ACCESS_KEY), undef,
|
|
Packit Service |
392537 |
"set S3 access key")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set('S3_SECRET_KEY', $S3_SECRET_KEY), undef,
|
|
Packit Service |
392537 |
"set S3 secret key")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
pass("(placeholder)");
|
|
Packit Service |
392537 |
} elsif ($kind eq "devpay") {
|
|
Packit Service |
392537 |
# use devpay credentials
|
|
Packit Service |
392537 |
is($dev->property_set('S3_ACCESS_KEY', $DEVPAY_ACCESS_KEY), undef,
|
|
Packit Service |
392537 |
"set devpay access key")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set('S3_SECRET_KEY', $DEVPAY_SECRET_KEY), undef,
|
|
Packit Service |
392537 |
"set devpay secret key")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set('S3_USER_TOKEN', $DEVPAY_USER_TOKEN), undef,
|
|
Packit Service |
392537 |
"set devpay user token")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
} else {
|
|
Packit Service |
392537 |
croak("didn't recognize the device kind, so no credentials were set");
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
return $dev;
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $base_name;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
SKIP: {
|
|
Packit Service |
392537 |
skip "define \$INSTALLCHECK_S3_{SECRET,ACCESS}_KEY to run S3 tests",
|
|
Packit Service |
392537 |
104 +
|
|
Packit Service |
392537 |
1 * $verify_file_count +
|
|
Packit Service |
392537 |
7 * $write_file_count +
|
|
Packit Service |
392537 |
14 * $s3_make_device_count
|
|
Packit Service |
392537 |
unless $run_s3_tests;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev_name = "s3:";
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
isnt($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"creating $dev_name fails miserably");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev_name = "s3:foo";
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->property_get("full_deletion"),
|
|
Packit Service |
392537 |
"property_get(full_deletion) on s3 device");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->property_get("leom"),
|
|
Packit Service |
392537 |
"property_get(leom) on s3 device");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# test parsing of boolean values
|
|
Packit Service |
392537 |
# (s3 is the only device driver that has a writable boolean property at the
|
|
Packit Service |
392537 |
# moment)
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my @verbose_vals = (
|
|
Packit Service |
392537 |
{'val' => '1', 'true' => 1},
|
|
Packit Service |
392537 |
{'val' => '0', 'true' => 0},
|
|
Packit Service |
392537 |
{'val' => 't', 'true' => 1},
|
|
Packit Service |
392537 |
{'val' => 'true', 'true' => 1},
|
|
Packit Service |
392537 |
{'val' => 'f', 'true' => 0},
|
|
Packit Service |
392537 |
{'val' => 'false', 'true' => 0},
|
|
Packit Service |
392537 |
{'val' => 'y', 'true' => 1},
|
|
Packit Service |
392537 |
{'val' => 'yes', 'true' => 1},
|
|
Packit Service |
392537 |
{'val' => 'n', 'true' => 0},
|
|
Packit Service |
392537 |
{'val' => 'no', 'true' => 0},
|
|
Packit Service |
392537 |
{'val' => 'on', 'true' => 1},
|
|
Packit Service |
392537 |
{'val' => 'off', 'true' => 0},
|
|
Packit Service |
392537 |
{'val' => 'oFf', 'true' => 0},
|
|
Packit Service |
392537 |
);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
foreach my $v (@verbose_vals) {
|
|
Packit Service |
392537 |
$dev_name = "s3:foo";
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$testconf = Installcheck::Config->new();
|
|
Packit Service |
392537 |
$testconf->add_param("device_property", "\"verbose\" \"$v->{'val'}\"");
|
|
Packit Service |
392537 |
$testconf->write();
|
|
Packit Service |
392537 |
config_init($CONFIG_INIT_EXPLICIT_NAME, 'TESTCONF') == $CFGERR_OK
|
|
Packit Service |
392537 |
or die("Could not load configuration");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->configure(1),
|
|
Packit Service |
392537 |
"configured device with verbose set to $v->{'val'}")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $get_val = $dev->property_get('verbose');
|
|
Packit Service |
392537 |
# see if truth-iness matches
|
|
Packit Service |
392537 |
my $expec = $v->{'true'}? "true" : "false";
|
|
Packit Service |
392537 |
is(!!$dev->property_get('verbose'), !!$v->{'true'},
|
|
Packit Service |
392537 |
"device_property 'VERBOSE' '$v->{'val'}' => property_get(verbose) returning $expec");
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# test unparsable property
|
|
Packit Service |
392537 |
$dev_name = "s3:foo";
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$testconf = Installcheck::Config->new();
|
|
Packit Service |
392537 |
$testconf->add_param("device_property", "\"verbose\" \"foo\"");
|
|
Packit Service |
392537 |
$testconf->write();
|
|
Packit Service |
392537 |
config_init($CONFIG_INIT_EXPLICIT_NAME, 'TESTCONF') == $CFGERR_OK
|
|
Packit Service |
392537 |
or die("Could not load configuration");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!$dev->configure(1),
|
|
Packit Service |
392537 |
"failed to configure device with verbose set to foo");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
like($dev->error_or_status(), qr/'verbose'/,
|
|
Packit Service |
392537 |
"error message mentions property name");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
like($dev->error_or_status(), qr/'foo'/,
|
|
Packit Service |
392537 |
"error message mentions property value");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
like($dev->error_or_status(), qr/gboolean/,
|
|
Packit Service |
392537 |
"error message mentions property type");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $hostname = hostname();
|
|
Packit Service |
392537 |
$hostname =~ s/\./-/g;
|
|
Packit Service |
392537 |
$base_name = "$S3_ACCESS_KEY-installcheck-$hostname";
|
|
Packit Service |
392537 |
# strip $base_name too long
|
|
Packit Service |
392537 |
if (length($base_name)> 52) {
|
|
Packit Service |
392537 |
$base_name =~ s/buildbot/bb/g;
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
if (length($base_name)> 52) {
|
|
Packit Service |
392537 |
$base_name =~ s/dhcp-//g;
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
if (length($base_name)> 52) {
|
|
Packit Service |
392537 |
$base_name =~ s/zmanda-com/zc/g;
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev_name = "s3:$base_name-s3-1";
|
|
Packit Service |
392537 |
$dev = s3_make_device($dev_name, "s3");
|
|
Packit Service |
392537 |
$dev->read_label();
|
|
Packit Service |
392537 |
my $status = $dev->status();
|
|
Packit Service |
392537 |
# this test appears very liberal, but catches the case where setup_handle fails without
|
|
Packit Service |
392537 |
# giving false positives
|
|
Packit Service |
392537 |
ok(($status == $DEVICE_STATUS_SUCCESS) || (($status & $DEVICE_STATUS_VOLUME_UNLABELED) != 0),
|
|
Packit Service |
392537 |
"status is either OK or possibly unlabeled")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, "TESTCONF13", undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!($dev->status() & $DEVICE_STATUS_VOLUME_UNLABELED),
|
|
Packit Service |
392537 |
"it's labeled now")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
for (my $i = 1; $i <= 3; $i++) {
|
|
Packit Service |
392537 |
write_file(0x2FACE, $dev->block_size()*10, $i);
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after write")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev->read_label();
|
|
Packit Service |
392537 |
ok(!($dev->status()),
|
|
Packit Service |
392537 |
"no error, at all, from read_label")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# append one more copy, to test ACCESS_APPEND
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_APPEND, undef, undef),
|
|
Packit Service |
392537 |
"start in append mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
write_file(0xD0ED0E, $dev->block_size()*10, 4);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after append")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# try reading the third file back
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_READ, undef, undef),
|
|
Packit Service |
392537 |
"start in read mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
verify_file(0x2FACE, $dev->block_size()*10, 3);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# test EOT indications on reading
|
|
Packit Service |
392537 |
my $hdr = $dev->seek_file(4);
|
|
Packit Service |
392537 |
is($hdr->{'type'}, $Amanda::Header::F_DUMPFILE,
|
|
Packit Service |
392537 |
"file 4 has correct type F_DUMPFILE");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$hdr = $dev->seek_file(5);
|
|
Packit Service |
392537 |
is($hdr->{'type'}, $Amanda::Header::F_TAPEEND,
|
|
Packit Service |
392537 |
"file 5 has correct type F_TAPEEND");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$hdr = $dev->seek_file(6);
|
|
Packit Service |
392537 |
is($hdr, undef, "seek_file returns undef for file 6");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after read")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status()); # (note: we don't use write_max_size here,
|
|
Packit Service |
392537 |
# as the maximum for S3 is very large)
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->erase(),
|
|
Packit Service |
392537 |
"erase device")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->erase(),
|
|
Packit Service |
392537 |
"erase device (again)")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after erase")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev->read_label();
|
|
Packit Service |
392537 |
$status = $dev->status();
|
|
Packit Service |
392537 |
ok($status & $DEVICE_STATUS_VOLUME_UNLABELED,
|
|
Packit Service |
392537 |
"status is unlabeled after an erase")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->erase(),
|
|
Packit Service |
392537 |
"erase device")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev_name = "s3:$base_name-s3-2";
|
|
Packit Service |
392537 |
$dev = s3_make_device($dev_name, "s3");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->erase(),
|
|
Packit Service |
392537 |
"erase device right after creation")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev_name = "s3:$base_name-s3-3";
|
|
Packit Service |
392537 |
$dev = s3_make_device($dev_name, "s3");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# set MAX_VOLUME_USAGE, LEOM=true, ENFORCE_MAX_VOLUME_USAGE=false
|
|
Packit Service |
392537 |
is($dev->property_set('MAX_VOLUME_USAGE', "512k"), undef,
|
|
Packit Service |
392537 |
"set MAX_VOLUME_USAGE to test LEOM");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("LEOM", 1), undef,
|
|
Packit Service |
392537 |
"set LEOM");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, "TESTCONF13", undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
write_file(0x2FACE, 440*1024, 1);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!$dev->is_eom,
|
|
Packit Service |
392537 |
"device does not indicate LEOM after writing as property ENFORCE_MAX_VOLUME_USAGE not set and its default value is false");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after LEOM test")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->erase(),
|
|
Packit Service |
392537 |
"erase device")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev_name = "s3:$base_name-s3-4";
|
|
Packit Service |
392537 |
$dev = s3_make_device($dev_name, "s3");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# set MAX_VOLUME_USAGE, LEOM=true, ENFORCE_MAX_VOLUME_USAGE=true
|
|
Packit Service |
392537 |
is($dev->property_set('MAX_VOLUME_USAGE', "512k"), undef,
|
|
Packit Service |
392537 |
"set MAX_VOLUME_USAGE to test LEOM");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set('ENFORCE_MAX_VOLUME_USAGE', 1 ), undef,
|
|
Packit Service |
392537 |
"set ENFORCE_MAX_VOLUME_USAGE");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("LEOM", 1), undef,
|
|
Packit Service |
392537 |
"set LEOM");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, "TESTCONF13", undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
write_file(0x2FACE, 440*1024, 1);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->is_eom,
|
|
Packit Service |
392537 |
"device indicates LEOM after writing, when property ENFORCE_MAX_VOLUME_USAGE set to true");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after LEOM test")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->erase(),
|
|
Packit Service |
392537 |
"erase device")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev_name = "s3:$base_name-s3-5";
|
|
Packit Service |
392537 |
$dev = s3_make_device($dev_name, "s3");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# set MAX_VOLUME_USAGE, LEOM=true, ENFORCE_MAX_VOLUME_USAGE=false
|
|
Packit Service |
392537 |
is($dev->property_set('MAX_VOLUME_USAGE', "512k"), undef,
|
|
Packit Service |
392537 |
"set MAX_VOLUME_USAGE to test LEOM");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set('ENFORCE_MAX_VOLUME_USAGE', 0 ), undef,
|
|
Packit Service |
392537 |
"set ENFORCE_MAX_VOLUME_USAGE");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("LEOM", 1), undef,
|
|
Packit Service |
392537 |
"set LEOM");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, "TESTCONF13", undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
write_file(0x2FACE, 440*1024, 1);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!$dev->is_eom,
|
|
Packit Service |
392537 |
"device does not indicate LEOM after writing, when property ENFORCE_MAX_VOLUME_USAGE set to false");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after LEOM test")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->erase(),
|
|
Packit Service |
392537 |
"erase device")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# try with empty user token
|
|
Packit Service |
392537 |
$dev_name = lc("s3:$base_name-s3-6");
|
|
Packit Service |
392537 |
$dev = s3_make_device($dev_name, "s3");
|
|
Packit Service |
392537 |
is($dev->property_set('S3_USER_TOKEN', ''), undef,
|
|
Packit Service |
392537 |
"set devpay user token")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev->read_label();
|
|
Packit Service |
392537 |
$status = $dev->status();
|
|
Packit Service |
392537 |
ok(($status == $DEVICE_STATUS_SUCCESS) || (($status & $DEVICE_STATUS_VOLUME_UNLABELED) != 0),
|
|
Packit Service |
392537 |
"status is either OK or possibly unlabeled")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev->finish();
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->erase(),
|
|
Packit Service |
392537 |
"erase device")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# try a eu-constrained bucket
|
|
Packit Service |
392537 |
$dev_name = lc("s3:$base_name-s3-eu");
|
|
Packit Service |
392537 |
$dev = s3_make_device($dev_name, "s3");
|
|
Packit Service |
392537 |
is($dev->property_set('S3_BUCKET_LOCATION', 'EU'), undef,
|
|
Packit Service |
392537 |
"set S3 bucket location to 'EU'")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, "TESTCONF13", undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"status is OK")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev->finish();
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->erase(),
|
|
Packit Service |
392537 |
"erase device")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# try a wildcard-constrained bucket
|
|
Packit Service |
392537 |
$dev_name = lc("s3:$base_name-s3-wild");
|
|
Packit Service |
392537 |
$dev = s3_make_device($dev_name, "s3");
|
|
Packit Service |
392537 |
is($dev->property_set('S3_BUCKET_LOCATION', '*'), undef,
|
|
Packit Service |
392537 |
"set S3 bucket location to '*'")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, "TESTCONF13", undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"status is OK")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev->finish();
|
|
Packit Service |
392537 |
ok($dev->erase(),
|
|
Packit Service |
392537 |
"erase device")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# test again with invalid ca_info
|
|
Packit Service |
392537 |
$dev_name = lc("s3:$base_name-s3-ca");
|
|
Packit Service |
392537 |
$dev = s3_make_device($dev_name, "s3");
|
|
Packit Service |
392537 |
SKIP: {
|
|
Packit Service |
392537 |
skip "SSL not supported; can't check SSL_CA_INFO", 2
|
|
Packit Service |
392537 |
unless $dev->property_get('S3_SSL');
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set('SSL_CA_INFO', '/dev/null'), undef,
|
|
Packit Service |
392537 |
"set invalid SSL/TLS CA certificate")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!$dev->start($ACCESS_WRITE, "TESTCONF13", undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
isnt($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"status is OK")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev->finish();
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# test again with our own CA bundle
|
|
Packit Service |
392537 |
$dev_name = lc("s3:$base_name-s3-oca");
|
|
Packit Service |
392537 |
$dev = s3_make_device($dev_name, "s3");
|
|
Packit Service |
392537 |
SKIP: {
|
|
Packit Service |
392537 |
skip "SSL not supported; can't check SSL_CA_INFO", 4
|
|
Packit Service |
392537 |
unless $dev->property_get('S3_SSL');
|
|
Packit Service |
392537 |
is($dev->property_set('SSL_CA_INFO', "$srcdir/data/aws-bundle.crt"), undef,
|
|
Packit Service |
392537 |
"set our own SSL/TLS CA certificate bundle")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->erase(),
|
|
Packit Service |
392537 |
"erase device")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, "TESTCONF13", undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"status is OK")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev->finish();
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->erase(),
|
|
Packit Service |
392537 |
"erase device")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# bucket names incompatible with location constraint
|
|
Packit Service |
392537 |
$dev_name = "s3:-$base_name-s3-eu-2";
|
|
Packit Service |
392537 |
$dev = s3_make_device($dev_name, "s3");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set('S3_BUCKET_LOCATION', ''), undef,
|
|
Packit Service |
392537 |
"should be able to set an empty S3 bucket location with an incompatible name")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev_name = "s3:$base_name-s3.eu-3";
|
|
Packit Service |
392537 |
$dev = s3_make_device($dev_name, "s3");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set('S3_BUCKET_LOCATION', ''), undef,
|
|
Packit Service |
392537 |
"should be able to set an empty S3 bucket location with an incompatible name")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev_name = "s3:-$base_name-s3-eu";
|
|
Packit Service |
392537 |
$dev = s3_make_device($dev_name, "s3");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set('S3_BUCKET_LOCATION', 'EU'), "Location constraint given for Amazon S3 bucket, but the bucket name (-$base_name-s3-eu) is not usable as a subdomain.",
|
|
Packit Service |
392537 |
"should not be able to set S3 bucket location with an incompatible name")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev_name = lc("s3:$base_name-s3-eu-4");
|
|
Packit Service |
392537 |
$dev = s3_make_device($dev_name, "s3");
|
|
Packit Service |
392537 |
is($dev->property_set('S3_BUCKET_LOCATION', 'XYZ'), undef,
|
|
Packit Service |
392537 |
"should be able to set S3 bucket location with a compatible name")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
$dev->read_label();
|
|
Packit Service |
392537 |
$status = $dev->status();
|
|
Packit Service |
392537 |
ok(($status == $DEVICE_STATUS_DEVICE_ERROR),
|
|
Packit Service |
392537 |
"status is DEVICE_STATUS_DEVICE_ERROR")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
my $error_msg = $dev->error_or_status();
|
|
Packit Service |
392537 |
ok(($dev->error_or_status() == "While creating new S3 bucket: The specified location-constraint is not valid (Unknown) (HTTP 400)"),
|
|
Packit Service |
392537 |
"invalid location-constraint")
|
|
Packit Service |
392537 |
or diag("bad error: " . $dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev_name = "s3:TESTCONF-s3_eu_2";
|
|
Packit Service |
392537 |
$dev = s3_make_device($dev_name, "s3");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set('S3_SUBDOMAIN', 'ON'), 'S3-SUBDOMAIN is set, but the bucket name (TESTCONF-s3_eu_2) is not usable as a subdomain, only [a-zo-9-] characters are allowed.',
|
|
Packit Service |
392537 |
"should be able to set an empty S3_SUBDOMAIN with an incompatible name")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
SKIP: {
|
|
Packit Service |
392537 |
# in this case, most of our code has already been exercised
|
|
Packit Service |
392537 |
# just make sure that authentication works as a basic sanity check
|
|
Packit Service |
392537 |
skip "skipping abbreviated devpay tests", $s3_make_device_count + 1
|
|
Packit Service |
392537 |
unless $run_devpay_tests;
|
|
Packit Service |
392537 |
$dev_name = "s3:$base_name-devpay";
|
|
Packit Service |
392537 |
$dev = s3_make_device($dev_name, "devpay");
|
|
Packit Service |
392537 |
$dev->read_label();
|
|
Packit Service |
392537 |
my $status = $dev->status();
|
|
Packit Service |
392537 |
# this test appears very liberal, but catches the case where setup_handle fails without
|
|
Packit Service |
392537 |
# giving false positives
|
|
Packit Service |
392537 |
ok(($status == 0) || (($status & $DEVICE_STATUS_VOLUME_UNLABELED) != 0),
|
|
Packit Service |
392537 |
"status is either OK or possibly unlabeled")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# Test a tape device if the proper environment variables are set
|
|
Packit Service |
392537 |
my $TAPE_DEVICE = $ENV{'INSTALLCHECK_TAPE_DEVICE'};
|
|
Packit Service |
392537 |
my $run_tape_tests = defined $TAPE_DEVICE;
|
|
Packit Service |
392537 |
SKIP: {
|
|
Packit Service |
392537 |
skip "define \$INSTALLCHECK_TAPE_DEVICE to run tape tests",
|
|
Packit Service |
392537 |
30 +
|
|
Packit Service |
392537 |
7 * $verify_file_count +
|
|
Packit Service |
392537 |
5 * $write_file_count
|
|
Packit Service |
392537 |
unless $run_tape_tests;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev_name = "tape:$TAPE_DEVICE";
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $status = $dev->read_label();
|
|
Packit Service |
392537 |
ok(($status == $DEVICE_STATUS_SUCCESS) || (($status & $DEVICE_STATUS_VOLUME_UNLABELED) != 0),
|
|
Packit Service |
392537 |
"status is either OK or possibly unlabeled")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, "TESTCONF13", undef),
|
|
Packit Service |
392537 |
"start in write mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(!($dev->status() & $DEVICE_STATUS_VOLUME_UNLABELED),
|
|
Packit Service |
392537 |
"not unlabeled anymore")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
for (my $i = 1; $i <= 4; $i++) {
|
|
Packit Service |
392537 |
write_file(0x2FACE+$i, $dev->block_size()*10+17, $i);
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after write")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev->read_label();
|
|
Packit Service |
392537 |
ok(!($dev->status()),
|
|
Packit Service |
392537 |
"no error, at all, from read_label")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->volume_label(), "TESTCONF13",
|
|
Packit Service |
392537 |
"read_label reads the correct label")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# append one more copy, to test ACCESS_APPEND
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# if final_filemarks is 1, then the tape device will use F_NOOP,
|
|
Packit Service |
392537 |
# inserting an extra file, and we'll be appending at file number 6.
|
|
Packit Service |
392537 |
my $append_fileno = ($dev->property_get("FINAL_FILEMARKS") == 2)? 5:6;
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
SKIP: {
|
|
Packit Service |
392537 |
skip "APPEND not supported", $write_file_count + 2
|
|
Packit Service |
392537 |
unless $dev->property_get("APPENDABLE");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_APPEND, undef, undef),
|
|
Packit Service |
392537 |
"start in append mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
write_file(0xD0ED0E, $dev->block_size()*4, $append_fileno);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after append")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# try reading the second and third files back, creating a new
|
|
Packit Service |
392537 |
# device object first, and skipping the read-label step.
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = undef;
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: re-create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# use a big read_block_size, checking that it's also settable
|
|
Packit Service |
392537 |
# via read_buffer_size
|
|
Packit Service |
392537 |
is($dev->property_set("read_buffer_size", 256*1024), undef,
|
|
Packit Service |
392537 |
"can set read_buffer_size");
|
|
Packit Service |
392537 |
is($dev->property_get("read_block_size"), 256*1024,
|
|
Packit Service |
392537 |
"and its value is reflected in read_block_size");
|
|
Packit Service |
392537 |
is($dev->property_set("read_block_size", 32*1024), undef,
|
|
Packit Service |
392537 |
"can set read_block_size");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_READ, undef, undef),
|
|
Packit Service |
392537 |
"start in read mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# now verify those files in a particular order to trigger all of the
|
|
Packit Service |
392537 |
# seeking edge cases
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
verify_file(0x2FACE+1, $dev->block_size()*10+17, 1);
|
|
Packit Service |
392537 |
verify_file(0x2FACE+2, $dev->block_size()*10+17, 2);
|
|
Packit Service |
392537 |
verify_file(0x2FACE+4, $dev->block_size()*10+17, 4);
|
|
Packit Service |
392537 |
verify_file(0x2FACE+3, $dev->block_size()*10+17, 3);
|
|
Packit Service |
392537 |
verify_file(0x2FACE+1, $dev->block_size()*10+17, 1);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# try re-seeking to the same file
|
|
Packit Service |
392537 |
ok(header_for($dev->seek_file(2), 2), "seek to file 2 the first time");
|
|
Packit Service |
392537 |
verify_file(0x2FACE+2, $dev->block_size()*10+17, 2);
|
|
Packit Service |
392537 |
ok(header_for($dev->seek_file(2), 2), "seek to file 2 the third time");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# and seek through the same pattern *without* reading to EOF
|
|
Packit Service |
392537 |
ok(header_for($dev->seek_file(1), 1), "seek to file 1");
|
|
Packit Service |
392537 |
ok(header_for($dev->seek_file(2), 2), "seek to file 2");
|
|
Packit Service |
392537 |
ok(header_for($dev->seek_file(4), 4), "seek to file 4");
|
|
Packit Service |
392537 |
ok(header_for($dev->seek_file(3), 3), "seek to file 3");
|
|
Packit Service |
392537 |
ok(header_for($dev->seek_file(1), 1), "seek to file 1");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
SKIP: {
|
|
Packit Service |
392537 |
skip "APPEND not supported", $verify_file_count
|
|
Packit Service |
392537 |
unless $dev->property_get("APPENDABLE");
|
|
Packit Service |
392537 |
verify_file(0xD0ED0E, $dev->block_size()*4, $append_fileno);
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after read")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# tickle a regression in improperly closing fd's
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device again after read")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->read_label() == $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"read_label after second finish (used to fail)")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# finally, run the device with FSF and BSF set to "no", to test the
|
|
Packit Service |
392537 |
# fallback schemes for this condition
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = undef;
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new($dev_name);
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"$dev_name: re-create successful")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
$dev->property_set("fsf", "no");
|
|
Packit Service |
392537 |
$dev->property_set("bsf", "no");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_READ, undef, undef),
|
|
Packit Service |
392537 |
"start in read mode")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok(header_for($dev->seek_file(1), 1), "seek to file 1");
|
|
Packit Service |
392537 |
ok(header_for($dev->seek_file(4), 4), "seek to file 4");
|
|
Packit Service |
392537 |
ok(header_for($dev->seek_file(2), 2), "seek to file 2");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device after read")
|
|
Packit Service |
392537 |
or diag($dev->error_or_status());
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
SKIP: {
|
|
Packit Service |
392537 |
skip "not built with ndmp and server", 26 unless
|
|
Packit Service |
392537 |
Amanda::Util::built_with_component("ndmp") and
|
|
Packit Service |
392537 |
Amanda::Util::built_with_component("server");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $dev;
|
|
Packit Service |
392537 |
my $testconf = Installcheck::Config->new();
|
|
Packit Service |
392537 |
$testconf->write();
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $cfg_result = config_init($CONFIG_INIT_EXPLICIT_NAME, 'TESTCONF');
|
|
Packit Service |
392537 |
if ($cfg_result != $CFGERR_OK) {
|
|
Packit Service |
392537 |
my ($level, @errors) = Amanda::Config::config_errors();
|
|
Packit Service |
392537 |
die(join "\n", @errors);
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
my $ndmp = Installcheck::Mock::NdmpServer->new();
|
|
Packit Service |
392537 |
my $ndmp_port = $ndmp->{'port'};
|
|
Packit Service |
392537 |
my $drive = $ndmp->{'drive'};
|
|
Packit Service |
392537 |
pass("started ndmjob in daemon mode");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# set up a header for use below
|
|
Packit Service |
392537 |
my $hdr = Amanda::Header->new();
|
|
Packit Service |
392537 |
$hdr->{type} = $Amanda::Header::F_DUMPFILE;
|
|
Packit Service |
392537 |
$hdr->{datestamp} = "20070102030405";
|
|
Packit Service |
392537 |
$hdr->{dumplevel} = 0;
|
|
Packit Service |
392537 |
$hdr->{compressed} = 1;
|
|
Packit Service |
392537 |
$hdr->{name} = "localhost";
|
|
Packit Service |
392537 |
$hdr->{disk} = "/home";
|
|
Packit Service |
392537 |
$hdr->{program} = "INSTALLCHECK";
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new("ndmp:127.0.0.1:9i1\@foo");
|
|
Packit Service |
392537 |
isnt($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"creation of an ndmp device fails with invalid port");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new("ndmp:127.0.0.1:90000\@foo");
|
|
Packit Service |
392537 |
isnt($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"creation of an ndmp device fails with too-large port");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new("ndmp:127.0.0.1:$ndmp_port");
|
|
Packit Service |
392537 |
isnt($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"creation of an ndmp device fails without ..\@device_name");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new("ndmp:127.0.0.1:$ndmp_port\@$drive");
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"creation of an ndmp device succeeds with correct syntax");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("ndmp_username", "foo"), undef,
|
|
Packit Service |
392537 |
"set ndmp_username property");
|
|
Packit Service |
392537 |
is($dev->property_get("ndmp_username"), "foo",
|
|
Packit Service |
392537 |
"..and get the value back");
|
|
Packit Service |
392537 |
is($dev->property_set("ndmp_password", "bar"), undef,
|
|
Packit Service |
392537 |
"set ndmp_password property");
|
|
Packit Service |
392537 |
is($dev->property_get("ndmp_password"), "bar",
|
|
Packit Service |
392537 |
"..and get the value back");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->property_set("verbose", 1), undef,
|
|
Packit Service |
392537 |
"set VERBOSE");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# set 'em back to the defaults
|
|
Packit Service |
392537 |
$dev->property_set("ndmp_username", "ndmp");
|
|
Packit Service |
392537 |
$dev->property_set("ndmp_password", "ndmp");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# use a big read_block_size, checking that it's also settable
|
|
Packit Service |
392537 |
# via read_buffer_size
|
|
Packit Service |
392537 |
is($dev->property_set("read_block_size", 256*1024), undef,
|
|
Packit Service |
392537 |
"can set read_block_size");
|
|
Packit Service |
392537 |
is($dev->property_get("read_block_size"), 256*1024,
|
|
Packit Service |
392537 |
"and its value is reflected");
|
|
Packit Service |
392537 |
is($dev->property_set("read_block_size", 64*1024), undef,
|
|
Packit Service |
392537 |
"set read_block_size back to something smaller");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# ok, let's fire the thing up
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, "TEST1", "20090915000000"),
|
|
Packit Service |
392537 |
"start device in write mode")
|
|
Packit Service |
392537 |
or diag $dev->error_or_status();
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->start_file($hdr),
|
|
Packit Service |
392537 |
"start_file");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
{ # write to the file
|
|
Packit Service |
392537 |
my $xfer = Amanda::Xfer->new([
|
|
Packit Service |
392537 |
Amanda::Xfer::Source::Random->new(32768*21, 0xBEEFEE00),
|
|
Packit Service |
392537 |
Amanda::Xfer::Dest::Device->new($dev, 0) ]);
|
|
Packit Service |
392537 |
$xfer->start(make_cb(xmsg_cb => sub {
|
|
Packit Service |
392537 |
my ($src, $msg, $xfer) = @_;
|
|
Packit Service |
392537 |
if ($msg->{'type'} == $XMSG_ERROR) {
|
|
Packit Service |
392537 |
die $msg->{'elt'} . " failed: " . $msg->{'message'};
|
|
Packit Service |
392537 |
} elsif ($msg->{'type'} == $XMSG_DONE) {
|
|
Packit Service |
392537 |
Amanda::MainLoop::quit();
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
}));
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
Amanda::MainLoop::run();
|
|
Packit Service |
392537 |
pass("wrote 21 blocks");
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device")
|
|
Packit Service |
392537 |
or diag $dev->error_or_status();
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->read_label(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"read label from (same) device")
|
|
Packit Service |
392537 |
or diag $dev->error_or_status();
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
is($dev->volume_label, "TEST1",
|
|
Packit Service |
392537 |
"volume label read back correctly");
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
## label a device and check the label, but open a new device in between
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# Write a label
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new("ndmp:127.0.0.1:$ndmp_port\@$drive");
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"creation of an ndmp device succeeds with correct syntax");
|
|
Packit Service |
392537 |
$dev->property_set("ndmp_username", "ndmp");
|
|
Packit Service |
392537 |
$dev->property_set("ndmp_password", "ndmp");
|
|
Packit Service |
392537 |
$dev->property_set("verbose", 1);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# Write the label
|
|
Packit Service |
392537 |
ok($dev->start($ACCESS_WRITE, "TEST2", "20090915000000"),
|
|
Packit Service |
392537 |
"start device in write mode")
|
|
Packit Service |
392537 |
or diag $dev->error_or_status();
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device")
|
|
Packit Service |
392537 |
or diag $dev->error_or_status();
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# Read the label with a new device.
|
|
Packit Service |
392537 |
$dev = Amanda::Device->new("ndmp:127.0.0.1:$ndmp_port\@$drive");
|
|
Packit Service |
392537 |
is($dev->status(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"creation of an ndmp device succeeds with correct syntax");
|
|
Packit Service |
392537 |
$dev->property_set("ndmp_username", "ndmp");
|
|
Packit Service |
392537 |
$dev->property_set("ndmp_password", "ndmp");
|
|
Packit Service |
392537 |
$dev->property_set("verbose", 1);
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
# read the label
|
|
Packit Service |
392537 |
is($dev->read_label(), $DEVICE_STATUS_SUCCESS,
|
|
Packit Service |
392537 |
"read label from device")
|
|
Packit Service |
392537 |
or diag $dev->error_or_status();
|
|
Packit Service |
392537 |
is($dev->volume_label, "TEST2",
|
|
Packit Service |
392537 |
"volume label read back correctly");
|
|
Packit Service |
392537 |
ok($dev->finish(),
|
|
Packit Service |
392537 |
"finish device")
|
|
Packit Service |
392537 |
or diag $dev->error_or_status();
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
|
|
Packit Service |
392537 |
$ndmp->cleanup();
|
|
Packit Service |
392537 |
}
|
|
Packit Service |
392537 |
unlink($input_filename);
|
|
Packit Service |
392537 |
unlink($output_filename);
|
|
Packit Service |
392537 |
rmtree($taperoot);
|