From: Adam King Date: Tue, 30 Nov 2021 13:45:47 +0000 (-0500) Subject: mgr/cephadm: unit test for re-adding host and receiving loopback address X-Git-Tag: v16.2.11~578^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b451f33a83c71f87cf679184e2ef0af58a323313;p=ceph.git mgr/cephadm: unit test for re-adding host and receiving loopback address Signed-off-by: Adam King (cherry picked from commit abfbbd383cadfa3e2862d939444e0e9218b3cb3b) --- diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index d4875d29a62d..fb75595329ca 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -159,6 +159,18 @@ class TestCephadm(object): assert wait(cephadm_module, cephadm_module.get_hosts()) == [HostSpec('test', '1::4')] assert wait(cephadm_module, cephadm_module.get_hosts()) == [] + @mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('[]')) + @mock.patch("cephadm.utils.resolve_ip") + def test_re_add_host_receive_loopback(self, resolve_ip, cephadm_module): + resolve_ip.side_effect = ['192.168.122.1', '127.0.0.1', '127.0.0.1'] + assert wait(cephadm_module, cephadm_module.get_hosts()) == [] + cephadm_module._add_host(HostSpec('test', '192.168.122.1')) + assert wait(cephadm_module, cephadm_module.get_hosts()) == [HostSpec('test', '192.168.122.1')] + cephadm_module._add_host(HostSpec('test')) + assert wait(cephadm_module, cephadm_module.get_hosts()) == [HostSpec('test', '192.168.122.1')] + with pytest.raises(OrchestratorError): + cephadm_module._add_host(HostSpec('test2')) + @mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('[]')) def test_service_ls(self, cephadm_module): with with_host(cephadm_module, 'test'):