Skip to content

[show priority-group drop counters] Remove backup with cached PG drop counters after 'config reload' #1679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
5 changes: 5 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,11 @@ def reload(db, filename, yes, load_sysinfo, no_service_restart, disable_arp_cach
if multi_asic.is_multi_asic():
num_cfg_file += num_asic

# Remove cached PG drop counters data
dropstat_dir_prefix = '/tmp/dropstat'
command = "rm -rf {}-*".format(dropstat_dir_prefix)
clicommon.run_command(command, display_cmd=True)

# If the user give the filename[s], extract the file names.
if filename is not None:
cfg_files = filename.split(',')
Expand Down
15 changes: 15 additions & 0 deletions tests/pgdropstat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import show.main as show
import clear.main as clear
import config.main as config

from click.testing import CliRunner

Expand Down Expand Up @@ -62,6 +63,20 @@ def executor(self, clear_before_show):
assert result.exit_code == 0
assert result.output == show_output

def test_show_pg_drop_config_reload(self):
runner = CliRunner()
self.test_show_pg_drop_clear()

# simulate 'config reload' to provoke counters recalculation (remove backup from /tmp folder)
result = runner.invoke(config.config.commands["reload"], [ "--no_service_restart", "-y"])

print(result.exit_code)
print(result.output)

assert result.exit_code == 0

self.test_show_pg_drop_show()

@classmethod
def teardown_class(cls):
os.environ["PATH"] = os.pathsep.join(os.environ["PATH"].split(os.pathsep)[:-1])
Expand Down