|
115 | 115 | Reloading Monit configuration ...
|
116 | 116 | """
|
117 | 117 |
|
118 |
| -reload_config_with_untriggered_timer_output="""\ |
119 |
| -Relevant services are not up. Retry later or use -f to avoid system checks |
120 |
| -""" |
121 |
| - |
122 | 118 | def mock_run_command_side_effect(*args, **kwargs):
|
123 | 119 | command = args[0]
|
124 | 120 |
|
@@ -155,41 +151,6 @@ def mock_run_command_side_effect_disabled_timer(*args, **kwargs):
|
155 | 151 | else:
|
156 | 152 | return '', 0
|
157 | 153 |
|
158 |
| -def mock_run_command_side_effect_untriggered_timer(*args, **kwargs): |
159 |
| - command = args[0] |
160 |
| - |
161 |
| - if kwargs.get('display_cmd'): |
162 |
| - click.echo(click.style("Running command: ", fg='cyan') + click.style(command, fg='green')) |
163 |
| - |
164 |
| - if kwargs.get('return_cmd'): |
165 |
| - if command == "systemctl list-dependencies --plain sonic-delayed.target | sed '1d'": |
166 |
| - return 'snmp.timer', 0 |
167 |
| - elif command == "systemctl list-dependencies --plain sonic.target | sed '1d'": |
168 |
| - return 'swss', 0 |
169 |
| - elif command == "systemctl is-enabled snmp.timer": |
170 |
| - return 'enabled', 0 |
171 |
| - elif command == "systemctl show snmp.timer --property=LastTriggerUSecMonotonic --value": |
172 |
| - return '0', 0 |
173 |
| - else: |
174 |
| - return '', 0 |
175 |
| - |
176 |
| -def mock_run_command_side_effect_gnmi(*args, **kwargs): |
177 |
| - command = args[0] |
178 |
| - |
179 |
| - if kwargs.get('display_cmd'): |
180 |
| - click.echo(click.style("Running command: ", fg='cyan') + click.style(command, fg='green')) |
181 |
| - |
182 |
| - if kwargs.get('return_cmd'): |
183 |
| - if command == "systemctl list-dependencies --plain sonic-delayed.target | sed '1d'": |
184 |
| - return 'gnmi.timer', 0 |
185 |
| - elif command == "systemctl list-dependencies --plain sonic.target | sed '1d'": |
186 |
| - return 'swss', 0 |
187 |
| - elif command == "systemctl is-enabled gnmi.timer": |
188 |
| - return 'enabled', 0 |
189 |
| - else: |
190 |
| - return '', 0 |
191 |
| - |
192 |
| - |
193 | 154 | # Load sonic-cfggen from source since /usr/local/bin/sonic-cfggen does not have .py extension.
|
194 | 155 | sonic_cfggen = load_module_from_source('sonic_cfggen', '/usr/local/bin/sonic-cfggen')
|
195 | 156 |
|
@@ -235,32 +196,6 @@ def test_config_reload(self, get_cmd_module, setup_single_broadcom_asic):
|
235 | 196 |
|
236 | 197 | assert "\n".join([l.rstrip() for l in result.output.split('\n')][:1]) == reload_config_with_sys_info_command_output
|
237 | 198 |
|
238 |
| - def test_config_reload_untriggered_timer(self, get_cmd_module, setup_single_broadcom_asic): |
239 |
| - with mock.patch("utilities_common.cli.run_command", mock.MagicMock(side_effect=mock_run_command_side_effect_untriggered_timer)) as mock_run_command: |
240 |
| - (config, show) = get_cmd_module |
241 |
| - |
242 |
| - jsonfile_config = os.path.join(mock_db_path, "config_db.json") |
243 |
| - jsonfile_init_cfg = os.path.join(mock_db_path, "init_cfg.json") |
244 |
| - |
245 |
| - # create object |
246 |
| - config.INIT_CFG_FILE = jsonfile_init_cfg |
247 |
| - config.DEFAULT_CONFIG_DB_FILE = jsonfile_config |
248 |
| - |
249 |
| - db = Db() |
250 |
| - runner = CliRunner() |
251 |
| - obj = {'config_db': db.cfgdb} |
252 |
| - |
253 |
| - # simulate 'config reload' to provoke load_sys_info option |
254 |
| - result = runner.invoke(config.config.commands["reload"], ["-l", "-y"], obj=obj) |
255 |
| - |
256 |
| - print(result.exit_code) |
257 |
| - print(result.output) |
258 |
| - traceback.print_tb(result.exc_info[2]) |
259 |
| - |
260 |
| - assert result.exit_code == 1 |
261 |
| - |
262 |
| - assert "\n".join([l.rstrip() for l in result.output.split('\n')][:2]) == reload_config_with_untriggered_timer_output |
263 |
| - |
264 | 199 | @classmethod
|
265 | 200 | def teardown_class(cls):
|
266 | 201 | print("TEARDOWN")
|
@@ -293,25 +228,7 @@ def test_load_minigraph(self, get_cmd_module, setup_single_broadcom_asic):
|
293 | 228 | assert "\n".join([l.rstrip() for l in result.output.split('\n')]) == load_minigraph_command_output
|
294 | 229 | # Verify "systemctl reset-failed" is called for services under sonic.target
|
295 | 230 | mock_run_command.assert_any_call('systemctl reset-failed swss')
|
296 |
| - # Verify "systemctl reset-failed" is called for services under sonic-delayed.target |
297 |
| - mock_run_command.assert_any_call('systemctl reset-failed snmp') |
298 |
| - assert mock_run_command.call_count == 11 |
299 |
| - |
300 |
| - def test_load_minigraph_with_gnmi_timer(self, get_cmd_module, setup_single_broadcom_asic): |
301 |
| - with mock.patch("utilities_common.cli.run_command", mock.MagicMock(side_effect=mock_run_command_side_effect_gnmi)) as mock_run_command: |
302 |
| - (config, show) = get_cmd_module |
303 |
| - runner = CliRunner() |
304 |
| - result = runner.invoke(config.config.commands["load_minigraph"], ["-y"]) |
305 |
| - print(result.exit_code) |
306 |
| - print(result.output) |
307 |
| - traceback.print_tb(result.exc_info[2]) |
308 |
| - assert result.exit_code == 0 |
309 |
| - assert "\n".join([l.rstrip() for l in result.output.split('\n')]) == load_minigraph_command_output |
310 |
| - # Verify "systemctl reset-failed" is called for services under sonic.target |
311 |
| - mock_run_command.assert_any_call('systemctl reset-failed swss') |
312 |
| - # Verify "systemctl reset-failed" is called for services under sonic-delayed.target |
313 |
| - mock_run_command.assert_any_call('systemctl reset-failed gnmi') |
314 |
| - assert mock_run_command.call_count == 11 |
| 231 | + assert mock_run_command.call_count == 8 |
315 | 232 |
|
316 | 233 | def test_load_minigraph_with_port_config_bad_format(self, get_cmd_module, setup_single_broadcom_asic):
|
317 | 234 | with mock.patch(
|
|
0 commit comments