提交 b5bc853d 编写于 作者: L Larry Hamel 提交者: Marbin Tan

gpperfmon: Add behave test for log_alert_history

Signed-off-by: NMarbin Tan <mtan@pivotal.io>
Signed-off-by: NC.J. Jameson <cjameson@pivotal.io>
上级 771854a7
......@@ -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
......
......@@ -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)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册