1Test::mysqld(3pm) User Contributed Perl Documentation Test::mysqld(3pm)
2
3
4
6 Test::mysqld - mysqld runner for tests
7
9 use DBI;
10 use Test::mysqld;
11 use Test::More;
12
13 my $mysqld = Test::mysqld->new(
14 my_cnf => {
15 'skip-networking' => '', # no TCP socket
16 }
17 ) or plan skip_all => $Test::mysqld::errstr;
18
19 plan tests => XXX;
20
21 my $dbh = DBI->connect(
22 $mysqld->dsn(dbname => 'test'),
23 );
24
25 # start_mysqlds is faster than calling Test::mysqld->new twice
26 my @mysqlds = Test::mysqld->start_mysqlds(
27 2,
28 my_cnf => {
29 'skip-networking' => '', # no TCP socket
30 }
31 ) or plan skip_all => $Test::mysqld::errstr;
32 Test::mysqlds->stop_mysqlds(@mysqlds);
33
35 "Test::mysqld" automatically setups a mysqld instance in a temporary
36 directory, and destroys it when the perl script exits.
37
39 new
40 Create and run a mysqld instance. The instance is terminated when the
41 returned object is being DESTROYed. If required programs
42 (mysql_install_db and mysqld) were not found, the function returns
43 undef and sets appropriate message to $Test::mysqld::errstr.
44
45 base_dir
46 Returns directory under which the mysqld instance is being created.
47 The property can be set as a parameter of the "new" function, in which
48 case the directory will not be removed at exit.
49
50 copy_data_from
51 If specified, uses a copy of the specified directory as the data
52 directory of MySQL. "Mysql" database (which is used to store
53 administrative information) is automatically created if necessary by
54 invoking mysql_install_db.
55
56 my_cnf
57 A hash containing the list of name=value pairs to be written into
58 my.cnf. The property can be set as a parameter of the "new" function.
59
60 mysql_install_db
61 mysqld
62 Path to "mysql_install_db" script or "mysqld" program bundled to the
63 mysqld distribution. If not set, the program is automatically search
64 by looking up $PATH and other prefixed directories.
65
66 dsn
67 Builds and returns dsn by using given parameters (if any). Default
68 username is 'root', and dbname is 'test'.
69
70 pid
71 Returns process id of mysqld (or undef if not running).
72
73 start
74 Starts mysqld.
75
76 stop
77 Stops mysqld.
78
79 setup
80 Setups the mysqld instance.
81
82 read_log
83 Returns the contents of the mysqld log file.
84
85 start_mysqlds
86 Create and run some mysqld instances, and return a list of
87 "Test::mysqld".
88
89 stop_mysqlds
90 Stop some mysqld instances.
91
93 Copyright (C) 2009 Cybozu Labs, Inc. Written by Kazuho Oku.
94
96 This program is free software; you can redistribute it and/or modify it
97 under the same terms as Perl itself.
98
99 See <http://www.perl.com/perl/misc/Artistic.html>
100
101
102
103perl v5.28.0 2018-07-23 Test::mysqld(3pm)