]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm/tests: mock find_program in test_container_engine 69162/head
authorSun Yuechi <sunyuechi@iscas.ac.cn>
Fri, 29 May 2026 08:46:13 +0000 (16:46 +0800)
committerSun Yuechi <sunyuechi@iscas.ac.cn>
Fri, 29 May 2026 08:59:38 +0000 (16:59 +0800)
test_container_engine mocks find_executable to keep command_check_host
off the real host, but command_check_host looks up 'lvcreate' (and
'systemctl') through find_program, which isn't mocked. So the test
actually needs lvcreate installed and only passes where it is.

Mock find_program too so the test doesn't depend on host binaries.

Signed-off-by: Sun Yuechi <sunyuechi@iscas.ac.cn>
src/cephadm/tests/test_cephadm.py

index 7d2402d8b9b30ed0f0001f5353638d4dd2af023a..27d4ff382524a40d18bc223fa5cde54dc748791e 100644 (file)
@@ -2282,10 +2282,11 @@ exec /usr/bin/docker run --rm --ipc=host --stop-signal=SIGTERM --ulimit nofile=1
 
 class TestCheckHost:
 
+    @mock.patch('cephadm.find_program', return_value='foo')
     @mock.patch('cephadm.find_executable', return_value='foo')
     @mock.patch('cephadm.check_time_sync', return_value=True)
     @mock.patch('cephadm.logger')
-    def test_container_engine(self, _logger, _find_executable, _check_time_sync):
+    def test_container_engine(self, _logger, _find_executable, _check_time_sync, _find_program):
         ctx = _cephadm.CephadmContext()
 
         ctx.container_engine = None