IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40982


Ignore:
Timestamp:
Oct 28, 2019, 2:17:03 PM (7 years ago)
Author:
eugene
Message:

add a handful of tests for find_invalid and hard_volume; fix API tests (returned message has changed)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20191011/Nebulous-Server/t/08_server_find_instances.t

    r24362 r40982  
    88use warnings FATAL => qw( all );
    99
    10 use Test::More tests => 19;
     10use Test::More tests => 25;
    1111
    1212use lib qw( ./t ./lib );
     
    2222);
    2323
    24 Test::Nebulous->setup;
    25 
     24# object exists but instance is on a different volume
     25# "~node02" is meant to be a hard volume
     26
     27# XXX previously, the logic was: if we request a hard volume location
     28# using ~node, then we would give an error if no data is available except on that node.
     29
     30# the code has been modified so that the requested storage object is provided if possible,
     31# even if the apparently "hard" target did not exist.
     32
     33Test::Nebulous->setup;
     34Test::Nebulous->cleanup; # make sure the database is reset before running any tests
     35
     36Test::Nebulous->setup;
    2637{
    2738    # key
     
    3546
    3647Test::Nebulous->setup;
    37 
    3848{
    3949    # key
     
    4959
    5060Test::Nebulous->setup;
    51 
    5261{
    5362    # key, volume
     
    6170
    6271Test::Nebulous->setup;
    63 
    6472{
    6573    # key, volume
     
    7381
    7482Test::Nebulous->setup;
    75 
    7683{
    7784    # key, volume
     
    8592
    8693Test::Nebulous->setup;
    87 
    8894{
    8995    # key
     
    100106# object exists but instance is on a different volume
    101107Test::Nebulous->setup;
    102 
    103108eval {
    104109    # key, volume
    105110    my $uri = $neb->create_object('foo', '~node01');
    106 
    107111    my $locations = $neb->find_instances('foo', '~node02');
    108 };
    109 like($@, qr/no instances on storage volume/, 'instances on a different volume');
     112
     113    uri_scheme_ok($locations->[0], 'file');
     114    is($uri, $locations->[0], "URIs match");
     115
     116    # print "uri: $uri\n";
     117    # print "result: $locations->[0]\n";
     118};
     119# die "quick check";
     120# print "answer: $_[0]\n";
     121# like($@, qr/no instances on storage volume/, 'instances on a different volume');
     122
     123# request from a soft_volume for an instance which is on an invalid node (find_invalid = 1)
     124# XXX should return the INVALID instance (currently 2019.10.24 does not)
     125Test::Nebulous->setup;
     126eval {
     127    # key, volume
     128    my $uri = $neb->create_object('foo', '~node02');
     129    Test::Nebulous->switch_node_state;
     130
     131    my $locations = $neb->find_instances('foo', 'node02', 1);
     132    uri_scheme_ok($locations->[0], 'file');
     133    is($uri, $locations->[0], "URIs match");
     134};
     135is($@, "", "instance on invalid node (as hard_volume) returned with find_invalid is set");
     136#like($@, qr/database error/, "instance on invalid node (as hard_volume) not returned");
     137
     138# request from a soft_volume for an instance which is on an invalid node (find_invalid = 0)
     139# XXX should return the INVALID instance (currently 2019.10.24 does not)
     140Test::Nebulous->setup;
     141eval {
     142    # key, volume
     143    my $uri = $neb->create_object('foo', '~node02');
     144    Test::Nebulous->switch_node_state;
     145
     146    my $locations = $neb->find_instances('foo', 'node02', 0);
     147};
     148#is($@, "", "instance on invalid node (as hard_volume) returned with find_invalid is set");
     149like($@, qr/database error/, "instance on invalid node (as soft_volume) not returned");
     150
     151#### tests with a hard_volume:
     152
     153# request from a hard_volume for an instance which is on an invalid node (find_instance not supplied)
     154Test::Nebulous->setup;
     155eval {
     156    # key, volume
     157    my $uri = $neb->create_object('foo', '~node02');
     158    Test::Nebulous->switch_node_state;
     159
     160    my $locations = $neb->find_instances('foo', '~node02');
     161};
     162like($@, qr/no instances on storage volume/, "instance on invalid node (as hard_volume) not returned");
     163
     164# request from a hard_volume for an instance which is on an invalid node (find_invalid = 1)
     165Test::Nebulous->setup;
     166eval {
     167    # key, volume
     168    my $uri = $neb->create_object('foo', '~node02');
     169    Test::Nebulous->switch_node_state;
     170
     171    my $locations = $neb->find_instances('foo', '~node02', 1);
     172    uri_scheme_ok($locations->[0], 'file');
     173    is($uri, $locations->[0], "URIs match");
     174};
     175is($@, "", "instance on invalid node (as hard_volume) returned with find_invalid is set");
     176#like($@, qr/database error/, "instance on invalid node (as hard_volume) not returned");
     177
     178# request from a hard_volume for an instance which is on an invalid node (find_invalid = 0)
     179Test::Nebulous->setup;
     180eval {
     181    # key, volume
     182    my $uri = $neb->create_object('foo', '~node02');
     183    Test::Nebulous->switch_node_state;
     184
     185    my $locations = $neb->find_instances('foo', '~node02', 0);
     186};
     187like($@, qr/no instances on storage volume/, "instance on invalid node (as hard_volume) not returned");
     188
     189# request from a hard_volume for an instance which is on an invalid node
     190Test::Nebulous->setup;
     191eval {
     192    # key, volume
     193    my $uri = $neb->create_object('foo', '~node02');
     194    Test::Nebulous->switch_node_state;
     195
     196    my $locations = $neb->find_instances('foo', '~node02', 1);
     197
     198    uri_scheme_ok($locations->[0], 'file');
     199    is($uri, $locations->[0], "URIs match");
     200};
     201
     202# request from a hard_volume returns an instance which is not on the hard volume if available
     203Test::Nebulous->setup;
     204eval {
     205    # key, volume
     206    my $uri = $neb->create_object('foo', '~node01');
     207
     208    my $locations = $neb->find_instances('foo', '~node02');
     209
     210    uri_scheme_ok($locations->[0], 'file');
     211    is($uri, $locations->[0], "URIs match");
     212};
     213
     214########
    110215
    111216Test::Nebulous->setup;
     
    125230
    126231Test::Nebulous->setup;
    127 
    128 eval {
    129     $neb->find_instances();
    130 };
    131 like($@, qr/1 - 2 were expected/, "no params");
     232eval {
     233    my $locations = $neb->find_instances();
     234};
     235like($@, qr/1 - 3 were expected/, "no params");
     236# note the new API expects 1-3 parameters
    132237
    133238Test::Nebulous->setup;
     
    135240eval {
    136241    $neb->create_object('foo');
    137     $neb->find_instances('foo', 'node01', 3);
    138 };
    139 like($@, qr/1 - 2 were expected/, "too many params");
     242    $neb->find_instances('foo', 'node01', 3, 5);
     243};
     244like($@, qr/1 - 3 were expected/, "too many params");
     245# note the new API expects 1-3 parameters
    140246
    141247Test::Nebulous->cleanup;
Note: See TracChangeset for help on using the changeset viewer.