AFS-Command

 view release on metacpan or  search on metacpan

t/01vos_dumprestore.t  view on Meta::CPAN

	}
    } else {
	print "not ok $TestCounter\n";
	warn("Unable to dump volume '$volname' in cell '$cell' to file '$files{$ctype}':\n" .
	     $vos->errors());
	die Data::Dumper->Dump([$vos],['vos']);
    }
    $TestCounter++;

}

if ( $dumpfilter ) {

    $result = $vos->dump
      (
       id			=> $volname,
       time			=> 0,
       file			=> $files{raw},
       cell			=> $cell,
       filterout		=> [$dumpfilter],
      );
    if ( $result ) {
	print "ok $TestCounter\n";
    } else {
	print "not ok $TestCounter\n";
	warn("Unable to dump volume '$volname' in cell '$cell' to file '$files{raw}':\n" .
	     $vos->errors());
    }
    $TestCounter++;

    my ($ctype) = ( $enabled{gzip} ? 'gzip' :
		    $enabled{bzip2} ? 'bzip2' : '' );

    if ( $ctype ) {

	$result = $vos->dump
	  (
	   id			=> $volname,
	   time			=> 0,
	   file			=> $files{$ctype},
	   cell			=> $cell,
	   filterout		=> [$dumpfilter],
	  );
	if ( $result ) {
	    print "ok $TestCounter\n";
	} else {
	    print "not ok $TestCounter\n";
	    warn("Unable to dump volume '$volname' in cell '$cell' to file '$files{raw}':\n" .
		 "(Testing dump filter with compression)\n" .
		 $vos->errors());
	}

    } else {
	print "ok $TestCounter # skip Compression support disabled\n";
    }
    $TestCounter++;

} else {

    for ( my $count = 0 ; $count < 2 ; $count++ ) {
	print "ok $TestCounter # skip Dump filter tests disabled\n";
	$TestCounter++;
    }

}

#
# Finally, let's remove that volume, so we can reuse the name for the
# restore tests.
#
$result = $vos->remove
  (
   server		=> $server_primary,
   partition		=> $partition_primary,
   id			=> $volname,
   cell			=> $cell,
  );
if ( $result ) {
    print "ok $TestCounter\n";
    $TestCounter++;
} else {
    print "not ok $TestCounter..$TestTotal\n";
    die("Unable to remove volume '$volname' from server '$server_primary', " .
	"partition '$partition_primary', in cell '$cell':\n" .
	$vos->errors());
}



#
# If we made it this far, dump works fine.  Now let's test restore...
#
$result = $vos->restore
  (
   server		=> $server_primary,
   partition		=> $partition_primary,
   name			=> $volname,
   file			=> $files{raw},
   overwrite		=> 'full',
   cell			=> $cell,
  );
if ( $result ) {
    print "ok $TestCounter\n";
    $Volnames{$volname}++;
} else {
    print "not ok $TestCounter\n";
    warn("Unable to restore volume '$volname' from file '$files{raw}',\n" .
	 "to server '$server_primary', partition '$partition_primary', name '$volname':\n" .
	 $vos->errors());
}
$TestCounter++;

foreach my $ctype ( qw(gunzip bunzip2) ) {

    unless ( $enabled{$ctype} ) {
	for ( my $count = 0 ; $count < 1 ; $count++ ) {
	    print "ok $TestCounter # skip Compression support for $ctype disabled\n";
	    $TestCounter++;
	}
	next;
    }

    $result = $vos->restore
      (
       server			=> $server_primary,
       partition		=> $partition_primary,
       name			=> $volname,
       file			=> $files{$ctype},
       overwrite		=> 'full',
       cell			=> $cell,
      );
    if ( $result ) {
	print "ok $TestCounter\n";
    } else {
	print "not ok $TestCounter\n";
	warn("Unable to restore volume '$volname' from file '$files{$ctype}',\n" .
	     "to server '$server_primary', partition '$partition_primary', name '$volname':\n" .
	     $vos->errors());
    }
    $TestCounter++;

}

if ( $restorefilter ) {

    $result = $vos->restore
      (
       server			=> $server_primary,
       partition		=> $partition_primary,
       name			=> $volname,
       file			=> $files{raw},
       overwrite		=> 'full',
       cell			=> $cell,
       filterin			=> [$restorefilter],
      );
    if ( $result ) {
	print "ok $TestCounter\n";
    } else {
	print "not ok $TestCounter\n";
	warn("Unable to restore volume '$volname' from file '$files{raw}',\n" .
	     "using restore filter '$restorefilter', " .
	     "to server '$server_primary', partition '$partition_primary', name '$volname':\n" .
	     $vos->errors());
    }
    $TestCounter++;

    my ($ctype) = ( $enabled{gunzip} ? 'gunzip' :
		    $enabled{bunzip2} ? 'bunzip2' : '' );

    if ( $ctype ) {

	$result = $vos->restore
	  (
	   server		=> $server_primary,
	   partition		=> $partition_primary,
	   name			=> $volname,
	   file			=> $files{$ctype},
	   overwrite		=> 'full',
	   cell			=> $cell,
	   filterin		=> [$restorefilter],
	  );
	if ( $result ) {
	    print "ok $TestCounter\n";
	} else {
	    print "not ok $TestCounter\n";
	    warn("Unable to restore volume '$volname' from file '$files{$ctype}',\n" .
		 "using restore filter '$restorefilter', " .
		 "to server '$server_primary', partition '$partition_primary', name '$volname':\n" .
		 $vos->errors());
	}

    } else {
	print "ok $TestCounter # skip Compression support disabled\n";
    }
    $TestCounter++;

} else {

    for ( my $count = 0 ; $count < 2 ; $count++ ) {
	print "ok $TestCounter # skip Restoreg filter tests disabled\n";
	$TestCounter++;
    }

}

$result = $vos->remove
  (
   server		=> $server_primary,
   partition		=> $partition_primary,
   id			=> $volname,
   cell			=> $cell,
  );
if ( $result ) {
    print "ok $TestCounter\n";
    $TestCounter++;
    delete $Volnames{$volname};
} else {
    print "not ok $TestCounter..$TestTotal\n";
    die("Unable to remove volume '$volname' from server '$server_primary', " .
	"partition '$partition_primary', in cell '$cell':\n" .
	$vos->errors());
}

exit 0;

END {

    #$TestCounter--;
    #warn "Total number of tests == $TestCounter\n";

    if ( %Volnames ) {
	warn("The following temporary volumes were created, and may be left over:\n\t" .
	     join("\n\t",sort keys %Volnames) . "\n");
    }
}



( run in 0.573 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )