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

Location:
trunk/Nebulous-Server/t
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/t/03_server_setup.t

    r24546 r41172  
    1414use Nebulous::Server;
    1515use Test::Nebulous;
     16
     17Test::Nebulous->show_setup;
     18die "test";
    1619
    1720Test::Nebulous->setup;
  • trunk/Nebulous-Server/t/04_server_create_object.t

    r24356 r41172  
    3030
    3131Test::Nebulous->setup;
    32 
    3332{
    3433    # key
     
    4039    uri_scheme_ok($uri, 'file');
    4140
    42 SKIP: {
    43     skip "requires xattr support", 1 unless $test_xattr;
    44     is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr');
    45 }
    46 }
    47 
    48 Test::Nebulous->setup;
    49 
     41  SKIP: {
     42      skip "requires xattr support", 1 unless $test_xattr;
     43      is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr');
     44    }
     45}
     46
     47Test::Nebulous->setup;
    5048{
    5149    # key
     
    5755    uri_scheme_ok($uri, 'file');
    5856
    59 SKIP: {
    60     skip "requires xattr support", 1 unless $test_xattr;
    61     is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr');
    62 }
     57  SKIP: {
     58      skip "requires xattr support", 1 unless $test_xattr;
     59      is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr');
     60    }
    6361}
    6462
     
    528526    $neb->create_object("foo", '~node07');
    529527};
    530 like($@, qr/node07 is not available/, "request volume this is full");
     528like($@, qr/node07 is not available/, "request volume which is full");
    531529
    532530Test::Nebulous->setup;
     
    535533    $neb->create_object("neb://~node07/foo");
    536534};
    537 like($@, qr/node07 is not available/, "request volume this is full");
     535like($@, qr/node07 is not available/, "request volume which is full");
    538536
    539537Test::Nebulous->setup;
  • 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
  • trunk/Nebulous-Server/t/08_server_find_instances.t

    r24362 r41172  
    88use warnings FATAL => qw( all );
    99
    10 use Test::More tests => 19;
     10use Test::More tests => 44;
    1111
    1212use lib qw( ./t ./lib );
     
    2222);
    2323
    24 Test::Nebulous->setup;
    25 
     24# XXX previously, the logic was: if we request a hard volume location
     25# using ~node, then we would give an error if no data is available except on that node.
     26
     27# the code has been modified so that the requested storage object is provided if possible,
     28# even if the apparently "hard" target did not exist.
     29
     30Test::Nebulous->setup;
     31Test::Nebulous->cleanup; # make sure the database is reset before running any tests
     32
     33# for (my $i = 0; $i < $Nloc; $i++) {
     34#       my $loc = $locations->[$i];
     35#       print "location: $loc\n";
     36#}
     37
     38Test::Nebulous->setup;
    2639{
    2740    # key
     
    3548
    3649Test::Nebulous->setup;
    37 
    3850{
    3951    # key
     
    4961
    5062Test::Nebulous->setup;
    51 
    5263{
    5364    # key, volume
     
    6172
    6273Test::Nebulous->setup;
    63 
    6474{
    6575    # key, volume
     
    7383
    7484Test::Nebulous->setup;
    75 
    7685{
    7786    # key, volume
     
    8594
    8695Test::Nebulous->setup;
    87 
    8896{
    8997    # key
     
    98106}
    99107
    100 # object exists but instance is on a different volume
    101 Test::Nebulous->setup;
    102 
     108# request from a hard_volume returns an instance which is not on the hard volume if available
     109Test::Nebulous->setup;
    103110eval {
    104111    # key, volume
    105112    my $uri = $neb->create_object('foo', '~node01');
    106 
    107113    my $locations = $neb->find_instances('foo', '~node02');
    108 };
    109 like($@, qr/no instances on storage volume/, 'instances on a different volume');
     114
     115    uri_scheme_ok($locations->[0], 'file');
     116    is($uri, $locations->[0], "URIs match");
     117};
     118is($@, "", "instance on different node (as hard_volume) returned");
     119
     120# request from a hard_volume returns an instance which is not on the hard volume if available
     121Test::Nebulous->setup;
     122eval {
     123    # key, volume
     124    my $uri = $neb->create_object('foo', '~node01');
     125    my $locations = $neb->find_instances('foo', '~node02');
     126
     127    uri_scheme_ok($locations->[0], 'file');
     128    is($uri, $locations->[0], "URIs match");
     129};
     130is($@, "", "instance on different node (as hard_volume) returned");
     131
     132### TESTS FOR INSTANCE ON INVALID NODE
     133diag ("TESTS FOR INSTANCE ON INVALID NODE");
     134
     135# request from a soft_volume for an instance which is on an invalid node (find_invalid = 1) [SOFT, 1]
     136Test::Nebulous->setup;
     137eval {
     138    # key, volume
     139    my $uri = $neb->create_object('foo', '~node02');
     140    Test::Nebulous->switch_node_state;
     141
     142    my $locations = $neb->find_instances('foo', 'node02', 1);
     143    uri_scheme_ok($locations->[0], 'file');
     144    is($uri, $locations->[0], "URIs match");
     145};
     146is($@, "", "instance on invalid node (as soft_volume) returned with find_invalid = 1");
     147
     148# request from a soft_volume for an instance which is on an invalid node (find_invalid = 0) [SOFT, 0]
     149Test::Nebulous->setup;
     150eval {
     151    # key, volume
     152    my $uri = $neb->create_object('foo', '~node02');
     153    Test::Nebulous->switch_node_state;
     154
     155    my $locations = $neb->find_instances('foo', 'node02', 0);
     156};
     157like($@, qr/database error/, "instance on invalid node (as soft_volume) not returned (find_invalid = 0)");
     158
     159# request from a hard_volume for an instance which is on an invalid node (find_instance not supplied) [SOFT, X]
     160Test::Nebulous->setup;
     161eval {
     162    # key, volume
     163    my $uri = $neb->create_object('foo', '~node02');
     164    Test::Nebulous->switch_node_state;
     165
     166    my $locations = $neb->find_instances('foo', 'node02');
     167};
     168like($@, qr/no instances available for key/, "instance on invalid node (as soft_volume) not returned (find_invalid not set)");
     169
     170# request from a hard_volume for an instance which is on an invalid node (find_invalid = 1) [HARD, 1]
     171Test::Nebulous->setup;
     172eval {
     173    # key, volume
     174    my $uri = $neb->create_object('foo', '~node02');
     175    Test::Nebulous->switch_node_state;
     176
     177    my $locations = $neb->find_instances('foo', '~node02', 1);
     178    uri_scheme_ok($locations->[0], 'file');
     179    is($uri, $locations->[0], "URIs match");
     180};
     181is($@, "", "instance on invalid node (as hard_volume) returned with find_invalid = 1");
     182
     183# request from a hard_volume for an instance which is on an invalid node (find_invalid = 0) [HARD, 0]
     184Test::Nebulous->setup;
     185eval {
     186    # key, volume
     187    my $uri = $neb->create_object('foo', '~node02');
     188    Test::Nebulous->switch_node_state;
     189
     190    my $locations = $neb->find_instances('foo', '~node02', 0);
     191};
     192like($@, qr/no instances on storage volume/, "instance on invalid node (as hard_volume) not returned (find_invalid = 0)");
     193
     194# request from a hard_volume for an instance which is on an invalid node [HARD, X]
     195Test::Nebulous->setup;
     196eval {
     197    # key, volume
     198    my $uri = $neb->create_object('foo', '~node02');
     199    Test::Nebulous->switch_node_state;
     200
     201    my $locations = $neb->find_instances('foo', '~node02');
     202};
     203like($@, qr/no instances on storage volume/, "instance on invalid node (as hard_volume) not returned (find_invalid not set)");
     204
     205#### TESTING the instance proximity analysis
     206Test::Nebulous->setup;
     207{
     208    my @nodedirs = Test::Nebulous->get_node_dirs();
     209
     210    # place 4 instances on specific nodes (hard targets works):
     211    my $uri1 = $neb->create_object("foo", "~node01");
     212    my $uri2 = $neb->replicate_object("foo", "~node02");
     213    my $uri3 = $neb->replicate_object("foo", "~node03");
     214    my $uri4 = $neb->replicate_object("foo", "~node08");
     215
     216    my $locations = $neb->find_instances("foo", "node01");
     217    my $Nloc = @$locations;
     218
     219    is($Nloc, 4, "found 4 instances");
     220   
     221    my $loc1 = $locations->[0];
     222    my $loc2 = $locations->[1];
     223    my $loc3 = $locations->[2];
     224    my $loc4 = $locations->[3];
     225
     226    # choosing instance relative to node01 yields:
     227    like($loc1, qr/$nodedirs[0]/, "node01 is closest to node01");   
     228    like($loc2, qr/$nodedirs[1]/, "node02 is 2nd closest to node01");
     229    like($loc3, qr/$nodedirs[2]/, "node03 is 3rd closest to node01");
     230    like($loc4, qr/$nodedirs[7]/, "node08 is 4th closest to node01");
     231}
     232
     233#### TESTING the instance proximity analysis
     234Test::Nebulous->setup;
     235{
     236    my @nodedirs = Test::Nebulous->get_node_dirs();
     237
     238    # place 4 instances on specific nodes (hard targets works):
     239    my $uri1 = $neb->create_object("foo", "~node01");
     240    my $uri2 = $neb->replicate_object("foo", "~node02");
     241    my $uri3 = $neb->replicate_object("foo", "~node03");
     242    my $uri4 = $neb->replicate_object("foo", "~node08");
     243
     244    my $locations = $neb->find_instances("foo", "node03");
     245    my $Nloc = @$locations;
     246
     247    is($Nloc, 4, "found 4 instances");
     248   
     249    my $loc1 = $locations->[0]; #
     250    my $loc2 = $locations->[1]; #
     251    my $loc3 = $locations->[2]; #
     252    my $loc4 = $locations->[3]; #
     253
     254    # choosing instance relative to node01 yields:
     255    like($loc1, qr/$nodedirs[2]/, "node03 is closest to node03");
     256    like($loc2, qr/$nodedirs[7]/, "node08 is 2nd closest to node03");
     257    like($loc3, qr/$nodedirs[1]/, "node02 is 3rd closest to node03");
     258    like($loc4, qr/$nodedirs[0]/, "node08 is 4th closest to node03");
     259}
     260
     261########
    110262
    111263Test::Nebulous->setup;
     
    125277
    126278Test::Nebulous->setup;
    127 
    128 eval {
    129     $neb->find_instances();
    130 };
    131 like($@, qr/1 - 2 were expected/, "no params");
     279eval {
     280    my $locations = $neb->find_instances();
     281};
     282like($@, qr/1 - 3 were expected/, "no params");
     283# note the new API expects 1-3 parameters
    132284
    133285Test::Nebulous->setup;
     
    135287eval {
    136288    $neb->create_object('foo');
    137     $neb->find_instances('foo', 'node01', 3);
    138 };
    139 like($@, qr/1 - 2 were expected/, "too many params");
     289    $neb->find_instances('foo', 'node01', 3, 5);
     290};
     291like($@, qr/1 - 3 were expected/, "too many params");
     292# note the new API expects 1-3 parameters
    140293
    141294Test::Nebulous->cleanup;
  • trunk/Nebulous-Server/t/11_server_is_valid_volume_name.t

    r24356 r41172  
    88use warnings FATAL => qw( all );
    99
    10 use Test::More tests => 3;
     10use Test::More tests => 5;
    1111
    1212use lib qw( ./t ./lib );
     
    3131Test::Nebulous->setup;
    3232
    33 is($neb->_is_valid_volume_name('foo', 'node99'), undef, "invalid volume name");
     33is($neb->_is_valid_volume_name('foo', 'node99'), 0, "invalid volume name");
     34
     35Test::Nebulous->setup;
     36
     37# key does not need to exist (is hashed to select db server)
     38ok($neb->_is_valid_volume_name('bax', 'node01'), "valid volume name");
     39
     40Test::Nebulous->setup;
     41
     42# 'any' should always be a valid name
     43ok($neb->_is_valid_volume_name('foo', 'any'), "valid volume name");
    3444
    3545Test::Nebulous->cleanup;
  • trunk/Nebulous-Server/t/15_server_xattr.t

    r24356 r41172  
    184184    $neb->getxattr_object('foo', 'user.bar');
    185185};
    186 like($@, qr|xattr neb:///foo:user.bar does not exist|,
    187     "get xattr from non-existant xattr key");
     186like($@, qr|xattr neb:///foo:user.bar does not exist|, "get xattr from non-existant xattr key");
    188187
    189188Test::Nebulous->setup;
  • trunk/Nebulous-Server/t/16_mounts.t

    r24356 r41172  
    2828    my $mounts = $neb->mounts();
    2929
    30     is(scalar @$mounts, 7, "number of rows");
     30    is(scalar @$mounts, 8, "number of rows");
    3131
    3232    my %row;
     
    3535        = @{$mounts->[0]};
    3636   
    37     is($row{total},     100000000000);
    38     is($row{used},      100000000);
    39     is($row{vol_id},    1);
    40     is($row{name},      "node01");
    41     is($row{host},      "node01");
    42     is($row{allocate},  1);
    43     is($row{available}, 1);
    44     is($row{xattr},     0);
     37    is($row{total},     100000000000, "total bytes");
     38    is($row{used},      100000000, "used bytes");
     39    is($row{vol_id},    1, "vol id");
     40    is($row{name},      "node01", "name");
     41    is($row{host},      "node01", "host");
     42    is($row{allocate},  1, "is allocated");
     43    is($row{available}, 1, "is available");
     44    is($row{xattr},     0, "has no xattr");
    4545
    4646    # 2nd row
     
    4848        = @{$mounts->[1]};
    4949
    50     is($row{total},     100000000000);
    51     is($row{used},      1000000000);
    52     is($row{vol_id},    2);
    53     is($row{name},      "node02");
    54     is($row{host},      "node02");
    55     is($row{allocate},  1);
    56     is($row{available}, 1);
    57     is($row{xattr},     0);
     50    is($row{total},     100000000000, "total bytes");
     51    is($row{used},      1000000000, "used bytes");
     52    is($row{vol_id},    2, "vol id");
     53    is($row{name},      "node02", "name");
     54    is($row{host},      "node02", "host");
     55    is($row{allocate},  1, "is allocated");
     56    is($row{available}, 1, "is available");
     57    is($row{xattr},     0, "has no xattr");
    5858}
    5959
  • trunk/Nebulous-Server/t/18_server_chmod_object.t

    r24356 r41172  
    3838    is($mode, 0440, "returned mode");
    3939    is($neb->getxattr_object($key, 'user.mode'), 0440, "xattr user.mode");
     40
     41    # reset to 600 so the user can delete the file and /tmp entry
     42    chmod(0600, $path);
    4043}
    4144
     
    5053    my $mode = $neb->chmod_object($key, 0440);
    5154
    52     my $st1 = stat(URI->new($uri1)->path);
    53     my $st2 = stat(URI->new($uri2)->path);
     55    my $path1 = URI->new($uri1)->path;
     56    my $path2 = URI->new($uri2)->path;
     57
     58    my $st1 = stat($path1);
     59    my $st2 = stat($path2);
    5460
    5561    is($st1->mode &07777, 0440, "chmod() first instance");
     
    5763    is($mode, 0440, "returned mode");
    5864    is($neb->getxattr_object($key, 'user.mode'), 0440, "xattr user.mode");
     65
     66    # reset to 600 so the user can delete the file and /tmp entry
     67    chmod (0600, $path1);
     68    chmod (0600, $path2);
    5969}
    6070
Note: See TracChangeset for help on using the changeset viewer.