Changeset 41019 for branches/eam_branches/ipp-20191011
- Timestamp:
- Oct 31, 2019, 12:02:31 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20191011/Nebulous-Server/t/08_server_find_instances.t
r40984 r41019 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 25;10 use Test::More tests => 44; 11 11 12 12 use lib qw( ./t ./lib ); … … 31 31 Test::Nebulous->cleanup; # make sure the database is reset before running any tests 32 32 33 # for (my $i = 0; $i < $Nloc; $i++) { 34 # my $loc = $locations->[$i]; 35 # print "location: $loc\n"; 36 #} 37 33 38 Test::Nebulous->setup; 34 39 { … … 101 106 } 102 107 103 # object exists but instance is on a different volume108 # request from a hard_volume returns an instance which is not on the hard volume if available 104 109 Test::Nebulous->setup; 105 110 eval { … … 110 115 uri_scheme_ok($locations->[0], 'file'); 111 116 is($uri, $locations->[0], "URIs match"); 112 113 # print "uri: $uri\n"; 114 # print "result: $locations->[0]\n"; 115 }; 116 # die "quick check"; 117 # print "answer: $_[0]\n"; 118 # like($@, qr/no instances on storage volume/, 'instances on a different volume'); 119 120 # request from a soft_volume for an instance which is on an invalid node (find_invalid = 1) 121 # XXX should return the INVALID instance (currently 2019.10.24 does not) 117 }; 118 is($@, "", "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 121 Test::Nebulous->setup; 122 eval { 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 }; 130 is($@, "", "instance on different node (as hard_volume) returned"); 131 132 ### TESTS FOR INSTANCE ON INVALID NODE 133 diag ("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] 122 136 Test::Nebulous->setup; 123 137 eval { … … 130 144 is($uri, $locations->[0], "URIs match"); 131 145 }; 132 is($@, "", "instance on invalid node (as hard_volume) returned with find_invalid is set"); 133 #like($@, qr/database error/, "instance on invalid node (as hard_volume) not returned"); 134 135 # request from a soft_volume for an instance which is on an invalid node (find_invalid = 0) 136 # XXX should return the INVALID instance (currently 2019.10.24 does not) 146 is($@, "", "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] 137 149 Test::Nebulous->setup; 138 150 eval { … … 143 155 my $locations = $neb->find_instances('foo', 'node02', 0); 144 156 }; 145 #is($@, "", "instance on invalid node (as hard_volume) returned with find_invalid is set"); 146 like($@, qr/database error/, "instance on invalid node (as soft_volume) not returned"); 147 148 #### tests with a hard_volume: 149 150 # request from a hard_volume for an instance which is on an invalid node (find_instance not supplied) 157 like($@, 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] 160 Test::Nebulous->setup; 161 eval { 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 }; 168 like($@, 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] 171 Test::Nebulous->setup; 172 eval { 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 }; 181 is($@, "", "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] 184 Test::Nebulous->setup; 185 eval { 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 }; 192 like($@, 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] 151 195 Test::Nebulous->setup; 152 196 eval { … … 157 201 my $locations = $neb->find_instances('foo', '~node02'); 158 202 }; 159 like($@, qr/no instances on storage volume/, "instance on invalid node (as hard_volume) not returned"); 160 161 # request from a hard_volume for an instance which is on an invalid node (find_invalid = 1) 162 Test::Nebulous->setup; 163 eval { 164 # key, volume 165 my $uri = $neb->create_object('foo', '~node02'); 166 Test::Nebulous->switch_node_state; 167 168 my $locations = $neb->find_instances('foo', '~node02', 1); 169 uri_scheme_ok($locations->[0], 'file'); 170 is($uri, $locations->[0], "URIs match"); 171 }; 172 is($@, "", "instance on invalid node (as hard_volume) returned with find_invalid is set"); 173 #like($@, qr/database error/, "instance on invalid node (as hard_volume) not returned"); 174 175 # request from a hard_volume for an instance which is on an invalid node (find_invalid = 0) 176 Test::Nebulous->setup; 177 eval { 178 # key, volume 179 my $uri = $neb->create_object('foo', '~node02'); 180 Test::Nebulous->switch_node_state; 181 182 my $locations = $neb->find_instances('foo', '~node02', 0); 183 }; 184 like($@, qr/no instances on storage volume/, "instance on invalid node (as hard_volume) not returned"); 185 186 # request from a hard_volume for an instance which is on an invalid node 187 Test::Nebulous->setup; 188 eval { 189 # key, volume 190 my $uri = $neb->create_object('foo', '~node02'); 191 Test::Nebulous->switch_node_state; 192 193 my $locations = $neb->find_instances('foo', '~node02', 1); 194 195 uri_scheme_ok($locations->[0], 'file'); 196 is($uri, $locations->[0], "URIs match"); 197 }; 198 199 # request from a hard_volume returns an instance which is not on the hard volume if available 200 Test::Nebulous->setup; 201 eval { 202 # key, volume 203 my $uri = $neb->create_object('foo', '~node01'); 204 205 my $locations = $neb->find_instances('foo', '~node02'); 206 207 uri_scheme_ok($locations->[0], 'file'); 208 is($uri, $locations->[0], "URIs match"); 209 }; 203 like($@, 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 206 Test::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 234 Test::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 } 210 260 211 261 ########
Note:
See TracChangeset
for help on using the changeset viewer.
