X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=installcheck%2FAmanda_Recovery_Clerk.pl;h=9c3bfb8d8f17f7802d163a76b3fc4855178bd082;hb=refs%2Fheads%2Fmaster;hp=22bdc84069d2ce84a255c9ab7a189cf0b3029bab;hpb=d5853102f67d85d8e169f9dbe973ad573306c215;p=debian%2Famanda diff --git a/installcheck/Amanda_Recovery_Clerk.pl b/installcheck/Amanda_Recovery_Clerk.pl index 22bdc84..9c3bfb8 100644 --- a/installcheck/Amanda_Recovery_Clerk.pl +++ b/installcheck/Amanda_Recovery_Clerk.pl @@ -1,8 +1,9 @@ -# Copyright (c) 2010 Zmanda Inc. All Rights Reserved. +# Copyright (c) 2010-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 @@ -60,7 +61,7 @@ my $taperoot = "$Installcheck::TMP/Amanda_Recovery_Clerk"; my $datestamp = "20100101010203"; # set up a 2-tape disk changer with some spanned dumps in it, and add those -# dumps to the catalog, too. To avoid re-implementing Amanda::Taper::Scan, this +# dumps to the catalog, too. To avoid re-implementing Amanda::Taper::Scribe, this # uses individual transfers for each part. sub setup_changer { my ($finished_cb, $chg_name, $to_write, $part_len) = @_; @@ -70,7 +71,8 @@ sub setup_changer { my ($slot, $xfer_info, $partnum); my $steps = define_steps - cb_ref => \$finished_cb; + cb_ref => \$finished_cb, + finalize => sub { $chg->quit() }; step setup => sub { $chg = Amanda::Changer->new($chg_name); @@ -126,7 +128,8 @@ sub setup_changer { my $name = $xfer_info->[2]; my $hdr = Amanda::Header->new(); - $hdr->{'type'} = $Amanda::Header::F_SPLIT_DUMPFILE; + # if the partnum is 0, write a DUMPFILE like Amanda < 3.1 did + $hdr->{'type'} = $partnum? $Amanda::Header::F_SPLIT_DUMPFILE : $Amanda::Header::F_DUMPFILE; $hdr->{'datestamp'} = $datestamp; $hdr->{'dumplevel'} = 0; $hdr->{'name'} = $name; @@ -144,7 +147,7 @@ sub setup_changer { my $key = $xfer_info->[1]; my $xsrc = Amanda::Xfer::Source::Random->new($len, $key); - my $xdst = Amanda::Xfer::Dest::Device->new($dev, 1024*256); + my $xdst = Amanda::Xfer::Dest::Device->new($dev, 0); my $xfer = Amanda::Xfer->new([$xsrc, $xdst]); $xfer->start(sub { @@ -167,7 +170,8 @@ sub setup_changer { diskname => "/$name", level => 0, status => "OK", - partnum => $partnum, + # get the partnum right, even if this wasn't split + partnum => $partnum? $partnum : ($partnum+1), nparts => -1, kb => $len / 1024, sec => 1.2, @@ -213,7 +217,7 @@ sub setup_changer { ); my @to_write = ( # slot xfer partnum - [ 1, $xfer_info[0], 1 ], + [ 1, $xfer_info[0], 0 ], # partnum 0 => old non-split header [ 1, $xfer_info[1], 1 ], [ 1, $xfer_info[1], 2 ], [ 2, $xfer_info[1], 3 ], @@ -308,13 +312,13 @@ sub new { return bless \%params, $class; } -sub notif_part { +sub clerk_notif_part { my $self = shift; - if (exists $self->{'notif_part'}) { - $self->{'notif_part'}->(@_); + if (exists $self->{'clerk_notif_part'}) { + $self->{'clerk_notif_part'}->(@_); } else { - $self->SUPER::notif_part(@_); + $self->SUPER::clerk_notif_part(@_); } } @@ -457,7 +461,7 @@ sub quit_clerk { my $clerk; my $feedback; -my @notif_parts; +my @clerk_notif_parts; my $chg = Amanda::Changer->new("chg-disk:$taperoot"); my $scan = Amanda::Recovery::Scan->new(chg => $chg); @@ -485,13 +489,15 @@ quit_clerk($clerk); # recover from TESTCONF02, then 01, and then 02 again -@notif_parts = (); +@clerk_notif_parts = (); $feedback = main::Feedback->new( - notif_part => sub { - push @notif_parts, [ $_[0], $_[1] ], + clerk_notif_part => sub { + push @clerk_notif_parts, [ $_[0], $_[1] ], }, ); +$chg = Amanda::Changer->new("chg-disk:$taperoot"); +$scan = Amanda::Recovery::Scan->new(chg => $chg); $clerk = Amanda::Recovery::Clerk->new(scan => $scan, debug => 1, feedback => $feedback); @@ -504,10 +510,10 @@ try_recovery( ), msg => "two-part recovery from second tape successful"); -is_deeply([ @notif_parts ], [ +is_deeply([ @clerk_notif_parts ], [ [ 'TESTCONF02', 2 ], [ 'TESTCONF02', 3 ], - ], "..and notif_part calls are correct"); + ], "..and clerk_notif_part calls are correct"); try_recovery( clerk => $clerk, @@ -623,7 +629,7 @@ SKIP: { } my $tapelist = Amanda::Config::config_dir_relative("tapelist"); - my $tl = Amanda::Tapelist::read_tapelist($tapelist); + my $tl = Amanda::Tapelist->new($tapelist); my $chg = Amanda::Changer->new(); my $scan = Amanda::Recovery::Scan->new(chg => $chg); @@ -647,10 +653,11 @@ SKIP: { [ 1024*160, 0xB000, "home" ], ); my @to_write = ( + # (note that slots 1 and 2 are i/e slots, and are initially empty) # slot xfer partnum - [ 4, $xfer_info[0], 1 ], - [ 5, $xfer_info[0], 2 ], - [ 5, $xfer_info[0], 3 ], + [ 3, $xfer_info[0], 1 ], + [ 4, $xfer_info[0], 2 ], + [ 4, $xfer_info[0], 3 ], ); setup_changer(\&Amanda::MainLoop::quit, "ndmp_server", \@to_write, 64*1024); @@ -665,9 +672,9 @@ SKIP: { clerk => $clerk, seed => 0xB000, dump => fake_dump("home", "/home", $datestamp, 0, + { label => 'TESTCONF03', filenum => 1 }, { label => 'TESTCONF04', filenum => 1 }, - { label => 'TESTCONF05', filenum => 1 }, - { label => 'TESTCONF05', filenum => 2 }, + { label => 'TESTCONF04', filenum => 2 }, ), msg => "multi-part ndmp recovery successful", expect_directtcp_supported => 1);