AFS

 view release on metacpan or  search on metacpan

src/BOS/t/BOS.t  view on Meta::CPAN

# -*-cperl-*-

use strict;
use lib qw(../../inc ../inc);
use blib;

use Test::More;

BEGIN {
    use AFS::FS;
    if (AFS::FS::isafs('./')) { plan tests => 39; }
    else { plan skip_all => 'Working directory is not in AFS file system ...'; }

    use_ok('AFS::BOS');
}

use AFS::VLDB;
use AFS::Cell 'localcell';
my $vldb = AFS::VLDB->new;
my $vldblist = $vldb->listvldbentry('root.afs');
my $server = $vldblist->{'root.afs'}->{'server'}->[0]->{'name'};
my $l_cell = localcell;

my $bos = AFS::BOS->new($server);
is(ref($bos), 'AFS::BOS', 'bos->new()');
undef $bos;

is(leak_test(), 1210, 'bos leak_test');

$bos = AFS::BOS->new($server);
my ($cell, $hostlist) = $bos->listhosts;
is($cell, $l_cell, 'bos-listhost: Cellname OK');
ok(defined $$hostlist[0], 'bos->listhost: Host list OK');

my @users = $bos->listusers;
ok(defined $users[0], 'bos->listusers: User list OK');

$bos->setrestart('14:00', 'a', 0);
like($AFS::CODE, qr/Flag "general" should be numeric/, 'bos->setrestart(time no_integer newbinary)');

$bos->setrestart('14:00', 0, 'a');
like($AFS::CODE, qr/Flag "newbinary" should be numeric/, 'bos->setrestart(time general no_integer)');

$bos->setrestart('14:00', 1, 1);
like($AFS::CODE, qr/specify more than one restart time/, 'bos->setrestart(time general=1 newbinary=1)');

my ($generalTime, $newBinaryTime) = $bos->getrestart;
ok(defined $generalTime, 'bos->getrestart: GeneralTime OK');
ok(defined $newBinaryTime, 'bos->getrestart: NewBinaryTime OK');

my $result = $bos->status(0, [ 'fs', ]) || $bos->status(0, [ 'dafs', ]);
isa_ok($result->{fs} || $result->{dafs}, 'HASH', 'bos->status OK');

my %h = ( nog => 1 );
$bos->adduser(\%h);
like($AFS::CODE, qr/USER not an array reference/, 'bos->adduser(HASH)');

$bos->addhost('host', 'a');
like($AFS::CODE, qr/Flag "clone" should be numeric/, 'bos->addhost(host no_integer)');

$bos->addhost(\%h);
like($AFS::CODE, qr/HOST not an array reference/, 'bos->addhost(HASH)');

my $host = 'very_very_very_very_long_long_long_long_name_name_name_name_name_name';
$bos->addhost($host, 1);
like($AFS::CODE, qr/host name too long/, 'bos->addhost(long_name)');



( run in 1.866 second using v1.01-cache-2.11-cpan-39bf76dae61 )