File tree Expand file tree Collapse file tree 2 files changed +6
-12
lines changed
tests/pytests/unit/grains Expand file tree Collapse file tree 2 files changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -2095,9 +2095,9 @@ def _lookup_fqdn(ip):
20952095 # No FQDN for this IP address, so we don't need to know this all the time.
20962096 log .debug ("Unable to resolve address %s: %s" , ip , err )
20972097 else :
2098- log .error (err_message , err )
2098+ log .error ("Failed to resolve address %s: %s" , ip , err )
20992099 except (OSError , socket .gaierror , socket .timeout ) as err :
2100- log .error (err_message , err )
2100+ log .error ("Failed to resolve address %s: %s" , ip , err )
21012101
21022102 start = time .time ()
21032103
@@ -2109,7 +2109,6 @@ def _lookup_fqdn(ip):
21092109 include_loopback = False , interface_data = salt .utils .network ._get_interfaces ()
21102110 )
21112111 )
2112- err_message = "Exception during resolving address: %s"
21132112
21142113 # Create a ThreadPool to process the underlying calls to 'socket.gethostbyaddr' in parallel.
21152114 # This avoid blocking the execution when the "fqdn" is not defined for certains IP addresses, which was causing
Original file line number Diff line number Diff line change @@ -1878,7 +1878,7 @@ def test_fqdns_return():
18781878
18791879
18801880@pytest .mark .skip_unless_on_linux
1881- def test_fqdns_socket_error ():
1881+ def test_fqdns_socket_error (caplog ):
18821882 """
18831883 test the behavior on non-critical socket errors of the dns grain
18841884 """
@@ -1907,17 +1907,12 @@ def _gethostbyaddr(_):
19071907 mock_log .debug .assert_called ()
19081908 mock_log .error .assert_not_called ()
19091909
1910- mock_log = MagicMock ( )
1910+ caplog . set_level ( logging . WARNING )
19111911 with patch .dict (
19121912 core .__salt__ , {"network.fqdns" : salt .modules .network .fqdns }
1913- ), patch .object (
1914- socket , "gethostbyaddr" , side_effect = _gen_gethostbyaddr (- 1 )
1915- ), patch (
1916- "salt.modules.network.log" , mock_log
1917- ):
1913+ ), patch .object (socket , "gethostbyaddr" , side_effect = _gen_gethostbyaddr (- 1 )):
19181914 assert core .fqdns () == {"fqdns" : []}
1919- mock_log .debug .assert_called_once ()
1920- mock_log .error .assert_called ()
1915+ assert "Failed to resolve address 1.2.3.4:" in caplog .text
19211916
19221917
19231918def test_core_virtual ():
You can’t perform that action at this time.
0 commit comments