mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-25 21:54:48 +00:00
Merge fix-deleting-empty-files-bug-1047701
This commit is contained in:
10
bin/pt-stalk
10
bin/pt-stalk
@@ -862,6 +862,16 @@ collect() {
|
||||
|
||||
hostname > "$d/$p-hostname"
|
||||
|
||||
local slept=0
|
||||
while [ -n "$(jobs)" -a $slept -lt $OPT_RUN_TIME ]; do
|
||||
sleep 1
|
||||
slept=$((slept + 1))
|
||||
done
|
||||
|
||||
for pid in $(jobs -p); do
|
||||
kill $pid >/dev/null 2>&1
|
||||
done
|
||||
|
||||
for file in "$d/$p-"*; do
|
||||
if [ -z "$(grep -v '^TS ' --max-count 1 "$file")" ]; then
|
||||
log "Removing empty file $file";
|
||||
|
@@ -286,7 +286,19 @@ collect() {
|
||||
|
||||
# Remove "empty" files, i.e. ones that are truly empty or
|
||||
# just contain timestamp lines. When a command above fails,
|
||||
# it may leave an empty file.
|
||||
# it may leave an empty file. But first wait another --run-time
|
||||
# seconds for any slow process to finish:
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1047701
|
||||
local slept=0
|
||||
while [ -n "$(jobs)" -a $slept -lt $OPT_RUN_TIME ]; do
|
||||
sleep 1
|
||||
slept=$((slept + 1))
|
||||
done
|
||||
|
||||
for pid in $(jobs -p); do
|
||||
kill $pid >/dev/null 2>&1
|
||||
done
|
||||
|
||||
for file in "$d/$p-"*; do
|
||||
# If there's not at least 1 line that's not a TS,
|
||||
# then the file is empty.
|
||||
|
@@ -59,6 +59,15 @@ export PERCONA_TOOLKIT_SANDBOX="$MYSQL_BASE_DIR"
|
||||
export PATH="$PATH:/usr/sbin:$MYSQL_BASE_DIR/bin"
|
||||
export LANG="en_US.UTF-8"
|
||||
|
||||
# ######################################### #
|
||||
# Remove conf files that's shouldn't exist. #
|
||||
# ######################################### #
|
||||
rm -rf /tmp/pt-* || true
|
||||
rm -rf /tmp/pt_* || true
|
||||
rm -rf /tmp/percona* || true
|
||||
rm ~/.pt-*conf* || true
|
||||
rm ~/.my* || true
|
||||
|
||||
#############################
|
||||
# Check and start test env. #
|
||||
#############################
|
||||
|
@@ -149,9 +149,9 @@ like(
|
||||
# the samples may not be precisely 1 second apart.
|
||||
chomp($output = `cat $dest/*-df | grep -c '^TS'`);
|
||||
ok(
|
||||
$output >= 1 && $output <= 2,
|
||||
$output >= 1 && $output <= 3,
|
||||
"Collect ran for --run-time"
|
||||
);
|
||||
) or diag("Run time: $output");
|
||||
|
||||
ok(
|
||||
PerconaTest::not_running("pt-stalk --iterations 1"),
|
||||
|
Reference in New Issue
Block a user