X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=installcheck%2FAmanda_Changer_ndmp.pl;h=a5943bfd67d039f9d09e8c12a39b850c92464317;hb=d28952249e392eb31bc8eecc53f6c477f30c617b;hp=895c2473a1f333661259ce810d1fe5f16e28a1ed;hpb=fd48f3e498442f0cbff5f3606c7c403d0566150e;p=debian%2Famanda diff --git a/installcheck/Amanda_Changer_ndmp.pl b/installcheck/Amanda_Changer_ndmp.pl index 895c247..a5943bf 100644 --- a/installcheck/Amanda_Changer_ndmp.pl +++ b/installcheck/Amanda_Changer_ndmp.pl @@ -1,8 +1,9 @@ -# Copyright (c) 2009, 2010 Zmanda Inc. All Rights Reserved. +# Copyright (c) 2009-2012 Zmanda Inc. All Rights Reserved. # -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 as published -# by the Free Software Foundation. +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY @@ -16,10 +17,11 @@ # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com -use Test::More tests => 165; +use Test::More tests => 171; use File::Path; use Data::Dumper; use strict; +use warnings; use lib "@amperldir@"; use Installcheck; @@ -73,7 +75,8 @@ sub test_interface { my ($interface, $chg); my $steps = define_steps - cb_ref => \$finished_cb; + cb_ref => \$finished_cb, + finalize => sub { $chg->quit() if defined $chg}; step start => sub { my $testconf = Installcheck::Config->new(); @@ -94,6 +97,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'}); @@ -289,12 +293,12 @@ sub test_changer { my $pfx = "BC=$mtx_config->{barcodes}; TORIG=$mtx_config->{track_orig}"; my $steps = define_steps - cb_ref => \$finished_cb; + cb_ref => \$finished_cb, + finalize => sub { $chg->quit() if defined $chg}; # clean up step setup => sub { unlink($chg_state_file) if -f $chg_state_file; - %Amanda::Changer::changers_by_uri_cc = (); my @ignore_barcodes = ( property => "\"ignore-barcodes\" \"y\"") if ($mtx_config->{'barcodes'} == -1); @@ -334,6 +338,7 @@ sub test_changer { "$pfx: Create working chg-robot instance: $chg") or die("no sense going on"); + is($chg->have_inventory(), '1', "changer have inventory"); $chg->info(info => [qw(vendor_string num_slots fast_search)], info_cb => $steps->{'info_cb'}); }; @@ -355,19 +360,24 @@ sub test_changer { check_inventory($chg, $mtx_config->{'barcodes'} > 0, $steps->{'load_slot_1'}, [ { slot => 1, state => Amanda::Changer::SLOT_EMPTY, import_export => 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_EMPTY, import_export => 1, - 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 => 'PTAG00XX', current => 1, - 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 => 'PTAG01XX', - 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_FULL, barcode => 'PTAG02XX', - 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"); }; @@ -446,20 +456,27 @@ sub test_changer { check_inventory($chg, $mtx_config->{'barcodes'} > 0, $steps->{'load_slot_3'}, [ { slot => 1, state => Amanda::Changer::SLOT_EMPTY, import_export => 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_EMPTY, import_export => 1, - 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 => 'PTAG00XX', reserved => 1, loaded_in => 0, current => 1, - device_status => undef, f_type => undef, label => undef }, + device_status => $DEVICE_STATUS_VOLUME_UNLABELED, + device_error => 'no tape label found', + f_type => $Amanda::Header::F_EMPTY, label => undef }, { slot => 4, state => Amanda::Changer::SLOT_FULL, barcode => 'PTAG01XX', reserved => 1, loaded_in => 1, - device_status => undef, f_type => undef, label => undef }, + device_status => $DEVICE_STATUS_VOLUME_UNLABELED, + device_error => 'no tape label found', + f_type => $Amanda::Header::F_EMPTY, label => undef }, { slot => 5, state => Amanda::Changer::SLOT_FULL, barcode => 'PTAG02XX', - 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"); }; @@ -548,22 +565,25 @@ sub test_changer { check_inventory($chg, $mtx_config->{'barcodes'} > 0, $steps->{'check_state_after_release1'}, [ { slot => 1, state => Amanda::Changer::SLOT_EMPTY, import_export => 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_EMPTY, import_export => 1, - 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 => 'PTAG00XX', 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 => 4, state => Amanda::Changer::SLOT_FULL, barcode => 'PTAG01XX', 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 => 5, state => Amanda::Changer::SLOT_FULL, barcode => 'PTAG02XX', - 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"); }; @@ -646,22 +666,24 @@ sub test_changer { check_inventory($chg, $mtx_config->{'barcodes'} > 0, $steps->{'release2'}, [ { slot => 1, state => Amanda::Changer::SLOT_EMPTY, import_export => 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_EMPTY, import_export => 1, - 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 => 'PTAG00XX', reserved => 1, loaded_in => 0, - device_status => $DEVICE_STATUS_SUCCESS, + device_status => $DEVICE_STATUS_SUCCESS, device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-1' }, { slot => 4, state => Amanda::Changer::SLOT_FULL, barcode => 'PTAG01XX', - device_status => $DEVICE_STATUS_SUCCESS, + device_status => $DEVICE_STATUS_SUCCESS, device_error => undef, f_type => $Amanda::Header::F_TAPESTART, label => 'TAPE-2' }, { slot => 5, state => Amanda::Changer::SLOT_FULL, barcode => 'PTAG02XX', 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' }, ], "$pfx: inventory is up to date after more labelings"); };