Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,8 @@ def storm_control_delete_entry(port_name, storm_type):


def _wait_until_clear(tables, interval=0.5, timeout=30, verbose=False):
if timeout == 0:
return True
start = time.time()
empty = False
app_db = SonicV2Connector(host='127.0.0.1')
Expand All @@ -793,6 +795,7 @@ 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 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
Loading