Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,8 @@ def _wait_until_clear(tables, interval=0.5, timeout=30, verbose=False):
click.echo("Some entries matching {} still exist: {}".format(table, keys[0]))
time.sleep(interval)
empty = (non_empty_table_count == 0)
if timeout == 0:
empty = True
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code looks a little wired. How about checking the value of timeout and return True directly at the beginning of the function of _wait_until_clear? Or just skip calling this function _wait_until_clear when timeout == 0?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, Please check

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bingwang-ms Can we signoff this PR?

if not empty:
click.echo("Operation not completed successfully, please save and reload configuration.")
return empty
Expand Down
8 changes: 8 additions & 0 deletions tests/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,14 @@ def test_qos_wait_until_clear_not_empty(self):
empty = _wait_until_clear(["BUFFER_POOL_TABLE:*"], 0.5,2)
assert not empty

@patch('click.echo')
@patch('swsscommon.swsscommon.SonicV2Connector.keys')
def test_qos_wait_until_clear_no_timeout(self, mock_keys, mock_echo):
from config.main import _wait_until_clear
assert _wait_until_clear(["BUFFER_POOL_TABLE:*"], 0.5, 0)
mock_keys.assert_not_called()
mock_echo.assert_not_called()

@mock.patch('config.main._wait_until_clear')
def test_qos_clear_no_wait(self, _wait_until_clear):
from config.main import _clear_qos
Expand Down