AFS-Command
view release on metacpan or search on metacpan
t/02vos_volserver.t view on Meta::CPAN
#
# First, let's get all the config data we need.
#
my $volname_prefix = $AFS::Command::Tests::Config{AFS_COMMAND_VOLNAME_PREFIX} || do {
print "not ok $TestCounter..$TestTotal\n";
die "Missing configuration variable AFS_COMMAND_VOLNAME_PREFIX\n";
};
my $cell = $AFS::Command::Tests::Config{AFS_COMMAND_CELLNAME} || do {
print "not ok $TestCounter..$TestTotal\n";
die "Missing configuration variable AFS_COMMAND_CELLNAME\n";
};
my $partition_list = $AFS::Command::Tests::Config{AFS_COMMAND_PARTITION_LIST} || do {
print "not ok $TestCounter..$TestTotal\n";
die "Missing configuration variable AFS_COMMAND_PARTITION_LIST\n";
};
my $binary = $AFS::Command::Tests::Config{AFS_COMMAND_BINARY_VOS} || 'vos';
my @servers = ();
my @partitions = ();
my $server_primary = "";
my $partition_primary = "";
foreach my $serverpart ( split(/\s+/,$partition_list) ) {
my ($server,$partition) = split(/:/,$serverpart);
unless ( $server && $partition ) {
print "not ok $TestCounter..$TestTotal\n";
die "Invalid server:/partition specification: '$serverpart'\n";
}
$server_primary = $server unless $server_primary;
$partition_primary = $partition unless $partition_primary;
push(@servers,$server);
push(@partitions,$partition);
}
#
# If the constructor fails, we're doomed.
#
my $vos = AFS::Command::VOS->new
(
command => $binary,
);
if ( ref $vos && $vos->isa("AFS::Command::VOS") ) {
print "# AFS::Command::VOS->new()\n";
print "ok $TestCounter\n";
$TestCounter++;
} else {
print "not ok $TestCounter..$TestTotal\n";
die "Unable to instantiate AFS::Command::VOS object\n";
}
#
# Thi test is kinda boring... Just verifying that partinfo and
# listpart are consistent.
#
my $listpart = $vos->listpart
(
server => $server_primary,
cell => $cell,
);
if ( ref $listpart && $listpart->isa("AFS::Object::FileServer") ) {
print "# AFS::Command::VOS->listpart()\n";
print "ok $TestCounter\n";
$TestCounter++;
} else {
print "not ok $TestCounter..$TestTotal\n";
die("Unable to query partinfo on server '$server_primary', in cell '$cell':\n" .
$vos->errors());
}
my $partinfo = $vos->partinfo
(
server => $server_primary,
cell => $cell,
);
if ( ref $partinfo && $partinfo->isa("AFS::Object::FileServer") ) {
print "# AFS::Command::VOS->partinfo()\n";
print "ok $TestCounter\n";
$TestCounter++;
} else {
print "not ok $TestCounter..$TestTotal\n";
die("Unable to query partinfo on server '$server_primary', in cell '$cell':\n" .
$vos->errors());
}
foreach my $objectpair ( [ $partinfo, $listpart ], [ $listpart, $partinfo ] ) {
my ($src,$dst) = @$objectpair;
my @partitions = $src->getPartitionNames();
if ( @partitions ) {
print "# AFS::Command::VOS->getPartitionNames()\n";
print "ok $TestCounter\n";
$TestCounter++;
} else {
print "not ok $TestCounter..$TestTotal\n";
die("Unable to get list of partition names for server '$server_primary', in cell '$cell':\n");
}
my $attribute_test = 1;
foreach my $partname ( @partitions ) {
my $partition = $dst->getPartition($partname);
unless ( ref $partition && $partition->isa("AFS::Object::Partition") ) {
print "not ok $TestCounter..$TestTotal\n";
die("Inconsistent data in listpart and partinfo output\n" .
"Found partname '$partname' in one, but not the other");
}
if ( $partition->hasAttribute('available') ) {
( run in 1.703 second using v1.01-cache-2.11-cpan-39bf76dae61 )