diff --git a/config/main.py b/config/main.py index 937933f85255..471a8f920a55 100644 --- a/config/main.py +++ b/config/main.py @@ -1253,6 +1253,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(',') diff --git a/tests/pgdropstat_test.py b/tests/pgdropstat_test.py index e896ded81174..ee156b7588e7 100644 --- a/tests/pgdropstat_test.py +++ b/tests/pgdropstat_test.py @@ -3,6 +3,7 @@ import show.main as show import clear.main as clear +import config.main as config from click.testing import CliRunner @@ -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])