Skip to content

Commit

Permalink
fix to validate all db device keys are populated after pcied restart (#…
Browse files Browse the repository at this point in the history
…5541)

pcied fix to validate all db device keys

Co-authored-by: rraguraj <[email protected]>
  • Loading branch information
rraguraj and rraguraj authored May 13, 2022
1 parent b2cc638 commit 1193c99
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/platform_tests/daemon/test_pcied.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,15 @@ def collect_data(duthost):
dev_summary_status = duthost.get_pmon_daemon_db_value(pcie_devices_status_tbl_key, status_field)
return {'status': dev_summary_status, 'devices': dev_data}

def wait_data(duthost):
def wait_data(duthost, expected_key_count):
class shared_scope:
data_after_restart = {}
def _collect_data():
shared_scope.data_after_restart = collect_data(duthost)
return bool(shared_scope.data_after_restart['devices'])
device_keys_found = len(shared_scope.data_after_restart['devices'])
if device_keys_found != 0:
logger.info("Expected PCIE device keys :{}, Current device key count {}".format(expected_key_count, device_keys_found))
return device_keys_found == expected_key_count
pcied_pooling_interval = 60
wait_until(pcied_pooling_interval, 6, 0, _collect_data)
return shared_scope.data_after_restart
Expand Down Expand Up @@ -160,7 +163,7 @@ def test_pmon_pcied_stop_and_start_status(check_daemon_status, duthosts, rand_on
pytest_assert(post_daemon_pid > pre_daemon_pid,
"Restarted {} pid should be bigger than {} but it is {}".format(daemon_name, pre_daemon_pid, post_daemon_pid))

data_after_restart = wait_data(duthost)
data_after_restart = wait_data(duthost, len(data_before_restart['devices']))
pytest_assert(data_after_restart == data_before_restart, 'DB data present before and after restart does not match')


Expand Down Expand Up @@ -190,7 +193,7 @@ def test_pmon_pcied_term_and_start_status(check_daemon_status, duthosts, rand_on
"{} expected pid is -1 but is {}".format(daemon_name, post_daemon_pid))
pytest_assert(post_daemon_pid > pre_daemon_pid,
"Restarted {} pid should be bigger than {} but it is {}".format(daemon_name, pre_daemon_pid, post_daemon_pid))
data_after_restart = wait_data(duthost)
data_after_restart = wait_data(duthost, len(data_before_restart['devices']))
pytest_assert(data_after_restart == data_before_restart, 'DB data present before and after restart does not match')


Expand All @@ -217,5 +220,5 @@ def test_pmon_pcied_kill_and_start_status(check_daemon_status, duthosts, rand_on
"{} expected pid is -1 but is {}".format(daemon_name, post_daemon_pid))
pytest_assert(post_daemon_pid > pre_daemon_pid,
"Restarted {} pid should be bigger than {} but it is {}".format(daemon_name, pre_daemon_pid, post_daemon_pid))
data_after_restart = wait_data(duthost)
data_after_restart = wait_data(duthost, len(data_before_restart['devices']))
pytest_assert(data_after_restart == data_before_restart, 'DB data present before and after restart does not match')

0 comments on commit 1193c99

Please sign in to comment.