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');
13 use List::Util 'first';
14 use Scalar::Util 'reftype';
22 my $var_dir = quotemeta ( File::Spec->catdir(qw/t var/) );
24 use_ok 'DBIx::Class::Storage::DBI::Replicated::Pool';
25 use_ok 'DBIx::Class::Storage::DBI::Replicated::Balancer';
26 use_ok 'DBIx::Class::Storage::DBI::Replicated::Replicant';
27 use_ok 'DBIx::Class::Storage::DBI::Replicated';
31 This is a test of the replicated storage system. This will work in one of
32 two ways, either it was try to fake replication with a couple of SQLite DBs
33 and creative use of copy, or if you define a couple of %ENV vars correctly
34 will try to test those. If you do that, it will assume the setup is properly
40 ## ----------------------------------------------------------------------------
41 ## Build a class to hold all our required testing data and methods.
42 ## ----------------------------------------------------------------------------
46 ## --------------------------------------------------------------------- ##
47 ## Create an object to contain your replicated stuff.
48 ## --------------------------------------------------------------------- ##
50 package DBIx::Class::DBI::Replicated::TestReplication;
53 use base qw/Class::Accessor::Fast/;
55 __PACKAGE__->mk_accessors( qw/schema/ );
57 ## Initialize the object
60 my ($class, $schema_method) = (shift, shift);
61 my $self = $class->SUPER::new(@_);
63 $self->schema( $self->init_schema($schema_method) );
68 ## Get the Schema and set the replication storage type
71 # current SQLT SQLite producer does not handle DROP TABLE IF EXISTS, trap warnings here
72 local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /no such table.+DROP TABLE/s };
74 my ($class, $schema_method) = @_;
76 my $method = "get_schema_$schema_method";
77 my $schema = $class->$method;
82 sub get_schema_by_storage_type {
83 DBICTest->init_schema(
86 '::DBI::Replicated' => {
87 balancer_type=>'::Random',
89 auto_validate_every=>100,
90 master_read_weight => 1
100 sub get_schema_by_connect_info {
101 DBICTest->init_schema(
102 sqlite_use_file => 1,
103 storage_type=> '::DBI::Replicated',
104 balancer_type=>'::Random',
106 auto_validate_every=>100,
107 master_read_weight => 1
118 sub generate_replicant_connect_info {}
122 ## --------------------------------------------------------------------- ##
123 ## Add a connect_info option to test option merging.
124 ## --------------------------------------------------------------------- ##
127 package DBIx::Class::Storage::DBI::Replicated;
130 around connect_info => sub {
131 my ($next, $self, $info) = @_;
132 $info->[3]{master_option} = 1;
139 ## --------------------------------------------------------------------- ##
140 ## Subclass for when you are using SQLite for testing, this provides a fake
141 ## replication support.
142 ## --------------------------------------------------------------------- ##
144 package DBIx::Class::DBI::Replicated::TestReplication::SQLite;
148 use base 'DBIx::Class::DBI::Replicated::TestReplication';
150 __PACKAGE__->mk_accessors(qw/master_path slave_paths/);
152 ## Set the master path from DBICTest
155 my $class = shift @_;
156 my $self = $class->SUPER::new(@_);
158 $self->master_path( DBICTest->_sqlite_dbfilename );
160 File::Spec->catfile(qw/t var DBIxClass_slave1.db/),
161 File::Spec->catfile(qw/t var DBIxClass_slave2.db/),
167 ## Return an Array of ArrayRefs where each ArrayRef is suitable to use for
168 ## $storage->connect_info to be used for connecting replicants.
170 sub generate_replicant_connect_info {
174 } @{$self->slave_paths};
176 my @connect_infos = map { [$_,'','',{AutoCommit=>1}] } @dsn;
178 ## Make sure nothing is left over from a failed test
182 my $c = $connect_infos[0];
183 $connect_infos[0] = {
193 ## Do a 'good enough' replication by copying the master dbfile over each of
194 ## the slave dbfiles. If the master is SQLite we do this, otherwise we
195 ## just do a one second pause to let the slaves catch up.
199 foreach my $slave (@{$self->slave_paths}) {
200 copy($self->master_path, $slave);
204 ## Cleanup after ourselves. Unlink all gthe slave paths.
208 foreach my $slave (@{$self->slave_paths}) {
215 ## --------------------------------------------------------------------- ##
216 ## Subclass for when you are setting the databases via custom export vars
217 ## This is for when you have a replicating database setup that you are
218 ## going to test against. You'll need to define the correct $ENV and have
219 ## two slave databases to test against, as well as a replication system
220 ## that will replicate in less than 1 second.
221 ## --------------------------------------------------------------------- ##
223 package DBIx::Class::DBI::Replicated::TestReplication::Custom;
224 use base 'DBIx::Class::DBI::Replicated::TestReplication';
226 ## Return an Array of ArrayRefs where each ArrayRef is suitable to use for
227 ## $storage->connect_info to be used for connecting replicants.
229 sub generate_replicant_connect_info {
231 [$ENV{"DBICTEST_SLAVE0_DSN"}, $ENV{"DBICTEST_SLAVE0_DBUSER"}, $ENV{"DBICTEST_SLAVE0_DBPASS"}, {AutoCommit => 1}],
232 [$ENV{"DBICTEST_SLAVE1_DSN"}, $ENV{"DBICTEST_SLAVE1_DBUSER"}, $ENV{"DBICTEST_SLAVE1_DBPASS"}, {AutoCommit => 1}],
236 ## pause a bit to let the replication catch up
243 ## ----------------------------------------------------------------------------
244 ## Create an object and run some tests
245 ## ----------------------------------------------------------------------------
247 ## Thi first bunch of tests are basic, just make sure all the bits are behaving
249 my $replicated_class = DBICTest->has_custom_dsn ?
250 'DBIx::Class::DBI::Replicated::TestReplication::Custom' :
251 'DBIx::Class::DBI::Replicated::TestReplication::SQLite';
255 for my $method (qw/by_connect_info by_storage_type/) {
258 ok $replicated = $replicated_class->new($method)
259 => "Created a replication object $method";
261 isa_ok $replicated->schema
262 => 'DBIx::Class::Schema';
264 isa_ok $replicated->schema->storage
265 => 'DBIx::Class::Storage::DBI::Replicated';
267 isa_ok $replicated->schema->storage->balancer
268 => 'DBIx::Class::Storage::DBI::Replicated::Balancer::Random'
269 => 'configured balancer_type';
272 ## Check that all Storage::DBI methods are handled by ::Replicated
274 ## Get a bunch of methods to check
275 my @storage_dbi_methods = @{Class::Inspector->methods('DBIx::Class::Storage::DBI')||[]};
277 ## remove constants and OTHER_CRAP
278 @storage_dbi_methods = grep !/^[A-Z_]+\z/, @storage_dbi_methods;
280 ## remove CAG accessors
281 @storage_dbi_methods = grep !/_accessor\z/, @storage_dbi_methods;
283 ## we need to exclude this stuff as well
284 my %root_methods = map { $_ => 1 } @{Class::Inspector->methods('DBIx::Class')};
286 @storage_dbi_methods = grep { !$root_methods{$_} } @storage_dbi_methods;
290 for my $method (@storage_dbi_methods) {
291 push @missing_methods, $method
292 unless $replicated->schema->storage->can($method);
295 if(scalar(@missing_methods)) {
296 my $missing = join (',', @missing_methods);
297 fail "the following DBIx::Class::Storage::DBI methods are unimplemented: $missing";
299 pass 'all DBIx::Class::Storage::DBI methods implemented';
303 isa_ok $replicated->schema->storage->master
304 => 'DBIx::Class::Storage::DBI';
306 isa_ok $replicated->schema->storage->pool
307 => 'DBIx::Class::Storage::DBI::Replicated::Pool';
309 ok $replicated->schema->storage->balancer->does('DBIx::Class::Storage::DBI::Replicated::Balancer'),
312 ok my @replicant_connects = $replicated->generate_replicant_connect_info
313 => 'got replication connect information';
315 ok my @replicated_storages = $replicated->schema->storage->connect_replicants(@replicant_connects)
316 => 'Created some storages suitable for replicants';
319 $replicated->schema->storage->debug(1);
320 $replicated->schema->storage->debugcb(sub {
321 my ($op, $info) = @_;
322 ##warn "\n$op, $info\n";
326 dsn => ($info=~m/\[(.+)\]/)[0],
327 storage_type => $info=~m/REPLICANT/ ? 'REPLICANT' : 'MASTER',
331 ok my @all_storages = $replicated->schema->storage->all_storages
334 is scalar @all_storages,
336 => 'correct number of ->all_storages';
338 is ((grep $_->isa('DBIx::Class::Storage::DBI'), @all_storages),
340 => '->all_storages are correct type');
342 my @all_storage_opts =
343 grep { (reftype($_)||'') eq 'HASH' }
344 map @{ $_->_connect_info }, @all_storages;
346 is ((grep $_->{master_option}, @all_storage_opts), 3,
347 'connect_info was merged from master to replicants');
349 my @replicant_names = keys %{ $replicated->schema->storage->replicants };
351 ok @replicant_names, "found replicant names @replicant_names";
353 ## Silence warning about not supporting the is_replicating method if using the
355 $replicated->schema->storage->debugobj->silence(1)
356 if first { $_ =~ /$var_dir/ } @replicant_names;
358 isa_ok $replicated->schema->storage->balancer->current_replicant
359 => 'DBIx::Class::Storage::DBI';
361 $replicated->schema->storage->debugobj->silence(0);
363 ok scalar(keys(%{$replicated->schema->storage->pool->replicants}))
364 => 'does have replicants';
366 is scalar(keys(%{$replicated->schema->storage->pool->replicants})), 2
367 => 'has two replicants';
370 ok $replicated_storages[0]->does('DBIx::Class::Storage::DBI::Replicated::Replicant'),
373 ok $replicated_storages[1]->does('DBIx::Class::Storage::DBI::Replicated::Replicant'),
376 ok $replicated->schema->storage->replicants->{$replicant_names[0]}
377 ->does('DBIx::Class::Storage::DBI::Replicated::Replicant'),
380 ok $replicated->schema->storage->replicants->{$replicant_names[1]}
381 ->does('DBIx::Class::Storage::DBI::Replicated::Replicant'),
384 ## Add some info to the database
388 ->populate('Artist', [
389 [ qw/artistid name/ ],
390 [ 4, "Ozric Tentacles"],
393 is $debug{storage_type}, 'MASTER',
394 "got last query from a master: $debug{dsn}";
396 like $debug{info}, qr/INSERT/, 'Last was an insert';
398 ## Make sure all the slaves have the table definitions
400 $replicated->replicate;
401 $replicated->schema->storage->replicants->{$replicant_names[0]}->active(1);
402 $replicated->schema->storage->replicants->{$replicant_names[1]}->active(1);
404 ## Silence warning about not supporting the is_replicating method if using the
406 $replicated->schema->storage->debugobj->silence(1)
407 if first { $_ =~ /$var_dir/ } @replicant_names;
409 $replicated->schema->storage->pool->validate_replicants;
411 $replicated->schema->storage->debugobj->silence(0);
413 ## Make sure we can read the data.
415 ok my $artist1 = $replicated->schema->resultset('Artist')->find(4)
418 ## We removed testing here since master read weight is on, so we can't tell in
419 ## advance what storage to expect. We turn master read weight off a bit lower
420 ## is $debug{storage_type}, 'REPLICANT'
421 ## => "got last query from a replicant: $debug{dsn}, $debug{info}";
424 => 'DBICTest::Artist';
426 is $artist1->name, 'Ozric Tentacles'
427 => 'Found expected name for first result';
429 ## Check that master_read_weight is honored
431 no warnings qw/once redefine/;
434 *DBIx::Class::Storage::DBI::Replicated::Balancer::Random::_random_number =
437 $replicated->schema->storage->balancer->increment_storage;
439 is $replicated->schema->storage->balancer->current_replicant,
440 $replicated->schema->storage->master
441 => 'master_read_weight is honored';
443 ## turn it off for the duration of the test
444 $replicated->schema->storage->balancer->master_read_weight(0);
445 $replicated->schema->storage->balancer->increment_storage;
448 ## Add some new rows that only the master will have This is because
449 ## we overload any type of write operation so that is must hit the master
454 ->populate('Artist', [
455 [ qw/artistid name/ ],
456 [ 5, "Doom's Children"],
457 [ 6, "Dead On Arrival"],
461 is $debug{storage_type}, 'MASTER',
462 "got last query from a master: $debug{dsn}";
464 like $debug{info}, qr/INSERT/, 'Last was an insert';
466 ## Make sure all the slaves have the table definitions
467 $replicated->replicate;
469 ## Should find some data now
471 ok my $artist2 = $replicated->schema->resultset('Artist')->find(5)
474 is $debug{storage_type}, 'REPLICANT'
475 => "got last query from a replicant: $debug{dsn}";
478 => 'DBICTest::Artist';
480 is $artist2->name, "Doom's Children"
481 => 'Found expected name for first result';
483 ## What happens when we disconnect all the replicants?
485 is $replicated->schema->storage->pool->connected_replicants => 2
486 => "both replicants are connected";
488 $replicated->schema->storage->replicants->{$replicant_names[0]}->disconnect;
489 $replicated->schema->storage->replicants->{$replicant_names[1]}->disconnect;
491 is $replicated->schema->storage->pool->connected_replicants => 0
492 => "both replicants are now disconnected";
494 ## All these should pass, since the database should automatically reconnect
496 ok my $artist3 = $replicated->schema->resultset('Artist')->find(6)
497 => 'Still finding stuff.';
499 is $debug{storage_type}, 'REPLICANT'
500 => "got last query from a replicant: $debug{dsn}";
503 => 'DBICTest::Artist';
505 is $artist3->name, "Dead On Arrival"
506 => 'Found expected name for first result';
508 is $replicated->schema->storage->pool->connected_replicants => 1
509 => "At Least One replicant reconnected to handle the job";
511 ## What happens when we try to select something that doesn't exist?
513 ok ! $replicated->schema->resultset('Artist')->find(666)
514 => 'Correctly failed to find something.';
516 is $debug{storage_type}, 'REPLICANT'
517 => "got last query from a replicant: $debug{dsn}";
519 ## test the reliable option
523 $replicated->schema->storage->set_reliable_storage;
525 ok $replicated->schema->resultset('Artist')->find(2)
526 => 'Read from master 1';
528 is $debug{storage_type}, 'MASTER',
529 "got last query from a master: $debug{dsn}";
531 ok $replicated->schema->resultset('Artist')->find(5)
532 => 'Read from master 2';
534 is $debug{storage_type}, 'MASTER',
535 "got last query from a master: $debug{dsn}";
537 $replicated->schema->storage->set_balanced_storage;
539 ok $replicated->schema->resultset('Artist')->find(3)
540 => 'Read from replicant';
542 is $debug{storage_type}, 'REPLICANT',
543 "got last query from a replicant: $debug{dsn}";
546 ## Make sure when reliable goes out of scope, we are using replicants again
548 ok $replicated->schema->resultset('Artist')->find(1)
549 => 'back to replicant 1.';
551 is $debug{storage_type}, 'REPLICANT',
552 "got last query from a replicant: $debug{dsn}";
554 ok $replicated->schema->resultset('Artist')->find(2)
555 => 'back to replicant 2.';
557 is $debug{storage_type}, 'REPLICANT',
558 "got last query from a replicant: $debug{dsn}";
560 ## set all the replicants to inactive, and make sure the balancer falls back to
563 $replicated->schema->storage->replicants->{$replicant_names[0]}->active(0);
564 $replicated->schema->storage->replicants->{$replicant_names[1]}->active(0);
567 ## catch the fallback to master warning
568 open my $debugfh, '>', \my $fallback_warning;
569 my $oldfh = $replicated->schema->storage->debugfh;
570 $replicated->schema->storage->debugfh($debugfh);
572 ok $replicated->schema->resultset('Artist')->find(2)
573 => 'Fallback to master';
575 is $debug{storage_type}, 'MASTER',
576 "got last query from a master: $debug{dsn}";
578 like $fallback_warning, qr/falling back to master/
579 => 'emits falling back to master debug';
581 $replicated->schema->storage->debugfh($oldfh);
584 $replicated->schema->storage->replicants->{$replicant_names[0]}->active(1);
585 $replicated->schema->storage->replicants->{$replicant_names[1]}->active(1);
587 ## Silence warning about not supporting the is_replicating method if using the
589 $replicated->schema->storage->debugobj->silence(1)
590 if first { $_ =~ /$var_dir/ } @replicant_names;
592 $replicated->schema->storage->pool->validate_replicants;
594 $replicated->schema->storage->debugobj->silence(0);
597 ## catch the fallback to master warning
598 open my $debugfh, '>', \my $return_warning;
599 my $oldfh = $replicated->schema->storage->debugfh;
600 $replicated->schema->storage->debugfh($debugfh);
602 ok $replicated->schema->resultset('Artist')->find(2)
603 => 'Return to replicants';
605 is $debug{storage_type}, 'REPLICANT',
606 "got last query from a replicant: $debug{dsn}";
608 like $return_warning, qr/Moved back to slave/
609 => 'emits returning to slave debug';
611 $replicated->schema->storage->debugfh($oldfh);
614 ## Getting slave status tests
617 ## We skip this tests unless you have a custom replicants, since the default
618 ## sqlite based replication tests don't support these functions.
620 skip 'Cannot Test Replicant Status on Non Replicating Database', 10
621 unless DBICTest->has_custom_dsn && $ENV{"DBICTEST_SLAVE0_DSN"};
623 $replicated->replicate; ## Give the slaves a chance to catchup.
625 ok $replicated->schema->storage->replicants->{$replicant_names[0]}->is_replicating
626 => 'Replicants are replicating';
628 is $replicated->schema->storage->replicants->{$replicant_names[0]}->lag_behind_master, 0
629 => 'Replicant is zero seconds behind master';
631 ## Test the validate replicants
633 $replicated->schema->storage->pool->validate_replicants;
635 is $replicated->schema->storage->pool->active_replicants, 2
636 => 'Still have 2 replicants after validation';
638 ## Force the replicants to fail the validate test by required their lag to
639 ## be negative (ie ahead of the master!)
641 $replicated->schema->storage->pool->maximum_lag(-10);
642 $replicated->schema->storage->pool->validate_replicants;
644 is $replicated->schema->storage->pool->active_replicants, 0
645 => 'No way a replicant be be ahead of the master';
647 ## Let's be fair to the replicants again. Let them lag up to 5
649 $replicated->schema->storage->pool->maximum_lag(5);
650 $replicated->schema->storage->pool->validate_replicants;
652 is $replicated->schema->storage->pool->active_replicants, 2
653 => 'Both replicants in good standing again';
655 ## Check auto validate
657 is $replicated->schema->storage->balancer->auto_validate_every, 100
658 => "Got the expected value for auto validate";
660 ## This will make sure we auto validatge everytime
661 $replicated->schema->storage->balancer->auto_validate_every(0);
663 ## set all the replicants to inactive, and make sure the balancer falls back to
666 $replicated->schema->storage->replicants->{$replicant_names[0]}->active(0);
667 $replicated->schema->storage->replicants->{$replicant_names[1]}->active(0);
669 ## Ok, now when we go to run a query, autovalidate SHOULD reconnect
671 is $replicated->schema->storage->pool->active_replicants => 0
672 => "both replicants turned off";
674 ok $replicated->schema->resultset('Artist')->find(5)
675 => 'replicant reactivated';
677 is $debug{storage_type}, 'REPLICANT',
678 "got last query from a replicant: $debug{dsn}";
680 is $replicated->schema->storage->pool->active_replicants => 2
681 => "both replicants reactivated";
684 ## Test the reliably callback
686 ok my $reliably = sub {
688 ok $replicated->schema->resultset('Artist')->find(5)
689 => 'replicant reactivated';
691 is $debug{storage_type}, 'MASTER',
692 "got last query from a master: $debug{dsn}";
694 } => 'created coderef properly';
696 $replicated->schema->storage->execute_reliably($reliably);
698 ## Try something with an error
700 ok my $unreliably = sub {
702 ok $replicated->schema->resultset('ArtistXX')->find(5)
703 => 'replicant reactivated';
705 } => 'created coderef properly';
707 throws_ok {$replicated->schema->storage->execute_reliably($unreliably)}
708 qr/Can't find source for ArtistXX/
709 => 'Bad coderef throws proper error';
711 ## Make sure replication came back
713 ok $replicated->schema->resultset('Artist')->find(3)
714 => 'replicant reactivated';
716 is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{dsn}";
718 ## make sure transactions are set to execute_reliably
720 ok my $transaction = sub {
726 ->populate('Artist', [
727 [ qw/artistid name/ ],
728 [ $id, "Children of the Grave $id"],
731 ok my $result = $replicated->schema->resultset('Artist')->find($id)
732 => "Found expected artist for $id";
734 is $debug{storage_type}, 'MASTER',
735 "got last query from a master: $debug{dsn}";
737 ok my $more = $replicated->schema->resultset('Artist')->find(1)
738 => 'Found expected artist again for 1';
740 is $debug{storage_type}, 'MASTER',
741 "got last query from a master: $debug{dsn}";
743 return ($result, $more);
745 } => 'Created a coderef properly';
747 ## Test the transaction with multi return
749 ok my @return = $replicated->schema->txn_do($transaction, 666)
750 => 'did transaction';
752 is $return[0]->id, 666
753 => 'first returned value is correct';
755 is $debug{storage_type}, 'MASTER',
756 "got last query from a master: $debug{dsn}";
759 => 'second returned value is correct';
761 is $debug{storage_type}, 'MASTER',
762 "got last query from a master: $debug{dsn}";
766 ## Test that asking for single return works
768 ok my @return = $replicated->schema->txn_do($transaction, 777)
769 => 'did transaction';
771 is $return[0]->id, 777
772 => 'first returned value is correct';
775 => 'second returned value is correct';
778 ## Test transaction returning a single value
781 ok my $result = $replicated->schema->txn_do(sub {
782 ok my $more = $replicated->schema->resultset('Artist')->find(1)
783 => 'found inside a transaction';
784 is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
786 }) => 'successfully processed transaction';
789 => 'Got expected single result from transaction';
792 ## Make sure replication came back
794 ok $replicated->schema->resultset('Artist')->find(1)
795 => 'replicant reactivated';
797 is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{dsn}";
799 ## Test Discard changes
802 ok my $artist = $replicated->schema->resultset('Artist')->find(2)
803 => 'got an artist to test discard changes';
805 is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{dsn}";
807 ok $artist->get_from_storage({force_pool=>'master'})
808 => 'properly discard changes';
810 is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
812 ok $artist->discard_changes({force_pool=>'master'})
813 => 'properly called discard_changes against master (manual attrs)';
815 is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
817 ok $artist->discard_changes()
818 => 'properly called discard_changes against master (default attrs)';
820 is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
822 ok $artist->discard_changes({force_pool=>$replicant_names[0]})
823 => 'properly able to override the default attributes';
825 is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{dsn}"
828 ## Test some edge cases, like trying to do a transaction inside a transaction, etc
831 ok my $result = $replicated->schema->txn_do(sub {
832 return $replicated->schema->txn_do(sub {
833 ok my $more = $replicated->schema->resultset('Artist')->find(1)
834 => 'found inside a transaction inside a transaction';
835 is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
838 }) => 'successfully processed transaction';
841 => 'Got expected single result from transaction';
845 ok my $result = $replicated->schema->txn_do(sub {
846 return $replicated->schema->storage->execute_reliably(sub {
847 return $replicated->schema->txn_do(sub {
848 return $replicated->schema->storage->execute_reliably(sub {
849 ok my $more = $replicated->schema->resultset('Artist')->find(1)
850 => 'found inside crazy deep transactions and execute_reliably';
851 is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
856 }) => 'successfully processed transaction';
859 => 'Got expected single result from transaction';
862 ## Test the force_pool resultset attribute.
865 ok my $artist_rs = $replicated->schema->resultset('Artist')
866 => 'got artist resultset';
868 ## Turn on Forced Pool Storage
869 ok my $reliable_artist_rs = $artist_rs->search(undef, {force_pool=>'master'})
870 => 'Created a resultset using force_pool storage';
872 ok my $artist = $reliable_artist_rs->find(2)
873 => 'got an artist result via force_pool storage';
875 is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
878 ## Test the force_pool resultset attribute part two.
881 ok my $artist_rs = $replicated->schema->resultset('Artist')
882 => 'got artist resultset';
884 ## Turn on Forced Pool Storage
885 ok my $reliable_artist_rs = $artist_rs->search(undef, {force_pool=>$replicant_names[0]})
886 => 'Created a resultset using force_pool storage';
888 ok my $artist = $reliable_artist_rs->find(2)
889 => 'got an artist result via force_pool storage';
891 is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{dsn}";
893 ## Delete the old database files
894 $replicated->cleanup;