Test::Docker::MySQL is a module to launch MySQL in docker containers.
# You have to setup docker manually before you use this (see SETUP section) $ENV{DOCKER_HOST} ||= 'tcp://192.168.59.103:2375'; # optional use Test::Docker::MySQL; my $dm_guard = Test::Docker::MySQL->new; my $port_1 = $dm_guard->get_port; # get a mysql container port my $port_2 = $dm_guard->get_port; # get another mysql container port my $dsn_1 = "dbi:mysql:database=mysql;host=127.0.0.1;port=$port_1"; my $dbh_1 = DBI->connect($dsn , 'root', '', { RaiseError => 1 }); my $dsn_2 = "dbi:mysql:database=mysql;host=127.0.0.1;port=$port_2"; my $dbh_2 = DBI->connect($dsn , 'root', '', { RaiseError => 1 }); undef $dm_guard; # dispatch `docker kill $container` command
new
All parameters are optional.
tag
The tag to launch via Docker. Default value is punytan/p5-test-docker-mysql.
punytan/p5-test-docker-mysql
ports
Specify port range by ports. Default value is [ 55500 .. 55555 ],
[ 55500 .. 55555 ]
get_port
Returns allocated port.
You can find the binary at https://github.com/boot2docker/osx-installer/releases.
$ boot2docker download && boot2docker init && boot2docker up
$ boot2docker down $ for i in {55500..55555}; do VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i"; VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i"; done $ boot2docker up
$ docker pull punytan/p5-test-docker-mysql
$ docker kill $(docker ps -a -q) $ docker rm $(docker ps -a -q)
Set DEBUG_TEST_DOCKER_MYSQL as true to get verbose log generated by this module.
DEBUG_TEST_DOCKER_MYSQL
punytan <punytan@gmail.com>
Copyright 2014- punytan
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Test::mysqld
To install Test::Docker::MySQL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Docker::MySQL
CPAN shell
perl -MCPAN -e shell install Test::Docker::MySQL
For more information on module installation, please visit the detailed CPAN module installation guide.