Skip to content

test(pickle): add Linux-only test for inotify instance exhaustion (Issue #24)#275

Merged
shaypal5 merged 11 commits intomasterfrom
test/inotify-instance-limit-exhaustion
Jul 7, 2025
Merged

test(pickle): add Linux-only test for inotify instance exhaustion (Issue #24)#275
shaypal5 merged 11 commits intomasterfrom
test/inotify-instance-limit-exhaustion

Conversation

@shaypal5
Copy link
Copy Markdown
Member

@shaypal5 shaypal5 commented Jul 7, 2025

Summary

This PR adds a Linux-only test to reproduce the "inotify instance limit reached" error (see Issue #24) by rapidly creating many concurrent cache waits using the pickle backend.

  • The test is marked with @pytest.mark.pickle and is skipped on non-Linux systems.
  • If the error is not triggered (e.g., due to a high system limit in CI), the test is skipped with an informative message.
  • The test is designed to be informative, not flaky.

Additionally, the CI workflow is updated to lower the inotify instance limit on Linux/local jobs, increasing the likelihood of hitting the error in CI.


Rationale

  • Documents and tracks the resource exhaustion issue for future backend or watchdog improvements.
  • Follows project and Python best practices for test isolation, OS-specific logic, and CI configuration.
  • CI change is Linux/local only, with clear comments.

Enables tracking of how we handle issue #24

shaypal5 and others added 11 commits July 7, 2025 17:23
…sue #24)\n\nAdds a test to reproduce the 'inotify instance limit reached' error on Linux by rapidly creating many concurrent cache waits using the pickle backend. The test is skipped on non-Linux systems and is designed to be informative, not flaky.\n\nAlso updates CI to lower the inotify instance limit on Linux/local jobs, increasing the likelihood of hitting the error in CI.\n\nReferences: https://github.com/python-cachier/cachier/issues/24\n\n- Follows project and Python best practices for test isolation, OS-specific logic, and CI configuration.\n- Test is marked with @pytest.mark.pickle and uses pytest.skip for clarity.\n- CI change is Linux/local only, with clear comments.\n\nThis helps document and track the resource exhaustion issue, and provides a reproducible test for future backend or watchdog improvements.
- Increase thread count to 4x the system limit (up to 4096)
- Make the slow function slower (0.5s instead of 0.1s)
- Increase wait_for_calc_timeout to 0.1s
- Force test to fail instead of skip when limit not hit
- Add more debugging output to understand what's happening

This should help reproduce the inotify instance limit issue in CI.
- Test now FAILS when inotify instance limit is reached (bug exists)
- Test now PASSES when no inotify errors occur (bug is fixed)
- This makes the test useful for verifying fixes to the inotify issue
- Updated error messages to reflect the new logic
- Test is now marked as expected to fail with @pytest.mark.xfail
- Will show as XFAIL when bug exists (expected)
- Will show as XPASS when bug is fixed (pleasant surprise)
- Provides clear reason for expected failure
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a Linux-only pytest to reproduce the “inotify instance limit reached” error for the pickle backend and updates CI to lower the inotify instance limit on Linux/local jobs.

  • Introduce test_inotify_instance_limit_reached marked as Linux-only and xfail in tests/test_pickle_core.py
  • Add a GitHub Actions step to reduce fs.inotify.max_user_instances to 128 for Linux/local CI runs

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/test_pickle_core.py New test_inotify_instance_limit_reached function to exhaust inotify instances via concurrent cache calls
.github/workflows/ci-test.yml CI step to lower inotify instance limit on Linux/local runners to force the test to hit the limit
Comments suppressed due to low confidence (1)

tests/test_pickle_core.py:631

  • The test uses threading.Thread but threading is never imported in this scope, which will raise a NameError. Please add import threading before using it.
    import queue

@shaypal5 shaypal5 merged commit 4d35a18 into master Jul 7, 2025
42 checks passed
@shaypal5 shaypal5 deleted the test/inotify-instance-limit-exhaustion branch July 7, 2025 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants