IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 31, 2019, 10:35:20 AM (7 years ago)
Author:
eugene
Message:

test case if volume is not valid

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20191011/Nebulous/t/71_client_there_can_be_only_one.t

    r40998 r41013  
    1010use Apache::Test qw( -withtestmore );
    1111
    12 plan tests => 8;
     12plan tests => 13;
    1313
    1414use lib qw( ./t ./lib );
     
    2323Test::Nebulous->cleanup;
    2424
     25## volume is defined, but it is not valid (should exit)
     26## Test::Nebulous->setup;
     27## {
     28##     my $key = "foo";
     29##     my $neb = Nebulous::Client->new(
     30##         proxy => "http://$hostport/nebulous",
     31##     );
     32##
     33##     my $uri = $neb->create($key, "node01");
     34##
     35##     $neb->replicate($key, "node02");
     36##
     37##     ## set node02 to an invalid state:
     38##     Test::Nebulous->switch_node_state;
     39##
     40##     # if requested node is invalid, the other instance is kept and the invalid one removed
     41##     # but since invalid instances are removed with a prune call, they are not counted
     42##     # in the number of items removed (return by the function call)
     43##     is($neb->there_can_be_only_one($key, "node02"), 0, "there can be only one!");
     44##     my $locations = $neb->find_instances( "foo" );
     45##
     46##     is( scalar @$locations, 1, "found 1" );
     47##     is($locations->[0], $uri, "instance on correct volume" );
     48## };
     49## is($@, "", "there_can_be_only_one with supplied volume should succeed");
     50## die "asdf";
     51
     52#######
     53
     54## volume not defined
    2555Test::Nebulous->setup;
    26 
    2756{
    2857    my $key = "foo";
     
    4069}
    4170
     71## volume is defined, only valid instances
    4272Test::Nebulous->setup;
    4373eval {
     
    5080    my $uri = $neb->replicate($key, "node02");
    5181    is($neb->there_can_be_only_one($key, "node02"), 1, "there can be only one!");
     82
     83    my $locations = $neb->find_instances( "foo" );
     84
     85    is( scalar @$locations, 1, "found 1" );
     86    is($locations->[0], $uri, "instance on correct volume" );
     87};
     88is($@, "", "there_can_be_only_one with supplied volume should succeed");
     89
     90## volume is defined, but it is not valid (should exit)
     91Test::Nebulous->setup;
     92eval {
     93    my $key = "foo";
     94    my $neb = Nebulous::Client->new(
     95        proxy => "http://$hostport/nebulous",
     96    );
     97    my $uri = $neb->create($key, "node01");
     98
     99    $neb->replicate($key, "node02");
     100
     101    ## set node02 to an invalid state:
     102    Test::Nebulous->switch_node_state;
     103
     104    # if requested node is invalid, nothing is removed
     105    is($neb->there_can_be_only_one($key, "node02"), 0, "there can be only one!");
    52106
    53107    my $locations = $neb->find_instances( "foo" );
Note: See TracChangeset for help on using the changeset viewer.