]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
cephadm: fix unit tests executing FileLock type
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 20 Sep 2023 19:38:50 +0000 (15:38 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 21 Sep 2023 13:46:41 +0000 (09:46 -0400)
commit1a5a61d78fc3dae4016012bfa14e4b91ec1ae4f5
tree3df6f6d587ce49261b145f1b897ef8575cb6e664
parent0c8bd683b5acaab6e3eeb11cec820df89525d809
cephadm: fix unit tests executing FileLock type

The FileLock type doesn't play much of a role when running tests so
to prevent issues, always mock it out when using with_cephadm_ctx.

In particular, a future patch revealed a problem with the FileLock code
that I can not understand how it was not hit before, or why this simple
refactoring - not directly related to file locking - triggered it. But
in short, the FakeFilesystem mocking utility only covers some syscalls.
In fact, the fake filesystem was returning an fd that was then passed to
real calls (fcntl and os.close).  The latter then triggered issues when
pytest was trying to clean up after it applied it's magic to stdio
objects in sys. The fix is easy - understanding why it happens and how
was hard.  I still don't understand why it popped up when it did only
that this is necessary to implement the following patches.

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