mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-14 07:06:28 +00:00
Validate --max|critical-load early and strongly, and check that the var exists and is defined.
This commit is contained in:
@@ -9,7 +9,7 @@ BEGIN {
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 14;
|
||||
use Test::More tests => 17;
|
||||
|
||||
use MySQLStatusWaiter;
|
||||
use PerconaTest;
|
||||
@@ -45,20 +45,42 @@ sub sleep {
|
||||
|
||||
throws_ok(
|
||||
sub { new MySQLStatusWaiter(
|
||||
max_spec => '100',
|
||||
max_spec => [qw(100)],
|
||||
get_status => \&get_status,
|
||||
sleep => \&sleep,
|
||||
oktorun => \&oktorun,
|
||||
) },
|
||||
qr/Invalid spec/,
|
||||
"Validate max_spec"
|
||||
qr/100 is not a variable name/,
|
||||
"Catch non-variable name"
|
||||
);
|
||||
|
||||
throws_ok(
|
||||
sub { new MySQLStatusWaiter(
|
||||
max_spec => [qw(foo=bar)],
|
||||
get_status => \&get_status,
|
||||
sleep => \&sleep,
|
||||
oktorun => \&oktorun,
|
||||
) },
|
||||
qr/value for foo must be a number/,
|
||||
"Catch non-number value"
|
||||
);
|
||||
|
||||
throws_ok(
|
||||
sub { new MySQLStatusWaiter(
|
||||
max_spec => [qw(foo)],
|
||||
get_status => \&get_status,
|
||||
sleep => \&sleep,
|
||||
oktorun => \&oktorun,
|
||||
) },
|
||||
qr/foo does not exist/,
|
||||
"Catch non-existent variable"
|
||||
);
|
||||
|
||||
# ############################################################################
|
||||
# Use initial vals + 20%.
|
||||
# ############################################################################
|
||||
@vals = (
|
||||
# initial values
|
||||
# initial check for existence
|
||||
{ Threads_connected => 10, },
|
||||
{ Threads_running => 5, },
|
||||
|
||||
@@ -83,6 +105,8 @@ throws_ok(
|
||||
{ Threads_running => 5, },
|
||||
);
|
||||
|
||||
$oktorun = 1;
|
||||
|
||||
my $sw = new MySQLStatusWaiter(
|
||||
oktorun => \&oktorun,
|
||||
get_status => \&get_status,
|
||||
@@ -142,6 +166,10 @@ is(
|
||||
# Use static vals.
|
||||
# ############################################################################
|
||||
@vals = (
|
||||
# initial check for existence
|
||||
{ Threads_connected => 1, },
|
||||
{ Threads_running => 1, },
|
||||
|
||||
# first check, no wait
|
||||
{ Threads_connected => 1, },
|
||||
{ Threads_running => 1, },
|
||||
@@ -223,6 +251,10 @@ is(
|
||||
# Critical thresholds (with static vals).
|
||||
# ############################################################################
|
||||
@vals = (
|
||||
# initial check for existence
|
||||
{ Threads_running => 1, },
|
||||
{ Threads_running => 9, },
|
||||
|
||||
# first check, no wait
|
||||
{ Threads_running => 1, },
|
||||
{ Threads_running => 9, },
|
||||
|
Reference in New Issue
Block a user