Skip to content

Commit d6b8869

Browse files
authored
[Auto-Techsupport] Fix the coredump_gen_handler Exception when the History table is empty (#2265)
coredump_gen_handler script is throwing exception currently when the history table is empty. Fix this issue and add a UT Signed-off-by: Vivek Reddy Karri <[email protected]>
1 parent b41da8f commit d6b8869

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

tests/coredump_gen_handler_test.py

+20
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,23 @@ def mock_cmd(cmd, env):
449449
patcher.fs.create_file("/var/core/orchagent.12345.123.core.gz")
450450
cls = cdump_mod.CriticalProcCoreDumpHandle("orchagent.12345.123.core.gz", "swss", redis_mock)
451451
cls.handle_core_dump_creation_event()
452+
453+
def test_auto_ts_empty_state_db(self):
454+
"""
455+
Scenario: Check if the techsupport is called as expected even when the history table in empty
456+
and container cooloff is non-zero
457+
"""
458+
db_wrap = Db()
459+
redis_mock = db_wrap.db
460+
set_auto_ts_cfg(redis_mock, state="enabled", since_cfg="2 days ago")
461+
set_feature_table_cfg(redis_mock, state="enabled", rate_limit_interval="300")
462+
with Patcher() as patcher:
463+
def mock_cmd(cmd, env):
464+
cmd_str = " ".join(cmd)
465+
if "show techsupport" in cmd_str and cmd_str != TS_DEFAULT_CMD:
466+
assert False, "Expected TS_CMD: {}, Recieved: {}".format(TS_DEFAULT_CMD, cmd_str)
467+
return 0, AUTO_TS_STDOUT, ""
468+
ts_helper.subprocess_exec = mock_cmd
469+
patcher.fs.create_file("/var/core/orchagent.12345.123.core.gz")
470+
cls = cdump_mod.CriticalProcCoreDumpHandle("orchagent.12345.123.core.gz", "swss", redis_mock)
471+
cls.handle_core_dump_creation_event()

utilities_common/auto_techsupport_helper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def get_ts_map(db):
259259
ts_map = {}
260260
ts_keys = db.keys(STATE_DB, TS_MAP+"*")
261261
if not ts_keys:
262-
return
262+
return ts_map
263263
for ts_key in ts_keys:
264264
data = db.get_all(STATE_DB, ts_key)
265265
if not data:

0 commit comments

Comments
 (0)