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