IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 27, 2019, 12:04:14 PM (7 years ago)
Author:
eugene
Message:

merging updates to Nebulous from EAM dev branch ipp-20191011

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/t/05_server_replicate_object.t

    r24995 r41172  
    88use warnings FATAL => qw( all );
    99
    10 use Test::More tests => 25;
     10use Test::More tests => 43;
    1111
    1212use lib qw( ./t ./lib );
     
    2828
    2929Test::Nebulous->setup;
    30 
    3130{
    3231    # key
     
    4544
    4645Test::Nebulous->setup;
    47 
    4846{
    4947    # key, $volume
     
    6260
    6361Test::Nebulous->setup;
    64 
    6562{
    6663    # key, $volume is undef
     
    7976
    8077Test::Nebulous->setup;
    81 
    8278{
    8379    # key, $volume
     
    147143}
    148144
     145# hard_volume tests:
     146
     147# replication with hard_volume:
     148Test::Nebulous->setup;
     149{
     150    my @nodedirs = Test::Nebulous->get_node_dirs();
     151
     152    # checking on replicate_object: hard_volume as node target
     153    my $uri1 = $neb->create_object("foo", "~node01");
     154    my $uri2 = $neb->replicate_object("foo", "~node02");
     155
     156    my $locations = $neb->find_instances("foo");
     157    my $Nloc = @$locations;
     158
     159    is($Nloc, 2, "found 2 instances");
     160   
     161    my $loc1 = $locations->[0];
     162    my $loc2 = $locations->[1];
     163
     164    like($loc1, qr/$nodedirs[0]/, "instance matches expected node");
     165    like($loc2, qr/$nodedirs[1]/, "instance matches expected node");
     166}
     167
     168# replication to unknown volume: should succeed
     169Test::Nebulous->setup;
     170{
     171    my @nodedirs = Test::Nebulous->get_node_dirs();
     172
     173    # checking on replicate_object, does this logic make sense?
     174    my $uri1 = $neb->create_object("foo", "~node01");
     175    my $uri2 = $neb->replicate_object("foo", "dummy");
     176
     177    my $locations = $neb->find_instances("foo");
     178    my $Nloc = @$locations;
     179
     180    is($Nloc, 2, "found 2 instances");
     181   
     182    my $loc1 = $locations->[0];
     183    my $loc2 = $locations->[1];
     184
     185    like($loc1, qr/$nodedirs[0]/, "instance matches expected node");
     186    uri_scheme_ok($loc2, 'file');
     187}
     188
     189# replication to unknown volume with hard_volume: should fail
     190Test::Nebulous->setup;
     191eval {
     192    my @nodedirs = Test::Nebulous->get_node_dirs();
     193
     194    # checking on replicate_object, does this logic make sense?
     195    my $uri1 = $neb->create_object("foo", "~node01");
     196    my $uri2 = $neb->replicate_object("foo", "~dummy");
     197
     198    my $locations = $neb->find_instances("foo");
     199};
     200like($@, qr/is not a valid volume name/, "replicate to unknown node with hard_volume should fail");
     201
     202# replication to unavailable volume: should succeed
     203Test::Nebulous->setup;
     204{
     205    my @nodedirs = Test::Nebulous->get_node_dirs();
     206
     207    # checking on replicate_object, does this logic make sense?
     208    my $uri1 = $neb->create_object("foo", "~node01");
     209    my $uri2 = $neb->replicate_object("foo", "node04");
     210
     211    my $locations = $neb->find_instances("foo");
     212    my $Nloc = @$locations;
     213
     214    is($Nloc, 2, "found 2 instances");
     215   
     216    my $loc1 = $locations->[0];
     217    my $loc2 = $locations->[1];
     218
     219    like($loc1, qr/$nodedirs[0]/, "instance matches expected node");
     220    uri_scheme_ok($loc2, 'file');
     221}
     222
     223# replication to unavailable volume with hard_volume: should fail
     224Test::Nebulous->setup;
     225eval {
     226    my @nodedirs = Test::Nebulous->get_node_dirs();
     227
     228    # checking on replicate_object, does this logic make sense?
     229    my $uri1 = $neb->create_object("foo", "~node01");
     230    my $uri2 = $neb->replicate_object("foo", "~node04");
     231
     232    my $locations = $neb->find_instances("foo");
     233};
     234like($@, qr/is not available/, "replicate to unknown node with hard_volume should fail");
     235
     236### END hard_volume tests
     237
     238### location-aware tests (do we respect the cab_id / vol_id exclusions?)
     239
     240# here are the volume definitions (Test/Nebulous.pm):
     241# name   : vol_id : cab_id : site_id : xattr
     242# node01 :      1 :      1 :       1 :     0
     243# node02 :      2 :      2 :       1 :     0
     244# node03 :      3 :      3 :       2 :     0
     245# node04 :      4 :      1 :       1 :     0
     246# node05 :      5 :      1 :       1 :     0
     247# node06 :      6 :      1 :       1 :     0
     248# node07 :      7 :      1 :       1 :     0
     249# node08 :      8 :      4 :       2 :     0
     250
     251# replication without volume
     252Test::Nebulous->setup;
     253{
     254    my @nodedirs = Test::Nebulous->get_node_dirs();
     255
     256    # checking on replicate_object: hard_volume as node target
     257    my $uri1 = $neb->create_object("foo", "~node01");
     258    my $uri2 = $neb->replicate_object("foo");
     259
     260    my $locations = $neb->find_instances("foo");
     261    my $Nloc = @$locations;
     262
     263    is($Nloc, 2, "found 2 instances");
     264   
     265    my $loc1 = $locations->[0];
     266    my $loc2 = $locations->[1];
     267
     268    # if the volume is not explicitly specified, then the first copy
     269    # should go to a different volume, cabinet, and site
     270    # if first is one node01, replication should go to node03 or node08
     271    # since those both have different site_id values
     272    like($loc1, qr/$nodedirs[0]/, "instance matches expected node");
     273
     274    my $isnode03 = $loc2 =~ m/$nodedirs[2]/;
     275    my $isnode08 = $loc2 =~ m/$nodedirs[7]/;
     276    ok($isnode03 || $isnode08, "instance matches expected node");
     277}
     278
     279# replication without volume
     280Test::Nebulous->setup;
     281{
     282    my @nodedirs = Test::Nebulous->get_node_dirs();
     283
     284    # checking on replicate_object, does this logic make sense?
     285    my $uri1 = $neb->create_object("foo", "~node03");
     286    my $uri2 = $neb->replicate_object("foo");
     287
     288    my $locations = $neb->find_instances("foo");
     289    my $Nloc = @$locations;
     290
     291    is($Nloc, 2, "found 2 instances");
     292   
     293    my $loc1 = $locations->[0];
     294    my $loc2 = $locations->[1];
     295
     296    # if the volume is not explicitly specified, then the first copy
     297    # should go to a different volume, cabinet, and site
     298    # if first is one node03, replication should go to node01 or node02
     299    # since those both have different site_id values
     300    like($loc1, qr/$nodedirs[2]/, "instance matches expected node");
     301
     302    my $isnode01 = $loc2 =~ m/$nodedirs[0]/;
     303    my $isnode02 = $loc2 =~ m/$nodedirs[1]/;
     304    ok($isnode01 || $isnode02, "instance matches expected node");
     305}
     306
    149307Test::Nebulous->setup;
    150308
Note: See TracChangeset for help on using the changeset viewer.