8 plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_replicated')
9 unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_replicated');
14 use List::Util 'first';
15 use Scalar::Util 'reftype';
20 note "Using Moose version $Moose::VERSION and MooseX::Types version $MooseX::Types::VERSION";
25 my $var_dir = quotemeta ( File::Spec->catdir(qw/t var/) );
27 use_ok 'DBIx::Class::Storage::DBI::Replicated::Pool';
28 use_ok 'DBIx::Class::Storage::DBI::Replicated::Balancer';
29 use_ok 'DBIx::Class::Storage::DBI::Replicated::Replicant';
30 use_ok 'DBIx::Class::Storage::DBI::Replicated';
35 This is a test of the replicated storage system. This will work in one of
36 two ways, either it was try to fake replication with a couple of SQLite DBs
37 and creative use of copy, or if you define a couple of %ENV vars correctly
38 will try to test those. If you do that, it will assume the setup is properly
39 replicating. Your results may vary, but I have demonstrated this to work with
40 mysql native replication.
45 ## ----------------------------------------------------------------------------
46 ## Build a class to hold all our required testing data and methods.
47 ## ----------------------------------------------------------------------------
51 ## --------------------------------------------------------------------- ##
52 ## Create an object to contain your replicated stuff.
53 ## --------------------------------------------------------------------- ##
55 package DBIx::Class::DBI::Replicated::TestReplication;
58 use base qw/Class::Accessor::Fast/;
60 __PACKAGE__->mk_accessors( qw/schema/ );
62 ## Initialize the object
65 my ($class, $schema_method) = (shift, shift);
66 my $self = $class->SUPER::new(@_);
68 $self->schema( $self->init_schema($schema_method) );
72 ## Get the Schema and set the replication storage type
75 # current SQLT SQLite producer does not handle DROP TABLE IF EXISTS, trap warnings here
76 local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /no such table.+DROP TABLE/s };
78 my ($class, $schema_method) = @_;
80 my $method = "get_schema_$schema_method";
81 my $schema = $class->$method;
86 sub get_schema_by_storage_type {
87 DBICTest->init_schema(
90 '::DBI::Replicated' => {
91 balancer_type=>'::Random',
93 auto_validate_every=>100,
94 master_read_weight => 1
104 sub get_schema_by_connect_info {
105 DBICTest->init_schema(
106 sqlite_use_file => 1,
107 storage_type=> '::DBI::Replicated',
108 balancer_type=>'::Random',
110 auto_validate_every=>100,
111 master_read_weight => 1
122 sub generate_replicant_connect_info {}
126 ## --------------------------------------------------------------------- ##
127 ## Add a connect_info option to test option merging.
128 ## --------------------------------------------------------------------- ##
130 package DBIx::Class::Storage::DBI::Replicated;
134 __PACKAGE__->meta->make_mutable;
136 around connect_info => sub {
137 my ($next, $self, $info) = @_;
138 $info->[3]{master_option} = 1;
142 __PACKAGE__->meta->make_immutable;
147 ## --------------------------------------------------------------------- ##
148 ## Subclass for when you are using SQLite for testing, this provides a fake
149 ## replication support.
150 ## --------------------------------------------------------------------- ##
152 package DBIx::Class::DBI::Replicated::TestReplication::SQLite;
156 use base 'DBIx::Class::DBI::Replicated::TestReplication';
158 __PACKAGE__->mk_accessors(qw/master_path slave_paths/);
160 ## Set the master path from DBICTest
163 my $class = shift @_;
164 my $self = $class->SUPER::new(@_);
166 $self->master_path( DBICTest->_sqlite_dbfilename );
168 File::Spec->catfile(qw/t var DBIxClass_slave1.db/),
169 File::Spec->catfile(qw/t var DBIxClass_slave2.db/),
175 ## Return an Array of ArrayRefs where each ArrayRef is suitable to use for
176 ## $storage->connect_info to be used for connecting replicants.
178 sub generate_replicant_connect_info {
182 } @{$self->slave_paths};
184 my @connect_infos = map { [$_,'','',{AutoCommit=>1}] } @dsn;
186 ## Make sure nothing is left over from a failed test
190 my $c = $connect_infos[0];
191 $connect_infos[0] = {
201 ## Do a 'good enough' replication by copying the master dbfile over each of
202 ## the slave dbfiles. If the master is SQLite we do this, otherwise we
203 ## just do a one second pause to let the slaves catch up.
207 foreach my $slave (@{$self->slave_paths}) {
208 copy($self->master_path, $slave);
212 ## Cleanup after ourselves. Unlink all gthe slave paths.
216 foreach my $slave (@{$self->slave_paths}) {
223 ## --------------------------------------------------------------------- ##
224 ## Subclass for when you are setting the databases via custom export vars
225 ## This is for when you have a replicating database setup that you are
226 ## going to test against. You'll need to define the correct $ENV and have
227 ## two slave databases to test against, as well as a replication system
228 ## that will replicate in less than 1 second.
229 ## --------------------------------------------------------------------- ##
231 package DBIx::Class::DBI::Replicated::TestReplication::Custom;
232 use base 'DBIx::Class::DBI::Replicated::TestReplication';
234 ## Return an Array of ArrayRefs where each ArrayRef is suitable to use for
235 ## $storage->connect_info to be used for connecting replicants.
237 sub generate_replicant_connect_info {
239 [$ENV{"DBICTEST_SLAVE0_DSN"}, $ENV{"DBICTEST_SLAVE0_DBUSER"}, $ENV{"DBICTEST_SLAVE0_DBPASS"}, {AutoCommit => 1}],
240 [$ENV{"DBICTEST_SLAVE1_DSN"}, $ENV{"DBICTEST_SLAVE1_DBUSER"}, $ENV{"DBICTEST_SLAVE1_DBPASS"}, {AutoCommit => 1}],
244 ## pause a bit to let the replication catch up
251 ## ----------------------------------------------------------------------------
252 ## Create an object and run some tests
253 ## ----------------------------------------------------------------------------
255 ## Thi first bunch of tests are basic, just make sure all the bits are behaving
257 my $replicated_class = DBICTest->has_custom_dsn ?
258 'DBIx::Class::DBI::Replicated::TestReplication::Custom' :
259 'DBIx::Class::DBI::Replicated::TestReplication::SQLite';
263 for my $method (qw/by_connect_info by_storage_type/) {
265 ok $replicated = $replicated_class->new($method)
266 => "Created a replication object $method";
268 isa_ok $replicated->schema
269 => 'DBIx::Class::Schema';
271 isa_ok $replicated->schema->storage
272 => 'DBIx::Class::Storage::DBI::Replicated';
274 isa_ok $replicated->schema->storage->balancer
275 => 'DBIx::Class::Storage::DBI::Replicated::Balancer::Random'
276 => 'configured balancer_type';
279 ### check that all Storage::DBI methods are handled by ::Replicated
281 my @storage_dbi_methods = Class::MOP::Class
282 ->initialize('DBIx::Class::Storage::DBI')->get_all_method_names;
284 my @replicated_methods = DBIx::Class::Storage::DBI::Replicated->meta
285 ->get_all_method_names;
287 # remove constants and OTHER_CRAP
288 @storage_dbi_methods = grep !/^[A-Z_]+\z/, @storage_dbi_methods;
290 # remove CAG accessors
291 @storage_dbi_methods = grep !/_accessor\z/, @storage_dbi_methods;
293 # remove DBIx::Class (the root parent, with CAG and stuff) methods
294 my @root_methods = Class::MOP::Class->initialize('DBIx::Class')
295 ->get_all_method_names;
297 $count{$_}++ for (@storage_dbi_methods, @root_methods);
299 @storage_dbi_methods = grep $count{$_} != 2, @storage_dbi_methods;
302 my %storage_dbi_methods;
303 @storage_dbi_methods{@storage_dbi_methods} = ();
304 my %replicated_methods;
305 @replicated_methods{@replicated_methods} = ();
307 # remove ::Replicated-specific methods
308 for my $method (@replicated_methods) {
309 delete $replicated_methods{$method}
310 unless exists $storage_dbi_methods{$method};
312 @replicated_methods = keys %replicated_methods;
314 # check that what's left is implemented
316 $count{$_}++ for (@storage_dbi_methods, @replicated_methods);
318 if ((grep $count{$_} == 2, @storage_dbi_methods) == @storage_dbi_methods) {
319 pass 'all DBIx::Class::Storage::DBI methods implemented';
322 my @unimplemented = grep $count{$_} == 1, @storage_dbi_methods;
324 fail 'the following DBIx::Class::Storage::DBI methods are unimplemented: '
329 ok $replicated->schema->storage->meta
330 => 'has a meta object';
332 isa_ok $replicated->schema->storage->master
333 => 'DBIx::Class::Storage::DBI';
335 isa_ok $replicated->schema->storage->pool
336 => 'DBIx::Class::Storage::DBI::Replicated::Pool';
338 does_ok $replicated->schema->storage->balancer
339 => 'DBIx::Class::Storage::DBI::Replicated::Balancer';
341 ok my @replicant_connects = $replicated->generate_replicant_connect_info
342 => 'got replication connect information';
344 ok my @replicated_storages = $replicated->schema->storage->connect_replicants(@replicant_connects)
345 => 'Created some storages suitable for replicants';
348 $replicated->schema->storage->debug(1);
349 $replicated->schema->storage->debugcb(sub {
350 my ($op, $info) = @_;
351 ##warn "\n$op, $info\n";
355 dsn => ($info=~m/\[(.+)\]/)[0],
356 storage_type => $info=~m/REPLICANT/ ? 'REPLICANT' : 'MASTER',
360 ok my @all_storages = $replicated->schema->storage->all_storages
363 is scalar @all_storages,
365 => 'correct number of ->all_storages';
367 is ((grep $_->isa('DBIx::Class::Storage::DBI'), @all_storages),
369 => '->all_storages are correct type');
371 my @all_storage_opts =
372 grep { (reftype($_)||'') eq 'HASH' }
373 map @{ $_->_connect_info }, @all_storages;
375 is ((grep $_->{master_option}, @all_storage_opts),
377 => 'connect_info was merged from master to replicants');
379 my @replicant_names = keys %{ $replicated->schema->storage->replicants };
381 ok @replicant_names, "found replicant names @replicant_names";
383 ## Silence warning about not supporting the is_replicating method if using the
385 $replicated->schema->storage->debugobj->silence(1)
386 if first { $_ =~ /$var_dir/ } @replicant_names;
388 isa_ok $replicated->schema->storage->balancer->current_replicant
389 => 'DBIx::Class::Storage::DBI';
391 $replicated->schema->storage->debugobj->silence(0);
393 ok $replicated->schema->storage->pool->has_replicants
394 => 'does have replicants';
396 is $replicated->schema->storage->pool->num_replicants => 2
397 => 'has two replicants';
399 does_ok $replicated_storages[0]
400 => 'DBIx::Class::Storage::DBI::Replicated::Replicant';
402 does_ok $replicated_storages[1]
403 => 'DBIx::Class::Storage::DBI::Replicated::Replicant';
405 does_ok $replicated->schema->storage->replicants->{$replicant_names[0]}
406 => 'DBIx::Class::Storage::DBI::Replicated::Replicant';
408 does_ok $replicated->schema->storage->replicants->{$replicant_names[1]}
409 => 'DBIx::Class::Storage::DBI::Replicated::Replicant';
411 ## Add some info to the database
415 ->populate('Artist', [
416 [ qw/artistid name/ ],
417 [ 4, "Ozric Tentacles"],
420 is $debug{storage_type}, 'MASTER',
421 "got last query from a master: $debug{dsn}";
423 like $debug{info}, qr/INSERT/, 'Last was an insert';
425 ## Make sure all the slaves have the table definitions
427 $replicated->replicate;
428 $replicated->schema->storage->replicants->{$replicant_names[0]}->active(1);
429 $replicated->schema->storage->replicants->{$replicant_names[1]}->active(1);
431 ## Silence warning about not supporting the is_replicating method if using the
433 $replicated->schema->storage->debugobj->silence(1)
434 if first { $_ =~ /$var_dir/ } @replicant_names;
436 $replicated->schema->storage->pool->validate_replicants;
438 $replicated->schema->storage->debugobj->silence(0);
440 ## Make sure we can read the data.
442 ok my $artist1 = $replicated->schema->resultset('Artist')->find(4)
445 ## We removed testing here since master read weight is on, so we can't tell in
446 ## advance what storage to expect. We turn master read weight off a bit lower
447 ## is $debug{storage_type}, 'REPLICANT'
448 ## => "got last query from a replicant: $debug{dsn}, $debug{info}";
451 => 'DBICTest::Artist';
453 is $artist1->name, 'Ozric Tentacles'
454 => 'Found expected name for first result';
456 ## Check that master_read_weight is honored
458 no warnings qw/once redefine/;
461 *DBIx::Class::Storage::DBI::Replicated::Balancer::Random::_random_number =
464 $replicated->schema->storage->balancer->increment_storage;
466 is $replicated->schema->storage->balancer->current_replicant,
467 $replicated->schema->storage->master
468 => 'master_read_weight is honored';
470 ## turn it off for the duration of the test
471 $replicated->schema->storage->balancer->master_read_weight(0);
472 $replicated->schema->storage->balancer->increment_storage;
475 ## Add some new rows that only the master will have This is because
476 ## we overload any type of write operation so that is must hit the master
481 ->populate('Artist', [
482 [ qw/artistid name/ ],
483 [ 5, "Doom's Children"],
484 [ 6, "Dead On Arrival"],
488 is $debug{storage_type}, 'MASTER',
489 "got last query from a master: $debug{dsn}";
491 like $debug{info}, qr/INSERT/, 'Last was an insert';
493 ## Make sure all the slaves have the table definitions
494 $replicated->replicate;
496 ## Should find some data now
498 ok my $artist2 = $replicated->schema->resultset('Artist')->find(5)
501 is $debug{storage_type}, 'REPLICANT'
502 => "got last query from a replicant: $debug{dsn}";
505 => 'DBICTest::Artist';
507 is $artist2->name, "Doom's Children"
508 => 'Found expected name for first result';
510 ## What happens when we disconnect all the replicants?
512 is $replicated->schema->storage->pool->connected_replicants => 2
513 => "both replicants are connected";
515 $replicated->schema->storage->replicants->{$replicant_names[0]}->disconnect;
516 $replicated->schema->storage->replicants->{$replicant_names[1]}->disconnect;
518 is $replicated->schema->storage->pool->connected_replicants => 0
519 => "both replicants are now disconnected";
521 ## All these should pass, since the database should automatically reconnect
523 ok my $artist3 = $replicated->schema->resultset('Artist')->find(6)
524 => 'Still finding stuff.';
526 is $debug{storage_type}, 'REPLICANT'
527 => "got last query from a replicant: $debug{dsn}";
530 => 'DBICTest::Artist';
532 is $artist3->name, "Dead On Arrival"
533 => 'Found expected name for first result';
535 is $replicated->schema->storage->pool->connected_replicants => 1
536 => "At Least One replicant reconnected to handle the job";
538 ## What happens when we try to select something that doesn't exist?
540 ok ! $replicated->schema->resultset('Artist')->find(666)
541 => 'Correctly failed to find something.';
543 is $debug{storage_type}, 'REPLICANT'
544 => "got last query from a replicant: $debug{dsn}";
546 ## test the reliable option
550 $replicated->schema->storage->set_reliable_storage;
552 ok $replicated->schema->resultset('Artist')->find(2)
553 => 'Read from master 1';
555 is $debug{storage_type}, 'MASTER',
556 "got last query from a master: $debug{dsn}";
558 ok $replicated->schema->resultset('Artist')->find(5)
559 => 'Read from master 2';
561 is $debug{storage_type}, 'MASTER',
562 "got last query from a master: $debug{dsn}";
564 $replicated->schema->storage->set_balanced_storage;
566 ok $replicated->schema->resultset('Artist')->find(3)
567 => 'Read from replicant';
569 is $debug{storage_type}, 'REPLICANT',
570 "got last query from a replicant: $debug{dsn}";
573 ## Make sure when reliable goes out of scope, we are using replicants again
575 ok $replicated->schema->resultset('Artist')->find(1)
576 => 'back to replicant 1.';
578 is $debug{storage_type}, 'REPLICANT',
579 "got last query from a replicant: $debug{dsn}";
581 ok $replicated->schema->resultset('Artist')->find(2)
582 => 'back to replicant 2.';
584 is $debug{storage_type}, 'REPLICANT',
585 "got last query from a replicant: $debug{dsn}";
587 ## set all the replicants to inactive, and make sure the balancer falls back to
590 $replicated->schema->storage->replicants->{$replicant_names[0]}->active(0);
591 $replicated->schema->storage->replicants->{$replicant_names[1]}->active(0);
594 ## catch the fallback to master warning
595 open my $debugfh, '>', \my $fallback_warning;
596 my $oldfh = $replicated->schema->storage->debugfh;
597 $replicated->schema->storage->debugfh($debugfh);
599 ok $replicated->schema->resultset('Artist')->find(2)
600 => 'Fallback to master';
602 is $debug{storage_type}, 'MASTER',
603 "got last query from a master: $debug{dsn}";
605 like $fallback_warning, qr/falling back to master/
606 => 'emits falling back to master warning';
608 $replicated->schema->storage->debugfh($oldfh);
611 $replicated->schema->storage->replicants->{$replicant_names[0]}->active(1);
612 $replicated->schema->storage->replicants->{$replicant_names[1]}->active(1);
614 ## Silence warning about not supporting the is_replicating method if using the
616 $replicated->schema->storage->debugobj->silence(1)
617 if first { $_ =~ /$var_dir/ } @replicant_names;
619 $replicated->schema->storage->pool->validate_replicants;
621 $replicated->schema->storage->debugobj->silence(0);
623 ok $replicated->schema->resultset('Artist')->find(2)
624 => 'Returned to replicates';
626 is $debug{storage_type}, 'REPLICANT',
627 "got last query from a replicant: $debug{dsn}";
629 ## Getting slave status tests
632 ## We skip this tests unless you have a custom replicants, since the default
633 ## sqlite based replication tests don't support these functions.
635 skip 'Cannot Test Replicant Status on Non Replicating Database', 10
636 unless DBICTest->has_custom_dsn && $ENV{"DBICTEST_SLAVE0_DSN"};
638 $replicated->replicate; ## Give the slaves a chance to catchup.
640 ok $replicated->schema->storage->replicants->{$replicant_names[0]}->is_replicating
641 => 'Replicants are replicating';
643 is $replicated->schema->storage->replicants->{$replicant_names[0]}->lag_behind_master, 0
644 => 'Replicant is zero seconds behind master';
646 ## Test the validate replicants
648 $replicated->schema->storage->pool->validate_replicants;
650 is $replicated->schema->storage->pool->active_replicants, 2
651 => 'Still have 2 replicants after validation';
653 ## Force the replicants to fail the validate test by required their lag to
654 ## be negative (ie ahead of the master!)
656 $replicated->schema->storage->pool->maximum_lag(-10);
657 $replicated->schema->storage->pool->validate_replicants;
659 is $replicated->schema->storage->pool->active_replicants, 0
660 => 'No way a replicant be be ahead of the master';
662 ## Let's be fair to the replicants again. Let them lag up to 5
664 $replicated->schema->storage->pool->maximum_lag(5);
665 $replicated->schema->storage->pool->validate_replicants;
667 is $replicated->schema->storage->pool->active_replicants, 2
668 => 'Both replicants in good standing again';
670 ## Check auto validate
672 is $replicated->schema->storage->balancer->auto_validate_every, 100
673 => "Got the expected value for auto validate";
675 ## This will make sure we auto validatge everytime
676 $replicated->schema->storage->balancer->auto_validate_every(0);
678 ## set all the replicants to inactive, and make sure the balancer falls back to
681 $replicated->schema->storage->replicants->{$replicant_names[0]}->active(0);
682 $replicated->schema->storage->replicants->{$replicant_names[1]}->active(0);
684 ## Ok, now when we go to run a query, autovalidate SHOULD reconnect
686 is $replicated->schema->storage->pool->active_replicants => 0
687 => "both replicants turned off";
689 ok $replicated->schema->resultset('Artist')->find(5)
690 => 'replicant reactivated';
692 is $debug{storage_type}, 'REPLICANT',
693 "got last query from a replicant: $debug{dsn}";
695 is $replicated->schema->storage->pool->active_replicants => 2
696 => "both replicants reactivated";
699 ## Test the reliably callback
701 ok my $reliably = sub {
703 ok $replicated->schema->resultset('Artist')->find(5)
704 => 'replicant reactivated';
706 is $debug{storage_type}, 'MASTER',
707 "got last query from a master: $debug{dsn}";
709 } => 'created coderef properly';
711 $replicated->schema->storage->execute_reliably($reliably);
713 ## Try something with an error
715 ok my $unreliably = sub {
717 ok $replicated->schema->resultset('ArtistXX')->find(5)
718 => 'replicant reactivated';
720 } => 'created coderef properly';
722 throws_ok {$replicated->schema->storage->execute_reliably($unreliably)}
723 qr/Can't find source for ArtistXX/
724 => 'Bad coderef throws proper error';
726 ## Make sure replication came back
728 ok $replicated->schema->resultset('Artist')->find(3)
729 => 'replicant reactivated';
731 is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{dsn}";
733 ## make sure transactions are set to execute_reliably
735 ok my $transaction = sub {
741 ->populate('Artist', [
742 [ qw/artistid name/ ],
743 [ $id, "Children of the Grave $id"],
746 ok my $result = $replicated->schema->resultset('Artist')->find($id)
747 => "Found expected artist for $id";
749 is $debug{storage_type}, 'MASTER',
750 "got last query from a master: $debug{dsn}";
752 ok my $more = $replicated->schema->resultset('Artist')->find(1)
753 => 'Found expected artist again for 1';
755 is $debug{storage_type}, 'MASTER',
756 "got last query from a master: $debug{dsn}";
758 return ($result, $more);
760 } => 'Created a coderef properly';
762 ## Test the transaction with multi return
764 ok my @return = $replicated->schema->txn_do($transaction, 666)
765 => 'did transaction';
767 is $return[0]->id, 666
768 => 'first returned value is correct';
770 is $debug{storage_type}, 'MASTER',
771 "got last query from a master: $debug{dsn}";
774 => 'second returned value is correct';
776 is $debug{storage_type}, 'MASTER',
777 "got last query from a master: $debug{dsn}";
781 ## Test that asking for single return works
783 ok my @return = $replicated->schema->txn_do($transaction, 777)
784 => 'did transaction';
786 is $return[0]->id, 777
787 => 'first returned value is correct';
790 => 'second returned value is correct';
793 ## Test transaction returning a single value
796 ok my $result = $replicated->schema->txn_do(sub {
797 ok my $more = $replicated->schema->resultset('Artist')->find(1)
798 => 'found inside a transaction';
799 is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
801 }) => 'successfully processed transaction';
804 => 'Got expected single result from transaction';
807 ## Make sure replication came back
809 ok $replicated->schema->resultset('Artist')->find(1)
810 => 'replicant reactivated';
812 is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{dsn}";
814 ## Test Discard changes
817 ok my $artist = $replicated->schema->resultset('Artist')->find(2)
818 => 'got an artist to test discard changes';
820 is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{dsn}";
822 ok $artist->get_from_storage({force_pool=>'master'})
823 => 'properly discard changes';
825 is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
827 ok $artist->discard_changes({force_pool=>'master'})
828 => 'properly called discard_changes against master (manual attrs)';
830 is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
832 ok $artist->discard_changes()
833 => 'properly called discard_changes against master (default attrs)';
835 is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
837 ok $artist->discard_changes({force_pool=>$replicant_names[0]})
838 => 'properly able to override the default attributes';
840 is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{dsn}"
843 ## Test some edge cases, like trying to do a transaction inside a transaction, etc
846 ok my $result = $replicated->schema->txn_do(sub {
847 return $replicated->schema->txn_do(sub {
848 ok my $more = $replicated->schema->resultset('Artist')->find(1)
849 => 'found inside a transaction inside a transaction';
850 is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
853 }) => 'successfully processed transaction';
856 => 'Got expected single result from transaction';
860 ok my $result = $replicated->schema->txn_do(sub {
861 return $replicated->schema->storage->execute_reliably(sub {
862 return $replicated->schema->txn_do(sub {
863 return $replicated->schema->storage->execute_reliably(sub {
864 ok my $more = $replicated->schema->resultset('Artist')->find(1)
865 => 'found inside crazy deep transactions and execute_reliably';
866 is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
871 }) => 'successfully processed transaction';
874 => 'Got expected single result from transaction';
877 ## Test the force_pool resultset attribute.
880 ok my $artist_rs = $replicated->schema->resultset('Artist')
881 => 'got artist resultset';
883 ## Turn on Forced Pool Storage
884 ok my $reliable_artist_rs = $artist_rs->search(undef, {force_pool=>'master'})
885 => 'Created a resultset using force_pool storage';
887 ok my $artist = $reliable_artist_rs->find(2)
888 => 'got an artist result via force_pool storage';
890 is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
893 ## Test the force_pool resultset attribute part two.
896 ok my $artist_rs = $replicated->schema->resultset('Artist')
897 => 'got artist resultset';
899 ## Turn on Forced Pool Storage
900 ok my $reliable_artist_rs = $artist_rs->search(undef, {force_pool=>$replicant_names[0]})
901 => 'Created a resultset using force_pool storage';
903 ok my $artist = $reliable_artist_rs->find(2)
904 => 'got an artist result via force_pool storage';
906 is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{dsn}";
908 ## Delete the old database files
909 $replicated->cleanup;