AFS-Command

 view release on metacpan or  search on metacpan

t/00vos_basic.t  view on Meta::CPAN

    } else {
	print "not ok $TestCounter..$TestTotal\n";
	die("Unable to remove volume '$volname_readonly' from server '$servers[$index]', " .
	    "partition '$partitions[$index]', in cell '$cell':\n" .
	    $vos->errors());
    }
    $TestCounter++;

}

#
# Test the vos offline functionality, if supported.
#
if ( $vos->supportsOperation('offline') ) {

    foreach my $method ( qw(offline online) ) {

	$result = $vos->$method
	  (
	   id			=> $volname,
	   server		=> $servers[0],
	   partition		=> $partitions[0],
	   cell			=> $cell,
	  );
	if ( $result ) {
	    print "ok $TestCounter\n";
	} else {
	    print "not ok $TestCounter\n";
	    die("Unable to $method volume '$volname' from server '$servers[0]', " .
		"partition '$partitions[0]', in cell '$cell':\n" .
		$vos->errors());
	}
	$TestCounter++;

	$result = $vos->examine
	  (
	   id			=> $volname,
	   cell			=> $cell,
	  );
	if ( ref $result ) {
	    print "ok $TestCounter\n";
	} else {
	    print "not ok $TestCounter\n";
	    die("Unable to examine volume '$volname' on server '$servers[0]', " .
		"partition '$partitions[0]', in cell '$cell':\n" .
		$vos->errors());
	}
	$TestCounter++;

	my ($header) = $result->getVolumeHeaders();

	if ( $header->status() eq $method ) {
	    print "ok $TestCounter\n";
	} else {
	    print "not ok $TestCounter\n";
	    warn("Volume '$volname' on server '$servers[0]', " .
		 "partition '$partitions[0]', in cell '$cell' was not $method");
	}
	$TestCounter++;

	if ( $header->attached() ) {
	    print "ok $TestCounter\n";
	} else {
	    print "not ok $TestCounter\n";
	    warn("Volume '$volname' on server '$servers[0]', " .
		 "partition '$partitions[0]', in cell '$cell' does not appear to be attached");
	}
	$TestCounter++;

    }

} else {

    for ( my $index = 0 ; $index <= 7 ; $index++ ) {
	print "ok $TestCounter\n";
	$TestCounter++;
    }

}

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

#
# Finally, one we *expect* to fail...
#
$result = $vos->examine
  (
   id				=> $volname,
   cell				=> $cell,
  );
if ( $result ) {
    print "not ok $TestCounter..$TestTotal\n";
    die("Volume '$volname' in cell '$cell', still exists after a successful vos remove!!\n");
} elsif ( $vos->errors() =~ /VLDB: no such entry/i ) {
    print "ok $TestCounter\n";
} else {
    print "not ok $TestCounter..$TestTotal\n";
    die("Unexpected result from vos examine:\n" . $vos->errors());
}
$TestCounter++;

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" .



( run in 1.533 second using v1.01-cache-2.11-cpan-13bb782fe5a )