Subject: | Remote MySQL for tests + fix to pass all CHI tests |
Hi Scott,
CHIDriverTests-MySQLHandlerSocket.t does not allow to specify remote
MySQL host. Attached please find a QND fix for this issue. The database
can be entered in a form "XXX:host=YYY"
The patch also allows to have all CHI tests passed.
Besides immediate bug fixes it creates tables using InnoDB, as MyISAM
seems to be inappropriate. Please see the details -
http://www.pablowe.net/2011/03/handlersocket-edge-cases/
One outstanding issue remains -
CHI/Driver/HandlerSocket/t/CHIDriverTests/Base.pm wants CHI::Driver::DBI
to be installed, otherwise fails. While CHI::Driver::DBI does not seem
to be necessary for CHI::Driver::HandlerSocket, I am not sure if it is
mandatory for proper CHI operation.
Many thanks for your fantastic job, I would be glad to be any help.
Subject: | CHI-Driver-HandlerSocket-0.991.patch |
diff -ur CHI-Driver-HandlerSocket-0.991-old/lib/CHI/Driver/HandlerSocket/t/CHIDriverTests/Base.pm CHI-Driver-HandlerSocket-0.991/lib/CHI/Driver/HandlerSocket/t/CHIDriverTests/Base.pm
--- CHI-Driver-HandlerSocket-0.991-old/lib/CHI/Driver/HandlerSocket/t/CHIDriverTests/Base.pm 2011-03-11 14:49:29.000000000 -0500
+++ CHI-Driver-HandlerSocket-0.991/lib/CHI/Driver/HandlerSocket/t/CHIDriverTests/Base.pm 2012-06-05 18:05:00.000000000 -0400
@@ -33,13 +33,16 @@
};
}
+sub host { 'localhost' };
+
sub new_cache_options {
my $self = shift;
return (
$self->SUPER::new_cache_options(),
dbh => $self->dbh,
- create_table => 1
+ create_table => 1,
+ host => $self->host,
);
}
diff -ur CHI-Driver-HandlerSocket-0.991-old/lib/CHI/Driver/HandlerSocket/t/CHIDriverTests/MySQLHandlerSocket.pm CHI-Driver-HandlerSocket-0.991/lib/CHI/Driver/HandlerSocket/t/CHIDriverTests/MySQLHandlerSocket.pm
--- CHI-Driver-HandlerSocket-0.991-old/lib/CHI/Driver/HandlerSocket/t/CHIDriverTests/MySQLHandlerSocket.pm 2011-03-11 14:49:29.000000000 -0500
+++ CHI-Driver-HandlerSocket-0.991/lib/CHI/Driver/HandlerSocket/t/CHIDriverTests/MySQLHandlerSocket.pm 2012-06-05 18:04:09.000000000 -0400
@@ -11,16 +11,19 @@
}
our $dbh;
+our $host;
sub runtests {
my $class = shift;
my %opts = @_;
- $dbh = DBI->connect("DBI:mysql:database=$opts{database};host=localhost", $opts{user}, $opts{pass}) or
+ $dbh = DBI->connect("DBI:mysql:database=$opts{database}", $opts{user}, $opts{pass}) or
die "failed to connect to database: $DBI::errstr";
+ $host = $opts{host} // 'localhost';
$class->SUPER::runtests();
}
sub dbh { return $dbh; }
+sub host { return $host; }
sub cleanup : Tests( shutdown ) {
# unlink 't/dbfile.db';
diff -ur CHI-Driver-HandlerSocket-0.991-old/lib/CHI/Driver/HandlerSocket.pm CHI-Driver-HandlerSocket-0.991/lib/CHI/Driver/HandlerSocket.pm
--- CHI-Driver-HandlerSocket-0.991-old/lib/CHI/Driver/HandlerSocket.pm 2011-03-11 20:46:18.000000000 -0500
+++ CHI-Driver-HandlerSocket-0.991/lib/CHI/Driver/HandlerSocket.pm 2012-06-05 21:06:14.652004748 -0400
@@ -208,7 +208,7 @@
# CREATE TABLE IF NOT EXISTS $table ( `key` VARCHAR( 300 ), `value` TEXT, PRIMARY KEY ( `key` ) ) CHARSET=utf8 # fails 220 tests
$dbh->do( qq{
- CREATE TABLE IF NOT EXISTS $table ( `key` VARCHAR( 600 ), `value` BLOB, PRIMARY KEY ( `key` ) ) CHARSET=ASCII
+ CREATE TABLE IF NOT EXISTS $table ( `key` VARBINARY( 600 ), `value` BLOB, PRIMARY KEY ( `key` ) ) ENGINE=InnoDB
} ) or croak $dbh->errstr;
# from https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL/blob/master/docs-en/perl-client.en.txt:
diff -ur CHI-Driver-HandlerSocket-0.991-old/t/CHIDriverTests-MySQLHandlerSocket.t CHI-Driver-HandlerSocket-0.991/t/CHIDriverTests-MySQLHandlerSocket.t
--- CHI-Driver-HandlerSocket-0.991-old/t/CHIDriverTests-MySQLHandlerSocket.t 2011-03-11 14:49:29.000000000 -0500
+++ CHI-Driver-HandlerSocket-0.991/t/CHIDriverTests-MySQLHandlerSocket.t 2012-06-05 18:12:04.000000000 -0400
@@ -8,25 +8,28 @@
my $database;
my $user;
my $pass;
+my $host;
# Makefile.PL asks the user (if the user is reachable) for database login info to test with; that gets appeneded to the end of this file
while(my $line = readline DATA) {
no warnings 'uninitialized';
chomp $line;
- (my $k, my $v) = split /=/, $line;
+ (my $k, my $v) = split /=/, $line, 2;
$database = $v if $k eq 'database';
$user = $v if $k eq 'user';
$pass = $v if $k eq 'pass';
}
if($user and $pass ) {
+ $database =~ /;host=(.+);*/o;
+ $host = $1 if $1;
CHI::Driver::HandlerSocket::t::CHIDriverTests::MySQLHandlerSocket->runtests(
user => $user,
pass => $pass,
database => $database,
+ host => $host,
);
}
__DATA__
-