]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: mock CephadmHttpServer run in unit tests 47565/head
authorAdam King <adking@redhat.com>
Thu, 11 Aug 2022 18:26:11 +0000 (14:26 -0400)
committerAdam King <adking@redhat.com>
Thu, 11 Aug 2022 18:30:04 +0000 (14:30 -0400)
While tests were still passing, since this server class
was added the units tests are taking significantly longer to
run and I'm seeing messages like

Failed to run cephadm http server: Expected 4 octets in "<MagicMock name='mock.get().__getitem__()' id='139931011514704'>"

The run time given by "time tox -e py3" without this commit on
my local machine was

real 2m45.749s
user 16m13.273s
sys 0m11.041s

and with this commit (and the server run function therefore mocked)

real 0m36.164s
user 0m26.932s
sys 0m2.367s

so it seems to run about 4x faster with the server run function
mocked and the tests pass in both cases

Issue introduced by: https://github.com/ceph/ceph/pull/46400/commits/a0fe3ffdaaddd661f115de78ddae89b07b98a9ae

Signed-off-by: Adam King <adking@redhat.com>
src/pybind/mgr/cephadm/tests/fixtures.py

index c2e7a6ed8d20749763014b469a5d736b0897f7ee..2ca027a37d525edcd8cf067608c3898bfb3414ae 100644 (file)
@@ -99,8 +99,9 @@ def with_cephadm_module(module_options=None, store=None):
             mock.patch("cephadm.agent.CephadmAgentHelpers._apply_agent", return_value=False), \
             mock.patch("cephadm.agent.CephadmAgentHelpers._agent_down", return_value=False), \
             mock.patch('cephadm.offline_watcher.OfflineHostWatcher.run'), \
-            mock.patch('cephadm.tuned_profiles.TunedProfileUtils._remove_stray_tuned_profiles'),\
-            mock.patch('cephadm.offline_watcher.OfflineHostWatcher.run'):
+            mock.patch('cephadm.tuned_profiles.TunedProfileUtils._remove_stray_tuned_profiles'), \
+            mock.patch('cephadm.offline_watcher.OfflineHostWatcher.run'), \
+            mock.patch('cephadm.http_server.CephadmHttpServer.run'):
 
         m = CephadmOrchestrator.__new__(CephadmOrchestrator)
         if module_options is not None: