diff --git a/gpMgmt/test/behave/mgmt_utils/gpperfmon.feature b/gpMgmt/test/behave/mgmt_utils/gpperfmon.feature index 8054508f205f28b86424a1f0b769a81e676aba27..d0bc7b2733ea8708772c9e86a914da49d261efa9 100644 --- a/gpMgmt/test/behave/mgmt_utils/gpperfmon.feature +++ b/gpMgmt/test/behave/mgmt_utils/gpperfmon.feature @@ -63,6 +63,16 @@ Feature: gpperfmon When the user truncates "system_history" tables in "gpperfmon" Then wait until the results from boolean sql "SELECT count(*) > 0 FROM system_history" is "true" + @gpperfmon_log_alert_history + Scenario: gpperfmon adds to log_alert_history table + Given gpperfmon is configured and running in qamode + When the user truncates "log_alert_history" tables in "gpperfmon" + And the user runs "psql non_existing_database" + Then psql should return a return code of 2 + When the latest gpperfmon gpdb-alert log is copied to a file with a fake (earlier) timestamp + Then wait until the results from boolean sql "SELECT count(*) > 0 FROM log_alert_history" is "true" + And the file with the fake timestamp no longer exists + @gpperfmon_segment_history Scenario: gpperfmon adds to segment_history table Given gpperfmon is configured and running in qamode diff --git a/gpMgmt/test/behave/mgmt_utils/steps/mgmt_utils.py b/gpMgmt/test/behave/mgmt_utils/steps/mgmt_utils.py index 6c8b452c9299010b03a0802097d12e0f189ab83e..11e9cba35fb008f797994172baf7d1a3ce10ed86 100644 --- a/gpMgmt/test/behave/mgmt_utils/steps/mgmt_utils.py +++ b/gpMgmt/test/behave/mgmt_utils/steps/mgmt_utils.py @@ -12,7 +12,6 @@ import tarfile import thread import json import csv -import glob import subprocess import commands @@ -4875,3 +4874,25 @@ def impl(context): Then wait until the process "gpmmon" is up And wait until the process "gpsmon" is up ''') + + +@given('the latest gpperfmon gpdb-alert log is copied to a file with a fake (earlier) timestamp') +@when('the latest gpperfmon gpdb-alert log is copied to a file with a fake (earlier) timestamp') +def impl(context): + gpdb_alert_file_path_src = sorted(glob.glob(os.path.join(os.getenv("MASTER_DATA_DIRECTORY"), + "gpperfmon", + "logs", + "gpdb-alert*")))[-1] + # typical filename would be gpdb-alert-2017-04-26_155335.csv + # setting the timestamp to a string that starts with `-` (em-dash) + # will be sorted (based on ascii) before numeric timestamps + # without colliding with a real timestamp + dest = re.sub(r"_\d{6}\.csv$", "_-takeme.csv", gpdb_alert_file_path_src) + shutil.copy(gpdb_alert_file_path_src, dest) + context.fake_timestamp_file = dest + + +@then('the file with the fake timestamp no longer exists') +def impl(context): + if os.path.exists(context.fake_timestamp_file): + raise Exception("expected no file at: %s" % context.fake_timestamp_file)