X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=installcheck%2FAmanda_Changer_robot.pl;h=7eadaa25e9e3d6462728f1972e55e4890faa7472;hb=4c9eba1feb11adf189bceb4001c425e641f0b56a;hp=763395fa20922a2862d03201ec7a686c77a877e0;hpb=d5853102f67d85d8e169f9dbe973ad573306c215;p=debian%2Famanda diff --git a/installcheck/Amanda_Changer_robot.pl b/installcheck/Amanda_Changer_robot.pl index 763395f..7eadaa2 100644 --- a/installcheck/Amanda_Changer_robot.pl +++ b/installcheck/Amanda_Changer_robot.pl @@ -16,10 +16,11 @@ # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com -use Test::More tests => 321; +use Test::More tests => 324; use File::Path; use Data::Dumper; use strict; +use warnings; use lib "@amperldir@"; use Installcheck; @@ -90,7 +91,8 @@ sub test_interface { my ($interface, $chg); my $steps = define_steps - cb_ref => \$finished_cb; + cb_ref => \$finished_cb, + finalize => sub { $chg->quit() }; step start => sub { my $testconf = Installcheck::Config->new(); @@ -114,6 +116,7 @@ sub test_interface { $chg = Amanda::Changer->new("robo"); die "$chg" if $chg->isa("Amanda::Changer::Error"); + is($chg->have_inventory(), '1', "changer have inventory"); $interface = $chg->{'interface'}; $interface->inquiry($steps->{'inquiry_cb'}); @@ -334,6 +337,7 @@ Amanda::MainLoop::run(); my $chg = Amanda::Changer->new("delays"); die "$chg" if $chg->isa("Amanda::Changer::Error"); + is($chg->have_inventory(), '1', "changer have inventory"); is($chg->{'status_interval'}, 60, "status-interval parsed"); is($chg->{'eject_delay'}, 1, "eject-delay parsed"); is($chg->{'unload_delay'}, 120, "unload-delay parsed"); @@ -345,10 +349,12 @@ Amanda::MainLoop::run(); $dashed_mtx_state_file =~ s/^-*//; is($chg->{'statefile'}, "$localstatedir/amanda/chg-robot-$dashed_mtx_state_file", "statefile calculated correctly"); + $chg->quit(); # test no-fast-search $chg = Amanda::Changer->new("no-fast-search"); die "$chg" if $chg->isa("Amanda::Changer::Error"); + is($chg->have_inventory(), '1', "changer have inventory"); $chg->info( info => ['fast_search'], info_cb => make_cb(info_cb => sub { @@ -362,6 +368,7 @@ Amanda::MainLoop::run(); my @allowed = map { $chg->_is_slot_allowed($_) } (0 .. 10); is_deeply([ @allowed ], [ 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0 ], "_is_slot_allowed parses multiple properties and behaves as expected"); + $chg->quit(); } ## @@ -375,12 +382,12 @@ sub test_changer { my $vtape_root = "$Installcheck::TMP/chg-robot-vtapes"; my $steps = define_steps - cb_ref => \$finished_cb; + cb_ref => \$finished_cb, + finalize => sub { $chg->quit() }; step setup => sub { # clean up unlink($chg_state_file) if -f $chg_state_file; - %Amanda::Changer::changers_by_uri_cc = (); # set up some vtapes rmtree($vtape_root); @@ -459,18 +466,23 @@ sub test_changer { check_inventory($chg, $mtx_config->{'barcodes'} > 0, $steps->{'load_slot_1'}, [ { slot => 1, state => Amanda::Changer::SLOT_FULL, barcode => '11111', current => 1, - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, { slot => 2, state => Amanda::Changer::SLOT_FULL, barcode => '22222', - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, { slot => 3, state => Amanda::Changer::SLOT_FULL, barcode => '33333', - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, { slot => 4, state => Amanda::Changer::SLOT_FULL, barcode => '44444', - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, { slot => 5, state => Amanda::Changer::SLOT_EMPTY, - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, ], "$pfx: inventory is correct on start-up"); }; @@ -549,18 +561,25 @@ sub test_changer { check_inventory($chg, $mtx_config->{'barcodes'} > 0, $steps->{'load_slot_3'}, [ { slot => 1, state => Amanda::Changer::SLOT_FULL, barcode => '11111', reserved => 1, loaded_in => 0, current => 1, - device_status => undef, f_type => undef, label => undef }, + device_status => $DEVICE_STATUS_VOLUME_UNLABELED, + device_error => undef, + f_type => undef, label => undef }, { slot => 2, state => Amanda::Changer::SLOT_FULL, barcode => '22222', reserved => 1, loaded_in => 1, - device_status => undef, f_type => undef, label => undef }, + device_status => $DEVICE_STATUS_VOLUME_UNLABELED, + device_error => undef, + f_type => undef, label => undef }, { slot => 3, state => Amanda::Changer::SLOT_FULL, barcode => '33333', - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, { slot => 4, state => Amanda::Changer::SLOT_FULL, barcode => '44444', - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, { slot => 5, state => Amanda::Changer::SLOT_EMPTY, - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, ], "$pfx: inventory is updated when slots are loaded"); }; @@ -649,20 +668,23 @@ sub test_changer { check_inventory($chg, $mtx_config->{'barcodes'} > 0, $steps->{'check_state_after_release1'}, [ { slot => 1, state => Amanda::Changer::SLOT_FULL, barcode => '11111', reserved => 1, loaded_in => 0, current => 1, - device_status => $DEVICE_STATUS_SUCCESS, + device_status => $DEVICE_STATUS_SUCCESS, device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-1' }, { slot => 2, state => Amanda::Changer::SLOT_FULL, barcode => '22222', loaded_in => 1, - device_status => $DEVICE_STATUS_SUCCESS, + device_status => $DEVICE_STATUS_SUCCESS, device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-2' }, { slot => 3, state => Amanda::Changer::SLOT_FULL, barcode => '33333', - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, { slot => 4, state => Amanda::Changer::SLOT_FULL, barcode => '44444', - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, { slot => 5, state => Amanda::Changer::SLOT_EMPTY, - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, ], "$pfx: inventory is still up to date"); }; @@ -745,22 +767,24 @@ sub test_changer { check_inventory($chg, $mtx_config->{'barcodes'} > 0, $steps->{'release2'}, [ { slot => 1, state => Amanda::Changer::SLOT_FULL, barcode => '11111', - device_status => $DEVICE_STATUS_SUCCESS, + device_status => $DEVICE_STATUS_SUCCESS, device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-1', reserved => 1, loaded_in => 0 }, { slot => 2, state => Amanda::Changer::SLOT_FULL, barcode => '22222', - device_status => $DEVICE_STATUS_SUCCESS, + device_status => $DEVICE_STATUS_SUCCESS, device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-2' }, { slot => 3, state => Amanda::Changer::SLOT_FULL, barcode => '33333', - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, { slot => 4, state => Amanda::Changer::SLOT_FULL, barcode => '44444', reserved => 1, loaded_in => 1, current => 1, - device_status => $DEVICE_STATUS_SUCCESS, + device_status => $DEVICE_STATUS_SUCCESS, device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-4' }, { slot => 5, state => Amanda::Changer::SLOT_EMPTY, - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, ], "$pfx: inventory is up to date after more labelings"); }; @@ -986,21 +1010,23 @@ sub test_changer { check_inventory($chg, $mtx_config->{'barcodes'} > 0, $steps->{'try_update'}, [ { slot => 1, state => Amanda::Changer::SLOT_FULL, barcode => '11111', loaded_in => 1, - device_status => $DEVICE_STATUS_SUCCESS, + device_status => $DEVICE_STATUS_SUCCESS, device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-1' }, { slot => 2, state => Amanda::Changer::SLOT_FULL, barcode => '22222', loaded_in => 0, - device_status => $DEVICE_STATUS_SUCCESS, + device_status => $DEVICE_STATUS_SUCCESS, device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-2' }, { slot => 3, state => Amanda::Changer::SLOT_FULL, barcode => '33333', - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, { slot => 4, state => Amanda::Changer::SLOT_FULL, barcode => '44444', current => 1, - device_status => $DEVICE_STATUS_SUCCESS, + device_status => $DEVICE_STATUS_SUCCESS, device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-4' }, { slot => 5, state => Amanda::Changer::SLOT_EMPTY, - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, ], "$pfx: inventory still accurate"); }; @@ -1100,20 +1126,26 @@ sub test_changer { { slot => 1, state => Amanda::Changer::SLOT_FULL, barcode => '11111', device_status => $DEVICE_STATUS_SUCCESS, + device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-1' }, { slot => 2, state => Amanda::Changer::SLOT_FULL, barcode => '22222', device_status => $DEVICE_STATUS_SUCCESS, + device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'SURPRISE!' }, { slot => 3, state => Amanda::Changer::SLOT_FULL, barcode => '33333', loaded_in => 1, - device_status => undef, f_type => undef, label => 'TAPE-3' }, + device_status => $DEVICE_STATUS_SUCCESS, + device_error => undef, + f_type => undef, label => 'TAPE-3' }, { slot => 4, state => Amanda::Changer::SLOT_FULL, barcode => '44444', loaded_in => 0, current => 1, device_status => $DEVICE_STATUS_SUCCESS, + device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-4' }, { slot => 5, state => Amanda::Changer::SLOT_EMPTY, - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, ], "$pfx: inventory reflects updates"); }; @@ -1176,18 +1208,15 @@ sub test_changer { step moved4 => sub { my ($err) = @_; + die "$err" if $err; - chg_err_like($err, - { message => "slot 4 is currently loaded", - reason => 'invalid', - type => 'failed' }, - "$pfx: moving from a loaded slot is an error"); + pass("$pfx: move of a loaded volume succeeds"); $steps->{'move5'}->(); }; step move5 => sub { - $chg->move(from_slot => 2, to_slot => 5, finished_cb => $steps->{'inventory7'}); + $chg->move(from_slot => 2, to_slot => 4, finished_cb => $steps->{'inventory7'}); }; @@ -1203,20 +1232,26 @@ sub test_changer { { slot => 1, state => Amanda::Changer::SLOT_FULL, barcode => '11111', device_status => $DEVICE_STATUS_SUCCESS, + device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-1' }, { slot => 2, state => Amanda::Changer::SLOT_EMPTY, - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, { slot => 3, state => Amanda::Changer::SLOT_FULL, barcode => '33333', loaded_in => 1, - device_status => undef, f_type => undef, label => 'TAPE-3' }, + device_status => $DEVICE_STATUS_SUCCESS, + device_error => undef, + f_type => undef, label => 'TAPE-3' }, { slot => 4, state => Amanda::Changer::SLOT_FULL, - barcode => '44444', loaded_in => 0, current => 1, + barcode => '22222', current => 1, device_status => $DEVICE_STATUS_SUCCESS, - f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-4' }, + device_error => undef, + f_type => $Amanda::Header::F_TAPESTART, label => 'SURPRISE!' }, { slot => 5, state => Amanda::Changer::SLOT_FULL, - barcode => '22222', + barcode => '44444', device_status => $DEVICE_STATUS_SUCCESS, - f_type => $Amanda::Header::F_TAPESTART, label => 'SURPRISE!' }, + device_error => undef, + f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-4' }, ], "$pfx: inventory reflects the move"); }; @@ -1262,22 +1297,28 @@ sub test_changer { "$pfx: scanning with except_slots works"); check_inventory($chg, $mtx_config->{'barcodes'} > 0, $steps->{'update_unknown'}, [ { slot => 1, state => Amanda::Changer::SLOT_FULL, - barcode => '11111', loaded_in => 0, + barcode => '11111', loaded_in => 1, device_status => $DEVICE_STATUS_SUCCESS, + device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-1' }, { slot => 2, state => Amanda::Changer::SLOT_EMPTY, - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, { slot => 3, state => Amanda::Changer::SLOT_FULL, - barcode => '33333', loaded_in => 1, - device_status => undef, f_type => undef, label => 'TAPE-3' }, + barcode => '33333', loaded_in => 0, + device_status => $DEVICE_STATUS_SUCCESS, + device_error => undef, + f_type => undef, label => 'TAPE-3' }, { slot => 4, state => Amanda::Changer::SLOT_FULL, - barcode => '44444', current => 1, + barcode => '22222', current => 1, device_status => $DEVICE_STATUS_SUCCESS, - f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-4' }, + device_error => undef, + f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-2' }, { slot => 5, state => Amanda::Changer::SLOT_FULL, - barcode => '22222', + barcode => '44444', device_status => $DEVICE_STATUS_SUCCESS, - f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-2' }, + device_error => undef, + f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-4' }, ], "$pfx: inventory before updates with unknown state"); }; @@ -1292,41 +1333,52 @@ sub test_changer { if ($mtx_config->{'barcodes'} > 0) { check_inventory($chg, $mtx_config->{'barcodes'} > 0, $steps->{'quit'}, [ { slot => 1, state => Amanda::Changer::SLOT_FULL, - barcode => '11111', loaded_in => 0, + barcode => '11111', loaded_in => 1, device_status => $DEVICE_STATUS_SUCCESS, + device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-1' }, { slot => 2, state => Amanda::Changer::SLOT_EMPTY, - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, { slot => 3, state => Amanda::Changer::SLOT_FULL, - barcode => '33333', loaded_in => 1, - device_status => undef, f_type => undef, label => 'TAPE-3' }, + barcode => '33333', loaded_in => 0, + device_status => $DEVICE_STATUS_SUCCESS, + device_error => undef, + f_type => undef, label => 'TAPE-3' }, { slot => 4, state => Amanda::Changer::SLOT_FULL, - barcode => '44444', current => 1, + barcode => '22222', current => 1, device_status => $DEVICE_STATUS_SUCCESS, - f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-4' }, + device_error => undef, + f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-2' }, { slot => 5, state => Amanda::Changer::SLOT_FULL, - barcode => '22222', + barcode => '44444', device_status => $DEVICE_STATUS_SUCCESS, - f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-2' }, + device_error => undef, + f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-4' }, ], "$pfx: inventory reflects updates with unknown state with barcodes"); } else { check_inventory($chg, $mtx_config->{'barcodes'} > 0, $steps->{'quit'}, [ { slot => 1, state => Amanda::Changer::SLOT_FULL, - barcode => '11111', loaded_in => 0, + barcode => '11111', loaded_in => 1, device_status => $DEVICE_STATUS_SUCCESS, + device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-1' }, { slot => 2, state => Amanda::Changer::SLOT_EMPTY, - device_status => undef, f_type => undef, label => undef }, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, { slot => 3, state => Amanda::Changer::SLOT_FULL, - barcode => '33333', loaded_in => 1, - device_status => undef, f_type => undef, label => undef }, + barcode => '33333', loaded_in => 0, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, { slot => 4, state => Amanda::Changer::SLOT_FULL, - barcode => '44444', current => 1, - device_status => undef, f_type => undef, label => undef }, + barcode => '22222', current => 1, + device_status => undef, device_error => undef, + f_type => undef, label => undef }, { slot => 5, state => Amanda::Changer::SLOT_FULL, - barcode => '22222', + barcode => '44444', device_status => $DEVICE_STATUS_SUCCESS, - f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-2' }, + device_error => undef, + f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-4' }, ], "$pfx: inventory reflects updates with unknown state without barcodes"); } };