Imported Upstream version 3.3.0
[debian/amanda] / installcheck / Amanda_Taper_Scribe.pl
index 0aeb002014293cca75d8d16a8d911433ccc9601d..607013aee9e7739cf69ba968772586dea0695d1a 100644 (file)
@@ -105,8 +105,7 @@ sub new {
     my $class = shift;
     my %params = @_;
     my @slots = @{ $params{'slots'} || [] };
-    my $chg =  Amanda::Changer->new("chg-disk:$taperoot");
-    die $chg if $chg->isa("Amanda::Changer::Error");
+    my $chg =  $params{'changer'};
 
     # wedge in an extra device property to disable LEOM support, if requested
     if ($params{'disable_leom'}) {
@@ -122,6 +121,10 @@ sub new {
     }, $class;
 }
 
+sub quit {
+    my $self = shift;
+}
+
 sub make_new_tape_label {
     return "FAKELABEL";
 }
@@ -206,6 +209,7 @@ sub scribe_notif_tape_done {
     main::event("scribe_notif_tape_done",
        $params{'volume_label'}, $params{'num_files'},
        $params{'size'});
+    $params{'finished_cb'}->();
 }
 
 
@@ -291,7 +295,8 @@ sub run_devh {
 }
 
 reset_taperoot(1);
-run_devh(3, Mock::Taperscan->new(), Mock::Feedback->new({allow => 1}, {allow => 1}, {allow => 1}));
+my $chg =  Amanda::Changer->new("chg-disk:$taperoot");
+run_devh(3, Mock::Taperscan->new(changer => $chg), Mock::Feedback->new({allow => 1}, {allow => 1}, {allow => 1}));
 is_deeply([ @events ], [
       [ 'start' ],
       [ 'scan' ], # scan starts *before* get_volume
@@ -320,7 +325,7 @@ is_deeply([ @events ], [
     ], "correct event sequence for basic run of DevHandling")
     or diag(Dumper([@events]));
 
-run_devh(1, Mock::Taperscan->new(), Mock::Feedback->new({cause => 'config', message => 'no-can-do'}));
+run_devh(1, Mock::Taperscan->new(changer => $chg), Mock::Feedback->new({cause => 'config', message => 'no-can-do'}));
 is_deeply([ @events ], [
       [ 'start' ],
       [ 'scan' ],
@@ -334,7 +339,7 @@ is_deeply([ @events ], [
     ], "correct event sequence for a run without permission")
     or diag(Dumper([@events]));
 
-run_devh(1, Mock::Taperscan->new(slots => ["bogus"]), Mock::Feedback->new({allow => 1}));
+run_devh(1, Mock::Taperscan->new(slots => ["bogus"], changer => $chg), Mock::Feedback->new({allow => 1}));
 is_deeply([ @events ], [
       [ 'start' ],
       [ 'scan' ],
@@ -348,7 +353,7 @@ is_deeply([ @events ], [
     ], "correct event sequence for a run with a changer error")
     or diag(Dumper([@events]));
 
-run_devh(1, Mock::Taperscan->new(slots => ["bogus"]),
+run_devh(1, Mock::Taperscan->new(slots => ["bogus"], changer => $chg),
            Mock::Feedback->new({cause => 'config', message => "not this time"}));
 is_deeply([ @events ], [
       [ 'start' ],
@@ -363,7 +368,7 @@ is_deeply([ @events ], [
     ], "correct event sequence for a run with no permission AND a changer config denial")
     or diag(Dumper([@events]));
 
-run_devh(1, Mock::Taperscan->new(slots => ["bogus"]), Mock::Feedback->new({cause => 'error', message => "frobnicator exploded!"}));
+run_devh(1, Mock::Taperscan->new(slots => ["bogus"], changer => $chg), Mock::Feedback->new({cause => 'error', message => "frobnicator exploded!"}));
 is_deeply([ @events ], [
       [ 'start' ],
       [ 'scan' ],
@@ -404,6 +409,7 @@ sub run_scribe_xfer_async {
 
        # set up a transfer
        my $xdt = $scribe->get_xfer_dest(
+           allow_split => 1,
            max_memory => 1024 * 64,
            part_size => (defined $params{'part_size'})? $params{'part_size'} : (1024 * 128),
             part_cache_type => $params{'part_cache_type'} || 'memory',
@@ -476,7 +482,7 @@ my $experr;
 
 reset_taperoot(1);
 $main::scribe = Amanda::Taper::Scribe->new(
-    taperscan => Mock::Taperscan->new(disable_leom => 1),
+    taperscan => Mock::Taperscan->new(disable_leom => 1, changer => $chg),
     feedback => Mock::Feedback->new({allow => 1}));
 
 reset_events();
@@ -513,7 +519,7 @@ is_deeply([ @events ], [
 
 reset_taperoot(1);
 $main::scribe = Amanda::Taper::Scribe->new(
-    taperscan => Mock::Taperscan->new(),
+    taperscan => Mock::Taperscan->new(changer => $chg),
     feedback => Mock::Feedback->new({ allow => 1 }));
 
 reset_events();
@@ -544,7 +550,7 @@ is_deeply([ @events ], [
 
 reset_taperoot(2);
 $main::scribe = Amanda::Taper::Scribe->new(
-    taperscan => Mock::Taperscan->new(disable_leom => 1),
+    taperscan => Mock::Taperscan->new(disable_leom => 1, changer => $chg),
     feedback => Mock::Feedback->new({ allow => 1 }, { allow => 1 }));
 
 reset_events();
@@ -577,14 +583,14 @@ is_deeply([ @events ], [
 
       [ 'dump_cb', 'DONE', [], undef, bi(655360) ],
       [ 'scribe_notif_tape_done', 'FAKELABEL', bi(3), bi(262144) ],
-    ], "correct event sequence for a multipart scribe of more than a whole volume, without LEOM")
+    ], "correct event sequence for a multipart scribe of more than a whole volume, without LEOM" . Data::Dumper::Dumper(@events))
     or print (Dumper([@events]));
 
 # same test, but with LEOM support
 
 reset_taperoot(2);
 $main::scribe = Amanda::Taper::Scribe->new(
-    taperscan => Mock::Taperscan->new(),
+    taperscan => Mock::Taperscan->new(changer => $chg),
     feedback => Mock::Feedback->new({ allow => 1 },{ allow => 1 }));
 
 reset_events();
@@ -621,7 +627,7 @@ is_deeply([ @events ], [
 
 reset_taperoot(1);
 $main::scribe = Amanda::Taper::Scribe->new(
-    taperscan => Mock::Taperscan->new(slots => ["1", "bogus"], disable_leom => 1),
+    taperscan => Mock::Taperscan->new(slots => ["1", "bogus"], disable_leom => 1, changer => $chg),
     feedback => Mock::Feedback->new({ allow => 1 },{ allow => 1 }));
 
 reset_events();
@@ -655,7 +661,7 @@ is_deeply([ @events ], [
 
 reset_taperoot(1);
 $main::scribe = Amanda::Taper::Scribe->new(
-    taperscan => Mock::Taperscan->new(slots => ["1", "bogus"]),
+    taperscan => Mock::Taperscan->new(slots => ["1", "bogus"], changer => $chg),
     feedback => Mock::Feedback->new({ allow => 1 }, { allow => 1 }));
 
 reset_events();
@@ -690,7 +696,7 @@ is_deeply([ @events ], [
 
 reset_taperoot(2);
 $main::scribe = Amanda::Taper::Scribe->new(
-    taperscan => Mock::Taperscan->new(),
+    taperscan => Mock::Taperscan->new(changer => $chg),
     feedback => Mock::Feedback->new({ allow => 1 }, { cause => 'config', message => "sorry!" }));
 
 reset_events();
@@ -722,7 +728,7 @@ is_deeply([ @events ], [
 
 reset_taperoot(2);
 $main::scribe = Amanda::Taper::Scribe->new(
-    taperscan => Mock::Taperscan->new(disable_leom => 1),
+    taperscan => Mock::Taperscan->new(disable_leom => 1, changer => $chg),
     feedback => Mock::Feedback->new({ allow => 1 }));
 
 reset_events();
@@ -744,7 +750,7 @@ is_deeply([ @events ], [
 
 reset_taperoot(2);
 $main::scribe = Amanda::Taper::Scribe->new(
-    taperscan => Mock::Taperscan->new(),
+    taperscan => Mock::Taperscan->new(changer => $chg),
     feedback => Mock::Feedback->new({ allow => 1 }));
 $Amanda::Config::debug_taper = 9;
 reset_events();
@@ -772,8 +778,8 @@ my $maxint64 = Math::BigInt->new("9223372036854775808");
 is_deeply(
     { get_splitting_args_from_config(
     ) },
-    { },
-    "default is no params");
+    { allow_split => 0 },
+    "default is only allow_split set to 0");
 
 is_deeply(
     { get_splitting_args_from_config(
@@ -781,7 +787,7 @@ is_deeply(
        dle_split_diskbuffer => $Installcheck::TMP,
        dle_fallback_splitsize => 100,
     ) },
-    { part_size => 0, part_cache_type => 'none' },
+    { allow_split => 0, part_size => 0, part_cache_type => 'none' },
     "tape_splitsize = 0 indicates no splitting");
 
 is_deeply(
@@ -790,7 +796,7 @@ is_deeply(
        part_size => 100,
        part_cache_dir => "/tmp",
     ) },
-    { },
+    { allow_split => 0 },
     "default if dle_allow_split is false, no splitting");
 
 is_deeply(
@@ -798,14 +804,14 @@ is_deeply(
        dle_tape_splitsize => 200,
        dle_fallback_splitsize => 150,
     ) },
-    { part_cache_type => 'memory', part_size => 200, part_cache_max_size => 150 },
+    { allow_split => 1,part_cache_type => 'memory', part_size => 200, part_cache_max_size => 150 },
     "when cache_inform is available, tape_splitsize is used, not fallback");
 
 is_deeply(
     { get_splitting_args_from_config(
        dle_tape_splitsize => 200,
     ) },
-    { part_size => 200, part_cache_type => 'memory', part_cache_max_size => 1024*1024*10, },
+    { allow_split => 1, part_size => 200, part_cache_type => 'memory', part_cache_max_size => 1024*1024*10, },
     "no split_diskbuffer and no fallback_splitsize, fall back to default (10M)");
 
 is_deeply(
@@ -814,7 +820,7 @@ is_deeply(
        dle_split_diskbuffer => "$Installcheck::TMP/does!not!exist!",
        dle_fallback_splitsize => 150,
     ) },
-    { part_size => 200, part_cache_type => 'memory', part_cache_max_size => 150 },
+    { allow_split => 1, part_size => 200, part_cache_type => 'memory', part_cache_max_size => 150 },
     "invalid split_diskbuffer => fall back (silently)");
 
 is_deeply(
@@ -822,7 +828,7 @@ is_deeply(
        dle_tape_splitsize => 200,
        dle_split_diskbuffer => "$Installcheck::TMP/does!not!exist!",
     ) },
-    { part_size => 200, part_cache_type => 'memory', part_cache_max_size => 1024*1024*10 },
+    { allow_split => 1, part_size => 200, part_cache_type => 'memory', part_cache_max_size => 1024*1024*10 },
     ".. even to the default fallback (10M)");
 
 is_deeply(
@@ -831,7 +837,7 @@ is_deeply(
        dle_split_diskbuffer => "$Installcheck::TMP",
        dle_fallback_splitsize => 250,
     ) },
-    { part_size => $maxint64, part_cache_type => 'memory', part_cache_max_size => 250,
+    { allow_split => 1, part_size => $maxint64, part_cache_type => 'memory', part_cache_max_size => 250,
       warning => "falling back to memory buffer for splitting: " .
                 "insufficient space in disk cache directory" },
     "not enough space in split_diskbuffer => fall back (with warning)");
@@ -843,7 +849,7 @@ is_deeply(
        dle_split_diskbuffer => "$Installcheck::TMP",
        dle_fallback_splitsize => 150,
     ) },
-    { part_size => 200, part_cache_type => 'disk', part_cache_dir => "$Installcheck::TMP" },
+    { allow_split => 1, part_size => 200, part_cache_type => 'disk', part_cache_dir => "$Installcheck::TMP" },
     "if split_diskbuffer exists and splitsize is nonzero, use it");
 
 is_deeply(
@@ -852,7 +858,7 @@ is_deeply(
        dle_split_diskbuffer => "$Installcheck::TMP",
        dle_fallback_splitsize => 250,
     ) },
-    { part_size => 0, part_cache_type => 'none' },
+    { allow_split => 0, part_size => 0, part_cache_type => 'none' },
     ".. but if splitsize is zero, no splitting");
 
 is_deeply(
@@ -860,7 +866,7 @@ is_deeply(
        dle_split_diskbuffer => "$Installcheck::TMP",
        dle_fallback_splitsize => 250,
     ) },
-    { part_size => 0, part_cache_type => 'none' },
+    { allow_split => 0, part_size => 0, part_cache_type => 'none' },
     ".. and if splitsize is missing, no splitting");
 
 is_deeply(
@@ -868,7 +874,7 @@ is_deeply(
        part_size => 300,
        part_cache_type => 'none',
     ) },
-    { part_size => 300, part_cache_type => 'none' },
+    { allow_split => 1, part_size => 300, part_cache_type => 'none' },
     "part_* parameters handled correctly when missing");
 
 is_deeply(
@@ -878,7 +884,7 @@ is_deeply(
        part_cache_dir => $Installcheck::TMP,
        part_cache_max_size => 250,
     ) },
-    { part_size => 300, part_cache_type => 'disk',
+    { allow_split => 1, part_size => 300, part_cache_type => 'disk',
       part_cache_dir => $Installcheck::TMP, part_cache_max_size => 250, },
     "part_* parameters handled correctly when specified");
 
@@ -889,10 +895,11 @@ is_deeply(
        part_cache_dir => "$Installcheck::TMP/does!not!exist!",
        part_cache_max_size => 250,
     ) },
-    { part_size => 300, part_cache_type => 'none',
+    { allow_split => 1, part_size => 300, part_cache_type => 'none',
       part_cache_max_size => 250,
       warning => "part-cache-dir '$Installcheck::TMP/does!not!exist! does not exist; "
               . "using part cache type 'none'"},
     "part_* parameters handled correctly when specified");
 
+$chg->quit();
 rmtree($taperoot);