|
|
79c577 |
#!/usr/bin/perl
|
|
|
79c577 |
|
|
|
79c577 |
use strict;
|
|
|
79c577 |
use warnings;
|
|
|
79c577 |
|
|
|
79c577 |
use Test::More tests => 7;
|
|
|
79c577 |
|
|
|
79c577 |
# MySQL setup
|
|
|
79c577 |
my $MYSQL_DIR = $ENV{'MYSQL_DIR'};
|
|
|
79c577 |
my $MYSQL_UNIX_PORT = $ENV{'MYSQL_UNIX_PORT'};
|
|
|
79c577 |
my $MYSQL_PIDFILE = $ENV{'MYSQL_PIDFILE'};
|
|
|
79c577 |
my $MYSQL_USER = $ENV{'MYSQL_USER'};
|
|
|
79c577 |
chomp($MYSQL_USER);
|
|
|
79c577 |
|
|
|
79c577 |
# DBD::MariaDB test setup
|
|
|
79c577 |
my $DBD_MARIADB_TESTDB = $ENV{'DBD_MARIADB_TESTDB'};
|
|
|
79c577 |
my $DBD_MARIADB_TESTHOST = $ENV{'DBD_MARIADB_TESTHOST'};
|
|
|
79c577 |
my $DBD_MARIADB_TESTSOCKET = $ENV{'DBD_MARIADB_TESTSOCKET'};
|
|
|
79c577 |
my $DBD_MARIADB_TESTUSER = $ENV{'DBD_MARIADB_TESTUSER'};
|
|
|
79c577 |
my $DBD_MARIADB_TESTPASSWORD = $ENV{'DBD_MARIADB_TESTPASSWORD'};
|
|
|
79c577 |
|
|
|
79c577 |
my $MYSQLD = '';
|
|
|
79c577 |
my $mysql_version = readpipe("mysql --version");
|
|
|
79c577 |
if ($mysql_version =~ /MariaDB/) {
|
|
|
79c577 |
system("mysql_install_db --no-defaults --datadir=$MYSQL_DIR --force --skip-name-resolve --explicit_defaults_for_timestamp >/dev/null 2>&1");
|
|
|
79c577 |
is($?, 0);
|
|
|
79c577 |
$MYSQLD = '/usr/libexec/mysqld';
|
|
|
79c577 |
} else {
|
|
|
79c577 |
$MYSQLD = '/usr/sbin/mysqld';
|
|
|
79c577 |
system("$MYSQLD --no-defaults --initialize-insecure --datadir=$MYSQL_DIR --explicit_defaults_for_timestamp --user=$MYSQL_USER >/dev/null 2>&1");
|
|
|
79c577 |
is($?, 0);
|
|
|
79c577 |
}
|
|
|
79c577 |
|
|
|
79c577 |
my $cmd = "$MYSQLD --no-defaults --user=$MYSQL_USER --socket=$MYSQL_UNIX_PORT --datadir=$MYSQL_DIR --pid-file=$MYSQL_PIDFILE --explicit_defaults_for_timestamp --skip-networking >/dev/null 2>&1 &";
|
|
|
79c577 |
system($cmd);
|
|
|
79c577 |
is($?, 0);
|
|
|
79c577 |
|
|
|
79c577 |
my $attempts = 0;
|
|
|
79c577 |
while (system("/usr/bin/mysqladmin --user=root --socket=$MYSQL_UNIX_PORT ping >/dev/null 2>&1") != 0) {
|
|
|
79c577 |
sleep 3;
|
|
|
79c577 |
$attempts++;
|
|
|
79c577 |
if ($attempts > 10) {
|
|
|
79c577 |
fail("skipping test, mariadb/mysql server could not be contacted after 30 seconds\n");
|
|
|
79c577 |
}
|
|
|
79c577 |
}
|
|
|
79c577 |
ok(1);
|
|
|
79c577 |
|
|
|
79c577 |
system("mysql --socket=$MYSQL_UNIX_PORT --execute \"CREATE USER '$DBD_MARIADB_TESTUSER\@localhost';\" 2>&1");
|
|
|
79c577 |
is($?, 0);
|
|
|
79c577 |
system("mysql --socket=$MYSQL_UNIX_PORT --execute \"CREATE DATABASE IF NOT EXISTS $DBD_MARIADB_TESTDB CHARACTER SET='utf8mb4';\" 2>&1");
|
|
|
79c577 |
is($?, 0);
|
|
|
79c577 |
system("mysql --socket=$MYSQL_UNIX_PORT --execute \"GRANT ALL PRIVILEGES ON $DBD_MARIADB_TESTDB.* TO '$DBD_MARIADB_TESTUSER\@localhost' IDENTIFIED BY '$DBD_MARIADB_TESTPASSWORD';\" 2>&1");
|
|
|
79c577 |
is($?, 0);
|
|
|
79c577 |
system("/usr/bin/mysqladmin --user=$DBD_MARIADB_TESTUSER --password=$DBD_MARIADB_TESTPASSWORD --socket=$DBD_MARIADB_TESTSOCKET ping >/dev/null 2>&1");
|
|
|
79c577 |
is($?, 0);
|