mirror of
https://github.com/MariaDB/server.git
synced 2025-01-21 22:34:18 +01:00
075a2fb716
to copyright header.
95 lines
2.6 KiB
Text
95 lines
2.6 KiB
Text
# Copyright (c) 2004, 2005 MySQL AB
|
|
# Use is subject to license terms
|
|
#
|
|
# This program is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU Library General Public
|
|
# License as published by the Free Software Foundation; version 2
|
|
# of the License.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
# Library General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Library General Public
|
|
# License along with this library; if not, write to the Free
|
|
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
# MA 02110-1301, USA
|
|
|
|
# Node recovery killing 1 node out of 4 at the time and waiting for recover
|
|
|
|
use strict;
|
|
use NDB::Run;
|
|
|
|
my $env = NDB::Run->getenv;
|
|
my $log = $env->getlog;
|
|
$log->setpart(time => 1, line => 0);
|
|
$log->setprio("info");
|
|
|
|
my $database = $ENV{NDB_DATABASE};
|
|
$log->put("start test database=$database");
|
|
$env->init or $log->push("init failed")->fatal;
|
|
|
|
my $db = $env->getdb($database) or $log->push->fatal;
|
|
my $mgm = $db->getnode(1) or $log->push->fatal;
|
|
my $db1 = $db->getnode(2) or $log->push->fatal;
|
|
my $db2 = $db->getnode(3) or $log->push->fatal;
|
|
my $db3 = $db->getnode(4) or $log->push->fatal;
|
|
my $db4 = $db->getnode(5) or $log->push->fatal;
|
|
my $api = $db->getnode(6) or $log->push->fatal;
|
|
|
|
$db->kill;
|
|
$db->start({init_rm=>1}) or $log->push->fatal;
|
|
sleep 10;
|
|
|
|
# should be option (or default) in $db->start
|
|
sub wait_until_started {
|
|
my $local_cnt = 100;
|
|
while (--$local_cnt > 0) {
|
|
sleep 2;
|
|
my $ret = $mgm->write("all status", { wait => 2 });
|
|
$ret or $log->fatal;
|
|
my $output = $ret->{output};
|
|
if ($output =~ /((.|\n)*\bstarted\b(.|\n)*){4}/i) {
|
|
# if all 4 nodes started
|
|
$log->put("*** db is started ***")->info;
|
|
return;
|
|
}
|
|
if ($output =~ /((.|\n)*\bno.contact\b(.|\n)*){4}/i) {
|
|
#if all 4 nodes no contact
|
|
print "NDBT_ProgramExit: 1 - test error\n";
|
|
$log->put("*** db is dead ***")->fatal;
|
|
}
|
|
}
|
|
print "NDBT_ProgramExit: 1 - test error\n";
|
|
$log->put("*** node recovery failed ***")->fatal;
|
|
}
|
|
|
|
my $cnt = 0;
|
|
wait_until_started();
|
|
$api->start({run=>"flexBench -t 32 -l 800"});
|
|
while (1) {
|
|
wait_until_started();
|
|
sleep 10;
|
|
my $id = (++$cnt % 4);
|
|
my $dbx = 0;
|
|
if ($id eq 0) {
|
|
$dbx = $db1;
|
|
}
|
|
elsif ($id eq 1) {
|
|
$dbx = $db2;
|
|
}
|
|
elsif ($id eq 2) {
|
|
$dbx = $db3;
|
|
}
|
|
else {
|
|
$dbx = $db4;
|
|
}
|
|
$dbx->kill or $log->fatal;
|
|
sleep 10;
|
|
$dbx->start; # start the node
|
|
}
|
|
|
|
$db->kill;
|
|
|
|
# vim: set sw=4:
|