]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/cephadm/tests/fixtures.py
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / cephadm / tests / fixtures.py
index b3926f9a9de840d901a99764abb3dd4ab3b04711..76ac0b44cf98740dffc4a1d9ba352b0f51ce5958 100644 (file)
@@ -1,4 +1,3 @@
-from importlib.resources import contents
 import mock
 import os
 import pytest
@@ -71,8 +70,17 @@ def cephadm_fs(
     uid = os.getuid()
     gid = os.getgid()
 
+    def fchown(fd, _uid, _gid):
+        """pyfakefs doesn't provide a working fchown or fchmod.
+        In order to get permissions working generally across renames
+        we need to provide our own implemenation.
+        """
+        file_obj = fs.get_open_file(fd).get_object()
+        file_obj.st_uid = _uid
+        file_obj.st_gid = _gid
+
     _cephadm = import_cephadm()
-    with mock.patch('os.fchown'), \
+    with mock.patch('os.fchown', side_effect=fchown), \
          mock.patch('os.fchmod'), \
          mock.patch('platform.processor', return_value='x86_64'), \
          mock.patch('cephadm.extract_uid_gid', return_value=(uid, gid)):