-# 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
# 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;
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();
$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'});
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);
"$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'});
};
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");
};
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");
};
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");
};
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");
};