]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: remove container_engine argument from test helper function
authorJohn Mulligan <jmulligan@redhat.com>
Mon, 26 Sep 2022 19:20:25 +0000 (15:20 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 27 Sep 2022 18:42:13 +0000 (14:42 -0400)
The with_cephadm_ctx test helper function had an argument that *called*
mock_podman function, thus calling the function at import-time. This can
lead to confusing and unexpected side effects. Because the
container_engine argument is not used by any callers of with_cephadm_ctx
we remove the argument.
All other callers of with_cephadm_ctx that make use of container engine
are already setting `ctx.container_engine = <xyz>` so removing the
argument makes it harder to make the same mistake again in the future.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/tests/fixtures.py

index 02f7eeb5d1973804affea3431cce70e0ce5c23b2..58903d159022979c15c02c581ec363c31a7c9dd9 100644 (file)
@@ -7,7 +7,7 @@ import time
 from contextlib import contextmanager
 from pyfakefs import fake_filesystem
 
-from typing import Callable, Dict, List, Optional
+from typing import Dict, List, Optional
 
 
 def import_cephadm():
@@ -117,13 +117,11 @@ def host_sysfs(fs: fake_filesystem.FakeFilesystem):
 @contextmanager
 def with_cephadm_ctx(
     cmd: List[str],
-    container_engine: Callable = mock_podman(),
     list_networks: Optional[Dict[str,Dict[str,List[str]]]] = None,
     hostname: Optional[str] = None,
 ):
     """
     :param cmd: cephadm command argv
-    :param container_engine: container engine mock (podman or docker)
     :param list_networks: mock 'list-networks' return
     :param hostname: mock 'socket.gethostname' return
     """
@@ -140,7 +138,7 @@ def with_cephadm_ctx(
          mock.patch('cephadm.logger'), \
          mock.patch('socket.gethostname', return_value=hostname):
         ctx: cd.CephadmContext = cd.cephadm_init_ctx(cmd)
-        ctx.container_engine = container_engine
+        ctx.container_engine = mock_podman()
         if list_networks is not None:
             with mock.patch('cephadm.list_networks', return_value=list_networks):
                 yield ctx