diff --git a/bin/pt-archiver b/bin/pt-archiver index 06a59e9f..1f88f553 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -4593,17 +4593,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -4617,13 +4619,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -5293,7 +5296,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($src->{dbh}); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ######################################################################## diff --git a/bin/pt-config-diff b/bin/pt-config-diff index 23a2d818..511cde7d 100755 --- a/bin/pt-config-diff +++ b/bin/pt-config-diff @@ -3695,17 +3695,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -3719,13 +3721,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -3977,7 +3980,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($configs[0]->{dbh}); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ######################################################################### diff --git a/bin/pt-deadlock-logger b/bin/pt-deadlock-logger index db6e6e5c..f77661da 100755 --- a/bin/pt-deadlock-logger +++ b/bin/pt-deadlock-logger @@ -3152,17 +3152,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -3176,13 +3178,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -3502,7 +3505,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($dbh); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ######################################################################## diff --git a/bin/pt-diskstats b/bin/pt-diskstats index 3c7bb90f..907d8bf8 100755 --- a/bin/pt-diskstats +++ b/bin/pt-diskstats @@ -4265,17 +4265,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -4289,13 +4291,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -4484,7 +4487,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check(); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ######################################################################## diff --git a/bin/pt-duplicate-key-checker b/bin/pt-duplicate-key-checker index dbf9bcca..2253b7f7 100755 --- a/bin/pt-duplicate-key-checker +++ b/bin/pt-duplicate-key-checker @@ -4109,17 +4109,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -4133,13 +4135,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -4355,7 +4358,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($dbh); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ####################################################################### diff --git a/bin/pt-find b/bin/pt-find index c9c32daa..b9469569 100755 --- a/bin/pt-find +++ b/bin/pt-find @@ -2949,17 +2949,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -2973,13 +2975,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -3523,7 +3526,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($dbh); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ######################################################################## diff --git a/bin/pt-fk-error-logger b/bin/pt-fk-error-logger index 0c472475..36d5ca84 100755 --- a/bin/pt-fk-error-logger +++ b/bin/pt-fk-error-logger @@ -2856,17 +2856,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -2880,13 +2882,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -3147,7 +3150,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($dbh); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ######################################################################## diff --git a/bin/pt-heartbeat b/bin/pt-heartbeat index 8d1d44d3..98c81163 100755 --- a/bin/pt-heartbeat +++ b/bin/pt-heartbeat @@ -4033,17 +4033,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -4057,13 +4059,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -4643,7 +4646,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($dbh); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ######################################################################## diff --git a/bin/pt-index-usage b/bin/pt-index-usage index 20fef382..9f812960 100755 --- a/bin/pt-index-usage +++ b/bin/pt-index-usage @@ -5616,17 +5616,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -5640,13 +5642,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -5986,7 +5989,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($dbh); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ######################################################################## diff --git a/bin/pt-kill b/bin/pt-kill index 070ff178..9626e1af 100755 --- a/bin/pt-kill +++ b/bin/pt-kill @@ -5613,17 +5613,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -5637,13 +5639,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -6135,7 +6138,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($dbh); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ######################################################################## diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index d0523972..76289af7 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -6635,17 +6635,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -6659,13 +6661,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -7029,7 +7032,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($cxn->dbh()); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ######################################################################## diff --git a/bin/pt-query-advisor b/bin/pt-query-advisor index a51b0d20..140d0a53 100755 --- a/bin/pt-query-advisor +++ b/bin/pt-query-advisor @@ -6798,17 +6798,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -6822,13 +6824,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -7362,7 +7365,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($dbh); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ######################################################################### diff --git a/bin/pt-query-digest b/bin/pt-query-digest index 3bb37b69..07a59afd 100755 --- a/bin/pt-query-digest +++ b/bin/pt-query-digest @@ -12647,17 +12647,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -12671,13 +12673,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -14160,7 +14163,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($qv_dbh || $ps_dbh || $ex_dbh); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ########################################################################## diff --git a/bin/pt-slave-delay b/bin/pt-slave-delay index 38a29aef..cd319dd0 100755 --- a/bin/pt-slave-delay +++ b/bin/pt-slave-delay @@ -3266,17 +3266,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -3290,13 +3292,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -3541,7 +3544,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($slave_dbh); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # If the I/O thread isn't running when the program starts, diff --git a/bin/pt-slave-restart b/bin/pt-slave-restart index 88e731d0..c543e6a6 100755 --- a/bin/pt-slave-restart +++ b/bin/pt-slave-restart @@ -3888,17 +3888,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -3912,13 +3914,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -4185,7 +4188,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($dbh); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ######################################################################## diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index 4325d6b6..7e78d9a2 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -817,17 +817,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -841,13 +843,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -8033,7 +8036,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($master_dbh); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ######################################################################## diff --git a/bin/pt-table-sync b/bin/pt-table-sync index e0a5effc..53aa432e 100755 --- a/bin/pt-table-sync +++ b/bin/pt-table-sync @@ -9037,17 +9037,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -9061,13 +9063,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -9436,7 +9439,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($dsns[0]->{dbh}); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ######################################################################## diff --git a/bin/pt-upgrade b/bin/pt-upgrade index 2fe29ff4..d2d032f9 100755 --- a/bin/pt-upgrade +++ b/bin/pt-upgrade @@ -11090,17 +11090,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -11114,13 +11116,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -11603,7 +11606,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($hosts->[0]->{dbh}); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ######################################################################## diff --git a/bin/pt-variable-advisor b/bin/pt-variable-advisor index 801349ee..6a5ab963 100755 --- a/bin/pt-variable-advisor +++ b/bin/pt-variable-advisor @@ -4178,17 +4178,19 @@ eval { sub version_check { eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -4202,13 +4204,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; @@ -4467,7 +4470,6 @@ sub main { # ######################################################################## if ( $o->get('version-check') && ($o->has('quiet') && !$o->get('quiet')) ) { Pingback::version_check($dbh); - return 0 if $ENV{PTVCDEBUG} && PTDEBUG; } # ######################################################################### diff --git a/lib/Pingback.pm b/lib/Pingback.pm index afc6672e..4638ec19 100644 --- a/lib/Pingback.pm +++ b/lib/Pingback.pm @@ -58,17 +58,19 @@ sub version_check { # get in the way of the tool's real work. eval { if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) { - PTDEBUG && _d('--version-check is disabled by PERCONA_VERSION_CHECK'); - $ENV{PTVCDEBUG} && _d('--version-check is disabled by the', - 'PERCONA_VERSION_CHECK environment variable'); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('--version-check is disabled by the PERCONA_VERSION_CHECK', + 'environment variable'); + } return; } if ( !time_to_check($check_time_file) ) { - PTDEBUG && _d('Not time to do --version-check'); - $ENV{PTVCDEBUG} && _d('It is not time to --version-checka again;', - 'only 1 check per', $check_time_limit, 'seconds, and the last', - 'check was performed on the modified time of', $check_time_file); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('It is not time to --version-checka again;', + 'only 1 check per', $check_time_limit, 'seconds, and the last', + 'check was performed on the modified time of', $check_time_file); + } return; } @@ -82,13 +84,14 @@ sub version_check { print join("\n", map { "# * $_" } @$advice); print "\n# Specify --no-version-check to disable these suggestions.\n\n"; } - elsif ( $ENV{PTVCDEBUG} ) { + elsif ( $ENV{PTVCDEBUG} || PTDEBUG ) { _d('--version-check worked, but there were no suggestions'); } }; if ( $EVAL_ERROR ) { - PTDEBUG && _d('Error doing --version-check:', $EVAL_ERROR); - $ENV{PTVCDEBUG} && _d('Error doing --version-check:', $EVAL_ERROR); + if ( $ENV{PTVCDEBUG} || PTDEBUG ) { + _d('Error doing --version-check:', $EVAL_ERROR); + } } return; diff --git a/t/pt-archiver/version_check.t b/t/pt-archiver/version_check.t new file mode 100644 index 00000000..c9124087 --- /dev/null +++ b/t/pt-archiver/version_check.t @@ -0,0 +1,143 @@ +#!/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 English qw(-no_match_vars); +use Test::More; + +use PerconaTest; +use Sandbox; +use Data::Dumper; +use File::Spec; +use Time::HiRes qw(time); +require "$trunk/bin/pt-archiver"; + +# PerconaTest.pm sets this because normal tests shouldn't v-c. +delete $ENV{PERCONA_VERSION_CHECK}; + +my $dp = new DSNParser(opts=>$dsn_opts); +my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp); +my $master_dbh = $sb->get_dbh_for('master'); + +if ( !$master_dbh ) { + plan skip_all => 'Cannot connect to sandbox master'; +} + +my $rows; +my $output; +my $cnf = "/tmp/12345/my.sandbox.cnf"; +my $cmd = "$trunk/bin/pt-archiver"; +my @args = qw(--dry-run --where 1=1); + +# Pingback.pm does this too. +my $dir = File::Spec->tmpdir(); +my $check_time_file = File::Spec->catfile($dir,'percona-toolkit-version-check'); +unlink $check_time_file if -f $check_time_file; + +$sb->create_dbs($master_dbh, ['test']); +$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql'); + +$output = `PTVCDEBUG=1 $cmd --source F=$cnf,D=test,t=table_1 --where 1=1 --purge 2>&1`; + +like( + $output, + qr/(?:VersionCheck|Pingback|Percona suggests)/, + "Looks like the version-check happened" +) or diag($output); + +$rows = $master_dbh->selectall_arrayref("SELECT * FROM test.table_1"); +is_deeply( + $rows, + [], + "Tool ran after version-check" +) or diag(Dumper($rows)); + +ok( + -f $check_time_file, + "Created percona-toolkit-version-check file" +); + +# ########################################################################### +# v-c file should limit checks to 1 per 24 hours +# ########################################################################### + +$output = `PTVCDEBUG=1 $cmd --source F=$cnf,D=test,t=table_1 --where 1=1 --purge 2>&1`; + +like( + $output, + qr/It is not time to --version-checka again/, + "Doesn't always check because of time limit" +); + +unlink $check_time_file if -f $check_time_file; + +# ########################################################################### +# Fake v.percona.com not responding by using a different, non-existent URL. +# ########################################################################### + +my $t0 = time; + +$output = `PTVCDEBUG=1 PERCONA_VERSION_CHECK_URL='http://x.percona.com' $cmd --source F=$cnf,D=test,t=table_1 --where 1=1 --purge 2>&1`; + +my $t = time - $t0; + +like( + $output, + qr/Error.+?GET http:\/\/x\.percona\.com.+?HTTP status 5\d+/, + "The Percona server didn't respond" +); + +# In actuality it should only wait 2s, but on slow boxes all the other +# stuff the tool does may cause the time to be much greater than 2. +# If nothing else, this tests that the timeout isn't something crazy +# like 30s. +cmp_ok( + $t, + '<', + 6, + "Tool waited a short while for the Percona server to respond" +); + +# ########################################################################### +# Disable the v-c. +# ########################################################################### + +unlink $check_time_file if -f $check_time_file; + +$output = `PTVCDEBUG=1 $cmd --source F=$cnf,D=test,t=table_1 --where 1=1 --purge --no-version-check 2>&1`; + +unlike( + $output, + qr/(?:VersionCheck|Pingback|Percona suggests)/, + "Looks like --no-version-check disabled the version-check" +) or diag($output); + +ok( + !-f $check_time_file, + "percona-toolkit-version-check file not created with --no-version-check" +); + +# PERCONA_VERSION_CHECK=0 is handled in Pingback, so it will print a line +# for PTVCDEBUG saying why it didn't run. So we just check that it doesn't +# create the file which also signifies that it didn't run. +$output = `PTVCDEBUG=1 PERCONA_VERSION_CHECK=0 $cmd --source F=$cnf,D=test,t=table_1 --where 1=1 --purge 2>&1`; + +ok( + !-f $check_time_file, + "Looks like PERCONA_VERSION_CHECK=0 disabled the version-check" +); + +# ############################################################################# +# Done. +# ############################################################################# +unlink $check_time_file if -f $check_time_file; +$sb->wipe_clean($master_dbh); +ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); +done_testing; +exit;