@@ -223,6 +223,30 @@ def test_get_messages_imc_acc_command_level_error_service_name(self, dmesg):
223223 'dmesg | grep -v "Step" | grep -iE "error|fail" | grep \' ix1\' ' , shell = True , expected_return_codes = {0 , 1 }
224224 )
225225
226+ def test_get_messages_imc_acc_command_level_warning (self , dmesg ):
227+ dmesg ._connection .execute_command .side_effect = [
228+ ConnectionCalledProcessError (returncode = 0 , cmd = "" ),
229+ ConnectionCompletedProcess (return_code = 0 , args = "command" , stdout = "" , stderr = "stderr" ),
230+ ]
231+ dmesg .get_messages (level = DmesgLevelOptions .WARNINGS )
232+ dmesg ._connection .execute_command .assert_called_with (
233+ 'dmesg | grep -v "Step" | grep -iE "warning" ' ,
234+ shell = True ,
235+ expected_return_codes = {0 , 1 },
236+ )
237+
238+ def test_get_messages_imc_acc_command_level_critical (self , dmesg ):
239+ dmesg ._connection .execute_command .side_effect = [
240+ ConnectionCalledProcessError (returncode = 0 , cmd = "" ),
241+ ConnectionCompletedProcess (return_code = 0 , args = "command" , stdout = "" , stderr = "stderr" ),
242+ ]
243+ dmesg .get_messages (level = DmesgLevelOptions .CRITICAL )
244+ dmesg ._connection .execute_command .assert_called_with (
245+ "dmesg | grep -v \" Step\" | grep crit " ,
246+ shell = True ,
247+ expected_return_codes = {0 , 1 },
248+ )
249+
226250 def test_get_messages_without_level (self , dmesg ):
227251 output = dedent (
228252 """
@@ -267,6 +291,28 @@ def test_get_messages_additional(self, dmesg):
267291 )
268292 assert expected == dmesg .get_messages_additional ()
269293
294+ def test_get_messages_additional_command_check (self , dmesg ):
295+ """
296+ Test to verify that correct command is executed.
297+
298+ when getting additional messages with service name and without level filtering.
299+ """
300+ output = dedent (
301+ """
302+ [15197896.276724] IPv6: ens785: IPv6 duplicate address 24:1:1::1
303+ used by aa:bb:cc:dd:ee:ff detected!
304+ [15222488.275756] ice 0000:4e:00.0 ens786: NIC Link is Down
305+ [15222488.308184] ice 0000:4b:00.0 ens785: NIC Link is Down
306+ [15222506.769174] ice 0000:4e:00.0 ens786: A parallel fault was detected."""
307+ )
308+ dmesg ._connection .execute_command .return_value = ConnectionCompletedProcess (
309+ return_code = 0 , args = "command" , stdout = output , stderr = "stderr"
310+ )
311+ dmesg .get_messages_additional (lines = 5 , service_name = "ice" )
312+ dmesg ._connection .execute_command .assert_called_with (
313+ f"{ dmesg ._tool_exec } | tail -n 5 | grep 'ice'" , shell = True , expected_return_codes = {0 }
314+ )
315+
270316 def test_verify_messages (self , dmesg ):
271317 output = dedent (
272318 """
0 commit comments