Changeset 41172 for trunk/Nebulous-Server/t/05_server_replicate_object.t
- Timestamp:
- Nov 27, 2019, 12:04:14 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/t/05_server_replicate_object.t
r24995 r41172 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 25;10 use Test::More tests => 43; 11 11 12 12 use lib qw( ./t ./lib ); … … 28 28 29 29 Test::Nebulous->setup; 30 31 30 { 32 31 # key … … 45 44 46 45 Test::Nebulous->setup; 47 48 46 { 49 47 # key, $volume … … 62 60 63 61 Test::Nebulous->setup; 64 65 62 { 66 63 # key, $volume is undef … … 79 76 80 77 Test::Nebulous->setup; 81 82 78 { 83 79 # key, $volume … … 147 143 } 148 144 145 # hard_volume tests: 146 147 # replication with hard_volume: 148 Test::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 169 Test::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 190 Test::Nebulous->setup; 191 eval { 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 }; 200 like($@, qr/is not a valid volume name/, "replicate to unknown node with hard_volume should fail"); 201 202 # replication to unavailable volume: should succeed 203 Test::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 224 Test::Nebulous->setup; 225 eval { 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 }; 234 like($@, 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 252 Test::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 280 Test::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 149 307 Test::Nebulous->setup; 150 308
Note:
See TracChangeset
for help on using the changeset viewer.
