[Bast-commits] r4368 - in
DBIx-Class/0.08/branches/replication_dedux:
lib/DBIx/Class/Storage/DBI lib/DBIx/Class/Storage/DBI/Replicated t
jnapiorkowski at dev.catalyst.perl.org
jnapiorkowski at dev.catalyst.perl.org
Fri May 9 01:06:42 BST 2008
Author: jnapiorkowski
Date: 2008-05-09 01:06:42 +0100 (Fri, 09 May 2008)
New Revision: 4368
Modified:
DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm
DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI/mysql.pm
DBIx-Class/0.08/branches/replication_dedux/t/93storage_replication.t
Log:
fixed up the relicant status tests to exclude them if the database is not a real replicating setup, removed some debug code, got the lag_behind_master and is_replicating methods working properly.
Modified: DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm 2008-05-08 23:34:55 UTC (rev 4367)
+++ DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm 2008-05-09 00:06:42 UTC (rev 4368)
@@ -119,7 +119,6 @@
my $replicant = $self->create_replicant($schema);
$replicant->connect_info($connect_info);
$replicant->ensure_connected;
-
DBIx::Class::Storage::DBI::Replicated::Replicant->meta->apply($replicant);
my ($key) = ($connect_info->[0]=~m/^dbi\:.+\:(.+)$/);
Modified: DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI/mysql.pm
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI/mysql.pm 2008-05-08 23:34:55 UTC (rev 4367)
+++ DBIx-Class/0.08/branches/replication_dedux/lib/DBIx/Class/Storage/DBI/mysql.pm 2008-05-09 00:06:42 UTC (rev 4368)
@@ -33,14 +33,14 @@
$self->dbh->do("ROLLBACK TO SAVEPOINT $name")
}
-
+
sub is_replicating {
- my $self = shift @_;
+ my $status = shift->dbh->selectrow_hashref('show slave status');
+ return ($status->{Slave_IO_Running} eq 'Yes') && ($status->{Slave_SQL_Running} eq 'Yes');
}
sub lag_behind_master {
- my $self = shift @_;
- return $self->dbh->selectrow_hashref('show slave status');
+ return shift->dbh->selectrow_hashref('show slave status')->{Seconds_Behind_Master};
}
1;
Modified: DBIx-Class/0.08/branches/replication_dedux/t/93storage_replication.t
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/t/93storage_replication.t 2008-05-08 23:34:55 UTC (rev 4367)
+++ DBIx-Class/0.08/branches/replication_dedux/t/93storage_replication.t 2008-05-09 00:06:42 UTC (rev 4368)
@@ -8,7 +8,7 @@
eval "use Moose; use Test::Moose";
plan $@
? ( skip_all => 'needs Moose for testing' )
- : ( tests => 41 );
+ : ( tests => 43 );
}
use_ok 'DBIx::Class::Storage::DBI::Replicated::Pool';
@@ -365,10 +365,22 @@
## Getting slave status tests
-use Data::Dump qw/dump/;
-my $lag1 = $replicated->schema->storage->replicants->{$replicant_names[0]}->lag_behind_master;
-warn dump $lag1;
-
+SKIP: {
+ ## We skip this tests unless you have a custom replicants, since the default
+ ## sqlite based replication tests don't support these functions.
+
+ skip 'Cannot Test Replicant Status on Non Replicating Database', 2
+ unless DBICTest->has_custom_dsn && $ENV{"DBICTEST_SLAVE0_DSN"};
+
+ $replicated->replicate; ## Give the slaves a chance to catchup.
+
+ ok $replicated->schema->storage->replicants->{$replicant_names[0]}->is_replicating
+ => 'Replicants are replicating';
+
+ is $replicated->schema->storage->replicants->{$replicant_names[0]}->lag_behind_master, 0
+ => 'Replicant is zero seconds behind master';
+}
+
## Delete the old database files
$replicated->cleanup;
More information about the Bast-commits
mailing list