IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 28, 2019, 4:26:42 PM (7 years ago)
Author:
eugene
Message:

find_instances has some inconsistencies : meaning of hard_volume, use of find_invalid

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20191011/Nebulous/t/56_client_find_instances.t

    r19469 r40998  
    1010use Apache::Test qw( -withtestmore );
    1111
    12 plan tests => 29;
     12plan tests => 35;
    1313
    1414use lib qw( ./t ./lib );
     
    2020my $hostport = Apache::Test->config->{ 'hostport' };
    2121
    22 Test::Nebulous->setup;
    23 
     22### XXX EAM : this test suite finds real errors in the implementation. 
     23
     24## the API is now slightly different (what is the state of the API in the ipp ops code?)
     25## find_instances ("key", "volume", find_invalid)
     26
     27## this returns a result even if we request a hard volume unless the hard volume is not valid
     28
     29Test::Nebulous->setup;
     30Test::Nebulous->cleanup;
     31
     32### TEST BLOCK for find_invalid
     33## Test::Nebulous->setup;
     34## {
     35##     # volume/key, volume override
     36##     my $neb = Nebulous::Client->new(
     37##         proxy => "http://$hostport/nebulous",
     38##     );
     39##     $neb->create( "foo", "~node02" );
     40## #    $neb->replicate( "foo", "~node02" );
     41##
     42##     Test::Nebulous->switch_node_state;
     43##     my $tmphost;
     44##
     45## #   my $locations = $neb->find_instances( "neb:///foo", "~node02", 1); # result : no instance
     46## #   my $locations = $neb->find_instances( "neb:///foo", "~node02", 0); # result : no instance
     47## #   my $locations = $neb->find_instances( "neb:///foo", "~node02"); # result : no instance
     48##
     49## #   my $locations = $neb->find_instances( "neb:///foo", "node02", 1); # result : no instance
     50## #   my $locations = $neb->find_instances( "neb:///foo", "node02", 0); # result : no instance
     51## #   my $locations = $neb->find_instances( "neb:///foo", "node02"); # result : no instances
     52##
     53## #   my $locations = $neb->find_instances( "neb:///foo", undef, 1);
     54## #   my $locations = $neb->find_instances( "neb:///foo", undef, 0);
     55## #   my $locations = $neb->find_instances( "neb:///foo", $tmphost, 0);
     56##
     57## #   my $locations = $neb->find_instances( "neb:///foo", "bebaz", 1);
     58## #   my $locations = $neb->find_instances( "neb:///foo", "bebaz", 0);
     59##
     60## #   my $locations = $neb->find_instances( "neb:///foo");
     61## #   my $locations = $neb->find_instances( "neb://bebaz/foo");
     62##
     63## #   my $locations = $neb->find_instances( "neb:///foo");
     64## #   my $locations = $neb->find_instances( "neb:///foo", undef, 0);
     65##
     66##     foreach my $f (@$locations) {
     67##      print "location: $f\n";
     68##     }
     69##
     70##     is( scalar @$locations, 1, "found 1" );
     71##     like( @$locations[0], qr/file:/, "URIs match" );
     72##     ok( -e _get_file_path( @$locations[0] ), "URI matches file" );
     73## }
     74## die "quit";
     75
     76## Test::Nebulous->setup;
     77## eval {
     78##     # volume/key, volume override
     79##     my $neb = Nebulous::Client->new(
     80##         proxy => "http://$hostport/nebulous",
     81##     );
     82##     $neb->create( "foo", "~node01" );
     83##
     84##     my $locations_1 = $neb->find_instances( "neb://~invalid/foo", "~invalid");
     85##     is($locations_1, undef, "no instances in invalid node" );
     86##
     87##     # EAM: we fail this test because the logic of find_instances has
     88##     # changed: as long as there is an instance on a valid node, the
     89##     # instance gets returned
     90##     my $locations = $neb->find_instances( "neb://node01/foo", "~node02" );
     91##     is($locations, undef, "no instances on specified volume" );
     92## };
     93##print "result: $@\n";
     94##like( $@, qr/result message/, "my message" );
     95
     96# find a single instance by raw name (foo)
     97Test::Nebulous->setup;
    2498{
    2599    # key
     
    36110}
    37111
    38 Test::Nebulous->setup;
    39 
     112# find a both instances of a duplicated object
     113Test::Nebulous->setup;
    40114{
    41115    # key
     
    56130
    57131Test::Nebulous->setup;
    58 
    59132{
    60133    # key, volume
     
    103176}
    104177
    105 Test::Nebulous->setup;
    106 
     178# find instance using hard_volume for wrong node
     179# (should still return a valid instance)
     180Test::Nebulous->setup;
    107181{
    108182    # volume/key, volume override
     
    114188    my $locations = $neb->find_instances( "neb://node01/foo", "~node02" );
    115189
    116     is($locations, undef, "no instances on specified volume" );
     190    is( scalar @$locations, 1, "found 1" );
     191    like( @$locations[0], qr/file:/, "URIs match" );
     192    ok( -e _get_file_path( @$locations[0] ), "URI matches file" );
     193#   the API used to return undef if we used a hard_volume but it was not there
     194#   is($locations, undef, "no instances on specified volume" );
     195}
     196
     197# find instance using hard_volume for unknown node
     198# (should fail)
     199Test::Nebulous->setup;
     200{
     201    # volume/key, volume override
     202    my $neb = Nebulous::Client->new(
     203        proxy => "http://$hostport/nebulous",
     204    );
     205    $neb->create( "foo", "~node01" );
     206
     207    my $locations = $neb->find_instances( "neb://node01/foo", "~nobody" );
     208
     209    is( scalar @$locations, 0, "found 0" );
     210#    like( @$locations[0], qr/file:/, "URIs match" );
     211#    ok( -e _get_file_path( @$locations[0] ), "URI matches file" );
     212
     213#   the API used to return undef if we used a hard_volume but it was not there
     214#   is($locations, undef, "no instances on specified volume" );
     215}
     216
     217# find instance using hard_volume for unavailable node
     218# (should fail)
     219Test::Nebulous->setup;
     220{
     221    # volume/key, volume override
     222    my $neb = Nebulous::Client->new(
     223        proxy => "http://$hostport/nebulous",
     224    );
     225    $neb->create( "foo", "~node01" );
     226
     227    my $locations = $neb->find_instances( "neb://node01/foo", "~node04" );
     228
     229    is( scalar @$locations, 1, "found 1" );
     230    like( @$locations[0], qr/file:/, "URIs match" );
     231    ok( -e _get_file_path( @$locations[0] ), "URI matches file" );
     232
     233#   the API used to return undef if we used a hard_volume but it was not there
     234#   is($locations, undef, "no instances on specified volume" );
    117235}
    118236
     
    153271
    154272Test::Nebulous->setup;
    155 
    156273{
    157274    my $neb = Nebulous::Client->new(
     
    171288    $neb->find_instances();
    172289};
    173 like( $@, qr/1 - 2 were expected/, "no params" );
     290like( $@, qr/1 - 3 were expected/, "no params" );
    174291
    175292Test::Nebulous->setup;
     
    180297    );
    181298
    182     $neb->find_instances( "foo", 'read', 3 );
     299    $neb->find_instances( "foo", 'read', 3, 5 );
    183300};
    184 like( $@, qr/1 - 2 were expected/, "too many params" );
     301like( $@, qr/1 - 3 were expected/, "too many params" );
    185302
    186303Test::Nebulous->cleanup;
Note: See TracChangeset for help on using the changeset viewer.