From 5707c35b4186395e9dfb7818656d8e4929f0613c Mon Sep 17 00:00:00 2001 From: Javier Pena Date: Wed, 18 Oct 2017 10:28:19 +0200 Subject: [PATCH] Mock _wait_for_interface in test_run_with_sleep When running unit tests in an environment without network access, for example in a packaging env, test_run_with_sleep fails with a timeout trying to list the network interfaces [1]. Mocking the _wait_for_interface call, as it is done currently on master and stable/pike, fixes the issue. The original commit is fdcb0922a5c4a4ecbb8cb1b307c6c750990699ff; this patch only grabs the one mock from the original change. [1] - See https://trunk.rdoproject.org/centos7-ocata/8a/70/8a70c4d575c3b5bef2debde8512ed3200ccc8d4c_aa5406af/rpmbuild.log Change-Id: I5010ea78b4794afb72f86762b7e6fc31c1540436 --- ironic_python_agent/tests/unit/test_agent.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ironic_python_agent/tests/unit/test_agent.py b/ironic_python_agent/tests/unit/test_agent.py index 0b8ddc0ee..f3a3b2455 100644 --- a/ironic_python_agent/tests/unit/test_agent.py +++ b/ironic_python_agent/tests/unit/test_agent.py @@ -370,11 +370,14 @@ class TestBaseAgent(test_base.BaseTestCase): @mock.patch('ironic_python_agent.hardware_managers.cna._detect_cna_card', autospec=True) @mock.patch.object(time, 'sleep', autospec=True) + @mock.patch.object(agent.IronicPythonAgent, '_wait_for_interface', + autospec=True) @mock.patch('wsgiref.simple_server.make_server', autospec=True) @mock.patch.object(hardware, '_check_for_iscsi', autospec=True) @mock.patch.object(hardware.HardwareManager, 'list_hardware_info') def test_run_with_sleep(self, mock_check_for_iscsi, mock_list_hardware, - mock_make_server, mock_sleep, mock_cna): + mock_make_server, mock_wait, mock_sleep, + mock_cna): CONF.set_override('inspection_callback_url', '', enforce_type=True) wsgi_server = mock_make_server.return_value wsgi_server.start.side_effect = KeyboardInterrupt()