Compare commits

..

1 Commits

Author SHA1 Message Date
dependabot[bot]
ea8fc17dbc build(deps): bump k8s.io/api from 0.34.0 to 0.34.1
Bumps [k8s.io/api](https://github.com/kubernetes/api) from 0.34.0 to 0.34.1.
- [Commits](https://github.com/kubernetes/api/compare/v0.34.0...v0.34.1)

---
updated-dependencies:
- dependency-name: k8s.io/api
  dependency-version: 0.34.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-15 09:50:34 +00:00
8 changed files with 89 additions and 414 deletions

View File

@@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v6
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Build

View File

@@ -12,17 +12,21 @@ MAKE_GOTOOLS
WriteMakefile(
NAME => 'Percona::Toolkit',
VERSION => '3.7.0-2',
EXE_FILES => [ <bin/*> ],
EXE_FILES => [
map {
(my $name = $_) =~ s/^bin.//;
my $file_name = $_;
if ( ( $file_name !~ m/mongo/ ) || ( $file_name !~ m/pg/ ) || ( $file_name !~ m/pt-stalk/ ) || ( $file_name !~ m/pt-k8s/ ) ) {
$_;
}
} <bin/*>
],
MAN1PODS => {
'docs/percona-toolkit.pod' => 'blib/man1/percona-toolkit.1p',
map {
(my $name = $_) =~ s/^bin.//;
my $file_name = $_;
if ( $file_name =~ m/(mongo|pg|galera|k8s|secure)/ ) {
# We have to put empty line here to avoid the MAN1PODS hash corruption
'' => '',
}
else {
if ( ( $file_name !~ m/mongo/ ) || ( $file_name !~ m/pg/ ) || ( $file_name !~ m/pt-stalk/ ) || ( $file_name !~ m/pt-k8s/ ) ) {
$_ => "blib/man1/$name.1p";
}
} <bin/*>
@@ -33,4 +37,4 @@ if ( $file_name =~ m/(mongo|pg|galera|k8s|secure)/ ) {
DBI => 1.46,
DBD::mysql => 3.0000_0,
},
);
);

View File

@@ -971,10 +971,8 @@ collect_mysql_data_one() {
fi
fi
if ! _should_skip "mysqladmin"; then
$CMD_MYSQLADMIN $EXT_ARGV ext -i$OPT_SLEEP_COLLECT -c$cnt >>"$d/$p-mysqladmin" &
mysqladmin_pid=$!
fi
$CMD_MYSQLADMIN $EXT_ARGV ext -i$OPT_SLEEP_COLLECT -c$cnt >>"$d/$p-mysqladmin" &
mysqladmin_pid=$!
ps_instrumentation_enabled=$($CMD_MYSQL $EXT_ARGV -e 'SELECT ENABLED FROM performance_schema.setup_instruments WHERE NAME = "transaction";' \
| sed "2q;d" | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')
@@ -1016,25 +1014,18 @@ collect_system_data() {
collect_mysql_data_loop() {
if ! _should_skip "processlist"; then
(echo $ts; $CMD_MYSQL $EXT_ARGV -e "SHOW FULL PROCESSLIST\G") \
>> "$d/$p-processlist" &
fi
(echo $ts; $CMD_MYSQL $EXT_ARGV -e "SELECT * FROM performance_schema.threads\G") \
>> "$d/$p-threads" &
(echo $ts; $CMD_MYSQL $EXT_ARGV -e "SELECT * FROM performance_schema.threads\G") \
>> "$d/$p-threads" &
if [ "$have_lock_waits_table" ]; then
if ! _should_skip "lock-waits"; then
(echo $ts; lock_waits "$d/lock_waits.running") >>"$d/$p-lock-waits" &
fi
if ! _should_skip "transactions"; then
(echo $ts; transactions) >>"$d/$p-transactions" &
fi
(echo $ts; lock_waits "$d/lock_waits.running") >>"$d/$p-lock-waits" &
(echo $ts; transactions) >>"$d/$p-transactions" &
fi
if [ "${mysql_version}" '>' "5.6" ] && [ $ps_instrumentation_enabled == "yes" ] \
&& ! _should_skip "ps-locks-transactions"; then
if [ "${mysql_version}" '>' "5.6" ] && [ $ps_instrumentation_enabled == "yes" ]; then
ps_locks_transactions "$d/$p-ps-locks-transactions"
fi
@@ -1261,22 +1252,20 @@ innodb_status() {
local innostat=""
if ! _should_skip "innodbstatus"; then
$CMD_MYSQL $EXT_ARGV -e "SHOW /*!40100 ENGINE*/ INNODB STATUS\G" \
>> "$d/$p-innodbstatus$n"
grep "END OF INNODB" "$d/$p-innodbstatus$n" >/dev/null || {
if [ -d /proc -a -d /proc/$mysqld_pid ]; then
for fd in /proc/$mysqld_pid/fd/*; do
file $fd | grep deleted >/dev/null && {
grep 'INNODB' $fd >/dev/null && {
cat $fd > "$d/$p-innodbstatus$n"
break
}
$CMD_MYSQL $EXT_ARGV -e "SHOW /*!40100 ENGINE*/ INNODB STATUS\G" \
>> "$d/$p-innodbstatus$n"
grep "END OF INNODB" "$d/$p-innodbstatus$n" >/dev/null || {
if [ -d /proc -a -d /proc/$mysqld_pid ]; then
for fd in /proc/$mysqld_pid/fd/*; do
file $fd | grep deleted >/dev/null && {
grep 'INNODB' $fd >/dev/null && {
cat $fd > "$d/$p-innodbstatus$n"
break
}
done
fi
}
fi
}
done
fi
}
}
rocksdb_status() {
@@ -1285,7 +1274,7 @@ rocksdb_status() {
has_rocksdb=`$CMD_MYSQL $EXT_ARGV -e "SHOW ENGINES" | grep -i 'rocksdb'`
exit_code=$?
if [ $exit_code -eq 0 ] && ! _should_skip "rocksdbstatus"; then
if [ $exit_code -eq 0 ]; then
$CMD_MYSQL $EXT_ARGV -e "SHOW ENGINE ROCKSDB STATUS\G" \
>> "$d/$p-rocksdbstatus$n" || rm -f "$d/$p-rocksdbstatus$n"
fi
@@ -1367,34 +1356,20 @@ collect_mysql_variables() {
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
if ! _should_skip "thread-variables"; then
sql="select * from performance_schema.variables_by_thread order by thread_id, variable_name;"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="select * from performance_schema.variables_by_thread order by thread_id, variable_name;"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="select * from performance_schema.user_variables_by_thread order by thread_id, variable_name;"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="select * from performance_schema.user_variables_by_thread order by thread_id, variable_name;"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="select * from performance_schema.status_by_thread order by thread_id, variable_name; "
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
fi
sql="select * from performance_schema.status_by_thread order by thread_id, variable_name; "
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
}
_should_skip() {
local name=$1
for item in "${OPT_SKIP_COLLECTION[@]}"; do
if [ "$item" == "$name" ]; then
return 0
fi
done
return 1
}
# ###########################################################################
# End collect package
# ###########################################################################
@@ -1549,7 +1524,7 @@ purge_samples() {
local retention_size="$4"
# Delete collect files which more than --retention-time days old.
if [ -n "${OPT_PREFIX:-}" ]; then
if [ -n "$OPT_PREFIX" ]; then
find "$dir" -maxdepth 1 -type f -mtime +$retention_time -name "$OPT_PREFIX-*" -exec rm -f '{}' \;
else
find "$dir" -maxdepth 1 -type f -mtime +$retention_time -regextype posix-egrep -regex "$dir/[0-9]{4}(_[0-9]{2}){5}-.*" -exec rm -f '{}' \;
@@ -1748,6 +1723,10 @@ stalk() {
main() {
trap sigtrap SIGHUP SIGINT SIGTERM
if [ "$OPT_SYSTEM_ONLY" ] && [ "$OPT_MYSQL_ONLY" ]; then
log 'Both options --system-only and --mysql-only specified, collecting only disk-space, hostname, output, and trigger metrics';
fi
# Note: $$ is the parent's PID, but we're a child proc.
# Bash 4 has $BASHPID but we can't rely on that. Consequently,
# we don't know our own PID. See the usage of $! below.
@@ -1791,10 +1770,6 @@ if [ "${0##*/}" = "$TOOL" ] \
mk_tmpdir
parse_options "$0" "${@:-""}"
if [ "$OPT_SYSTEM_ONLY" ] && [ "$OPT_MYSQL_ONLY" ]; then
log 'Both options --system-only and --mysql-only specified, collecting only disk-space, hostname, output, and trigger metrics';
fi
# Verify and set TRIGGER_FUNCTION based on --function.
if ! set_trg_func "$OPT_FUNCTION"; then
option_error "Invalid --function value: $OPT_FUNCTION"
@@ -1809,19 +1784,6 @@ if [ "${0##*/}" = "$TOOL" ] \
fi
fi
if [ "$OPT_SKIP_COLLECTION" ]; then
supported_skips=( "ps-locks-transactions" "thread-variables" "innodbstatus" "lock-waits" "mysqladmin" "processlist" "rocksdbstatus" "transactions" )
IFS=',' read -ra skips <<< "$OPT_SKIP_COLLECTION"
OPT_SKIP_COLLECTION=("${skips[@]}")
for skip in "${skips[@]}"; do
echo "$supported_skips" | grep -q "$skip"
if ! [[ " ${supported_skips[@]} " =~ " ${skip} " ]]; then
log "Invalid --skip-collection value: $skip, exiting."
exit 1
fi
done
fi
if [ -z "$OPT_STALK" -a "$OPT_COLLECT" ]; then
# Not stalking; do immediate collect once.
OPT_CYCLES=0
@@ -2429,12 +2391,6 @@ How long to sleep between collection loop cycles. This is useful with
C<--no-stalk> to do long collections. For example, to collect data every
minute for an hour, specify: C<--no-stalk --run-time 3600 --sleep-collect 60>.
=item --skip-collection
type: array
A comma-separated list of collection types to skip. Valid values are: C<"ps-locks-transactions,thread-variables,innodbstatus,lock-waits,mysqladmin,processlist,rocksdbstatus,transactions">.
=item --socket
short form: -S; type: string

4
go.mod
View File

@@ -33,7 +33,7 @@ require (
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.34.0
k8s.io/api v0.34.1
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
)
@@ -69,7 +69,7 @@ require (
golang.org/x/text v0.28.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apimachinery v0.34.0 // indirect
k8s.io/apimachinery v0.34.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect

8
go.sum
View File

@@ -205,10 +205,10 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.34.0 h1:L+JtP2wDbEYPUeNGbeSa/5GwFtIA662EmT2YSLOkAVE=
k8s.io/api v0.34.0/go.mod h1:YzgkIzOOlhl9uwWCZNqpw6RJy9L2FK4dlJeayUoydug=
k8s.io/apimachinery v0.34.0 h1:eR1WO5fo0HyoQZt1wdISpFDffnWOvFLOOeJ7MgIv4z0=
k8s.io/apimachinery v0.34.0/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw=
k8s.io/api v0.34.1 h1:jC+153630BMdlFukegoEL8E/yT7aLyQkIVuwhmwDgJM=
k8s.io/api v0.34.1/go.mod h1:SB80FxFtXn5/gwzCoN6QCtPD7Vbu5w2n1S0J5gFfTYk=
k8s.io/apimachinery v0.34.1 h1:dTlxFls/eikpJxmAC7MVE8oOeP1zryV7iRyIjB0gky4=
k8s.io/apimachinery v0.34.1/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 h1:hwvWFiBzdWw1FhfY1FooPn3kzWuJ8tmbZBHi4zVsl1Y=

View File

@@ -243,10 +243,8 @@ collect_mysql_data_one() {
# get and keep a connection to the database; in troubled times
# the database tends to exceed max_connections, so reconnecting
# in the loop tends not to work very well.
if ! _should_skip "mysqladmin"; then
$CMD_MYSQLADMIN $EXT_ARGV ext -i$OPT_SLEEP_COLLECT -c$cnt >>"$d/$p-mysqladmin" &
mysqladmin_pid=$!
fi
$CMD_MYSQLADMIN $EXT_ARGV ext -i$OPT_SLEEP_COLLECT -c$cnt >>"$d/$p-mysqladmin" &
mysqladmin_pid=$!
ps_instrumentation_enabled=$($CMD_MYSQL $EXT_ARGV -e 'SELECT ENABLED FROM performance_schema.setup_instruments WHERE NAME = "transaction";' \
| sed "2q;d" | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')
@@ -291,25 +289,18 @@ collect_mysql_data_loop() {
# SHOW FULL PROCESSLIST duplicates information in performance_schema.threads we collecting now
# Keeping it for backward compatibility and may remove in the future
if ! _should_skip "processlist"; then
(echo $ts; $CMD_MYSQL $EXT_ARGV -e "SHOW FULL PROCESSLIST\G") \
>> "$d/$p-processlist" &
fi
(echo $ts; $CMD_MYSQL $EXT_ARGV -e "SELECT * FROM performance_schema.threads\G") \
>> "$d/$p-threads" &
(echo $ts; $CMD_MYSQL $EXT_ARGV -e "SELECT * FROM performance_schema.threads\G") \
>> "$d/$p-threads" &
if [ "$have_lock_waits_table" ]; then
if ! _should_skip "lock-waits"; then
(echo $ts; lock_waits "$d/lock_waits.running") >>"$d/$p-lock-waits" &
fi
if ! _should_skip "transactions"; then
(echo $ts; transactions) >>"$d/$p-transactions" &
fi
(echo $ts; lock_waits "$d/lock_waits.running") >>"$d/$p-lock-waits" &
(echo $ts; transactions) >>"$d/$p-transactions" &
fi
if [ "${mysql_version}" '>' "5.6" ] && [ $ps_instrumentation_enabled == "yes" ] \
&& ! _should_skip "ps-locks-transactions"; then
if [ "${mysql_version}" '>' "5.6" ] && [ $ps_instrumentation_enabled == "yes" ]; then
ps_locks_transactions "$d/$p-ps-locks-transactions"
fi
@@ -547,22 +538,20 @@ innodb_status() {
local innostat=""
if ! _should_skip "innodbstatus"; then
$CMD_MYSQL $EXT_ARGV -e "SHOW /*!40100 ENGINE*/ INNODB STATUS\G" \
>> "$d/$p-innodbstatus$n"
grep "END OF INNODB" "$d/$p-innodbstatus$n" >/dev/null || {
if [ -d /proc -a -d /proc/$mysqld_pid ]; then
for fd in /proc/$mysqld_pid/fd/*; do
file $fd | grep deleted >/dev/null && {
grep 'INNODB' $fd >/dev/null && {
cat $fd > "$d/$p-innodbstatus$n"
break
}
$CMD_MYSQL $EXT_ARGV -e "SHOW /*!40100 ENGINE*/ INNODB STATUS\G" \
>> "$d/$p-innodbstatus$n"
grep "END OF INNODB" "$d/$p-innodbstatus$n" >/dev/null || {
if [ -d /proc -a -d /proc/$mysqld_pid ]; then
for fd in /proc/$mysqld_pid/fd/*; do
file $fd | grep deleted >/dev/null && {
grep 'INNODB' $fd >/dev/null && {
cat $fd > "$d/$p-innodbstatus$n"
break
}
done
fi
}
fi
}
done
fi
}
}
rocksdb_status() {
@@ -571,7 +560,7 @@ rocksdb_status() {
has_rocksdb=`$CMD_MYSQL $EXT_ARGV -e "SHOW ENGINES" | grep -i 'rocksdb'`
exit_code=$?
if [ $exit_code -eq 0 ] && ! _should_skip "rocksdbstatus"; then
if [ $exit_code -eq 0 ]; then
$CMD_MYSQL $EXT_ARGV -e "SHOW ENGINE ROCKSDB STATUS\G" \
>> "$d/$p-rocksdbstatus$n" || rm -f "$d/$p-rocksdbstatus$n"
fi
@@ -657,34 +646,20 @@ collect_mysql_variables() {
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
if ! _should_skip "thread-variables"; then
sql="select * from performance_schema.variables_by_thread order by thread_id, variable_name;"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="select * from performance_schema.variables_by_thread order by thread_id, variable_name;"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="select * from performance_schema.user_variables_by_thread order by thread_id, variable_name;"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="select * from performance_schema.user_variables_by_thread order by thread_id, variable_name;"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="select * from performance_schema.status_by_thread order by thread_id, variable_name; "
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
fi
sql="select * from performance_schema.status_by_thread order by thread_id, variable_name; "
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
}
_should_skip() {
local name=$1
for item in "${OPT_SKIP_COLLECTION[@]}"; do
if [ "$item" == "$name" ]; then
return 0
fi
done
return 1
}
# ###########################################################################
# End collect package
# ###########################################################################

View File

@@ -1,262 +0,0 @@
#!/usr/bin/env perl
BEGIN {
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};
use strict;
use warnings FATAL => 'all';
use threads;
use English qw(-no_match_vars);
use Test::More;
use Time::HiRes qw(sleep);
use PerconaTest;
use DSNParser;
use Sandbox;
require VersionParser;
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('source');
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox source';
}
my $cnf = "/tmp/12345/my.sandbox.cnf";
my $pid_file = "/tmp/pt-stalk.pid.$PID";
my $log_file = "/tmp/pt-stalk.log.$PID";
my $dest = "/tmp/pt-stalk.collect.$PID";
my $int_file = "/tmp/pt-stalk-after-interval-sleep";
my $pid;
my $output;
my $retval;
sub cleanup {
diag(`rm $pid_file $log_file $int_file 2>/dev/null`);
diag(`rm -rf $dest 2>/dev/null`);
}
# ###########################################################################
# Test that it collects all data when no --skip-collection is given.
# ###########################################################################
cleanup();
# We need these to collect lock-waits
sub start_thread_pt_1897_1 {
# this must run in a thread because we need to have an active session
# with open transaction
my ($dsn_opts) = @_;
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('source');
$sb->load_file('source', "t/pt-stalk/samples/PT-1897-1.sql");
}
my $thr1 = threads->create('start_thread_pt_1897_1', $dsn_opts);
$thr1->detach();
threads->yield();
sleep 1;
sub start_thread_pt_1897_2 {
# this must run in a thread because we need to have an active session
# with waiting transaction
my ($dsn_opts) = @_;
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('source');
$sb->load_file('source', "t/pt-stalk/samples/PT-1897-2.sql");
}
my $thr2 = threads->create('start_thread_pt_1897_2', $dsn_opts);
$thr2->detach();
threads->yield();
$retval = system("$trunk/bin/pt-stalk --no-stalk --pid $pid_file --log $log_file --dest $dest --iterations 1 -- --defaults-file=$cnf >$log_file 2>&1");
sleep 35;
PerconaTest::kill_program(pid_file => $pid_file);
is(
$retval >> 8,
0,
"Parent exit 0"
);
ok(
-d $dest,
"Creates --dest (collect) dir"
);
# ps-locks-transactions,thread-variables,innodbstatus,lock-waits,mysqladmin,processlist,rocksdbstatus,transactions
ok(
glob("$dest/*-ps-locks-transactions"),
"Collects *-ps-locks-transactions"
) or diag(`ls $dest`);
ok(
glob("$dest/*-innodbstatus*"),
"Collects *-innodbstatus*"
) or diag(`ls $dest`);
ok(
glob("$dest/*-lock-waits"),
"Collects *-lock-waits"
) or diag(`ls $dest`);
ok(
glob("$dest/*-mysqladmin"),
"Collects *-mysqladmin"
) or diag(`ls $dest`);
ok(
glob("$dest/*-processlist"),
"Collects *-processlist"
) or diag(`ls $dest`);
ok(
glob("$dest/*-transactions"),
"Collects *-transactions"
) or diag(`ls $dest`);
# thread-variables
ok(
glob("$dest/*-variables"),
"Collects *-variables"
) or diag(`ls $dest`);
$output = `cat $dest/*-variables 2>/dev/null`;
like(
$output,
qr/select \* from performance_schema\.variables_by_thread/,
"Thread variables collected"
); # or diag($output);
SKIP: {
skip "These tests require MyRocks", 1 if ( !$sb->has_engine('source', 'ROCKSDB') ) ;
# rocksdbstatus
ok(
glob("$dest/*-rocksdbstatus*"),
"Collects *-rocksdbstatus"
) or diag(`ls $dest`);
cleanup();
$retval = system("$trunk/bin/pt-stalk --no-stalk --pid $pid_file --log $log_file --dest $dest --iterations 1 --skip-collection rocksdbstatus -- --defaults-file=$cnf >$log_file 2>&1");
sleep 5;
PerconaTest::kill_program(pid_file => $pid_file);
ok(
! glob("$dest/*-rocksdbstatus*"),
"Does not collect *-rocksdbstatus"
) or diag(`ls $dest`);
}
cleanup();
$retval = system("$trunk/bin/pt-stalk --no-stalk --pid $pid_file --log $log_file --dest $dest --iterations 1 --skip-collection processlist -- --defaults-file=$cnf >$log_file 2>&1");
sleep 5;
PerconaTest::kill_program(pid_file => $pid_file);
ok(
! glob("$dest/*-processlist"),
"Does not collect *-processlist"
) or diag(`ls $dest`);
cleanup();
$retval = system("$trunk/bin/pt-stalk --no-stalk --pid $pid_file --log $log_file --dest $dest --iterations 1 --skip-collection ps-locks-transactions,thread-variables,innodbstatus,mysqladmin,processlist,transactions -- --defaults-file=$cnf >$log_file 2>&1");
sleep 5;
PerconaTest::kill_program(pid_file => $pid_file);
ok(
! glob("$dest/*-ps-locks-transactions"),
"Does not collect *-ps-locks-transactions"
) or diag(`ls $dest`);
ok(
glob("$dest/*-variables"),
"Collects *-variables"
) or diag(`ls $dest`);
$output = `cat $dest/*-variables 2>/dev/null`;
unlike(
$output,
qr/select \* from performance_schema\.variables_by_thread/,
"Thread variables not collected"
); # or diag($output);
ok(
! glob("$dest/*-innodbstatus"),
"Does not collect *-innodbstatus"
) or diag(`ls $dest`);
ok(
! glob("$dest/*-mysqladmin"),
"Does not collect *-mysqladmin"
) or diag(`ls $dest`);
ok(
! glob("$dest/*-processlist"),
"Does not collect *-processlist"
) or diag(`ls $dest`);
ok(
! glob("$dest/*-transactions"),
"Does not collect *-transactions"
) or diag(`ls $dest`);
#Unsupported skip-collection value
cleanup();
$retval = system("$trunk/bin/pt-stalk --no-stalk --pid $pid_file --log $log_file --dest $dest --iterations 1 --skip-collection ps-locks-transactions,thread-variables,innodbstatus,mysqladmin,processlist,transaction -- --defaults-file=$cnf >$log_file 2>&1");
sleep 5;
PerconaTest::kill_program(pid_file => $pid_file);
is(
$retval >> 8,
1,
"Parent exit 1 on unsupported --skip-collection value"
);
like(
`cat $log_file`,
qr/Invalid --skip-collection value: transaction, exiting./,
"Rejects unsupported --skip-collection value"
);
cleanup();
$retval = system("$trunk/bin/pt-stalk --no-stalk --pid $pid_file --log $log_file --dest $dest --iterations 1 --skip-collection 'mysqladmin and' -- --defaults-file=$cnf >$log_file 2>&1");
sleep 5;
PerconaTest::kill_program(pid_file => $pid_file);
is(
$retval >> 8,
1,
"Parent exit 1 on unsupported --skip-collection value"
);
like(
`cat $log_file`,
qr/Invalid --skip-collection value: mysqladmin and, exiting./,
"Rejects unsupported --skip-collection value"
);
# #############################################################################
# Done.
# #############################################################################
cleanup();
diag(`rm -rf $dest 2>/dev/null`);
$sb->wipe_clean($dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
done_testing;

View File

@@ -393,16 +393,18 @@ my $tempdir = tempdir( CLEANUP => 1 );
my $script = <<"EOT";
. $trunk/bin/pt-stalk
purge_samples $tempdir 10000 0 0 2>&1
purge_samples $tempdir 10000 2>&1
EOT
$output = `bash -c "$script"`;
$output = `$script`;
unlike(
$output,
qr/\Qfind: warning: you have specified the -depth option/,
"Bug 942114: no bad find usage"
);
# ###########################################################################
# Test that it handles floating point values
# ###########################################################################