- Timestamp:
- Oct 28, 2019, 4:26:42 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20191011/Nebulous/t/56_client_find_instances.t
r19469 r40998 10 10 use Apache::Test qw( -withtestmore ); 11 11 12 plan tests => 29;12 plan tests => 35; 13 13 14 14 use lib qw( ./t ./lib ); … … 20 20 my $hostport = Apache::Test->config->{ 'hostport' }; 21 21 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 29 Test::Nebulous->setup; 30 Test::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) 97 Test::Nebulous->setup; 24 98 { 25 99 # key … … 36 110 } 37 111 38 Test::Nebulous->setup; 39 112 # find a both instances of a duplicated object 113 Test::Nebulous->setup; 40 114 { 41 115 # key … … 56 130 57 131 Test::Nebulous->setup; 58 59 132 { 60 133 # key, volume … … 103 176 } 104 177 105 Test::Nebulous->setup; 106 178 # find instance using hard_volume for wrong node 179 # (should still return a valid instance) 180 Test::Nebulous->setup; 107 181 { 108 182 # volume/key, volume override … … 114 188 my $locations = $neb->find_instances( "neb://node01/foo", "~node02" ); 115 189 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) 199 Test::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) 219 Test::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" ); 117 235 } 118 236 … … 153 271 154 272 Test::Nebulous->setup; 155 156 273 { 157 274 my $neb = Nebulous::Client->new( … … 171 288 $neb->find_instances(); 172 289 }; 173 like( $@, qr/1 - 2were expected/, "no params" );290 like( $@, qr/1 - 3 were expected/, "no params" ); 174 291 175 292 Test::Nebulous->setup; … … 180 297 ); 181 298 182 $neb->find_instances( "foo", 'read', 3 );299 $neb->find_instances( "foo", 'read', 3, 5 ); 183 300 }; 184 like( $@, qr/1 - 2were expected/, "too many params" );301 like( $@, qr/1 - 3 were expected/, "too many params" ); 185 302 186 303 Test::Nebulous->cleanup;
Note:
See TracChangeset
for help on using the changeset viewer.
