Conversation
This commit extracts testing improvements from the feature branch, focusing on infrastructure enhancements without feature code: - Add pytest-xdist for parallel test execution - Add pytest-rerunfailures for handling flaky tests - Update test-local.sh script with -p (parallel) and -w (workers) flags - Add seriallocal marker for tests requiring sequential execution - Configure coverage for parallel execution - Add comprehensive fixtures in conftest.py: - `isolated_cache_directory`: Ensures pickle tests use worker-specific cache dirs - `inject_worker_schema_for_sql_tests`: Provides SQL schema isolation per worker - `cleanup_mongo_clients`: Proper MongoDB client cleanup to prevent ResourceWarning - `cleanup_test_schemas`: Cleanup SQL schemas after parallel test runs - Consolidate backend tests into dedicated files: - tests/test_mongo_core.py (MongoDB tests with cleanup improvements) - tests/test_pickle_core.py (Pickle tests with flaky handling) - tests/test_redis_core.py (Redis tests with isolation) - tests/test_sql_core.py (SQL tests with schema isolation) - Add comprehensive tests/README.md with: - Test suite overview and structure - Guidelines for writing isolated tests - Parallel testing documentation - Backend-specific testing instructions - Troubleshooting guide - Mark flaky tests with @pytest.mark.flaky for automatic retries - Add platform-specific timing adjustments (macOS vs Linux) - Improve MongoDB client tracking and cleanup - Add custom mongetter function for collection isolation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
for more information, see https://pre-commit.ci
|
@copilot fix precommit-ci errors: |
There was a problem hiding this comment.
Pull request overview
This PR aims to speed up local development workflows by enabling parallel pytest execution (via pytest-xdist), adding retry support for flaky tests, and documenting the test suite / parallel execution behavior.
Changes:
- Add pytest-xdist + pytest-rerunfailures to the base test requirements.
- Introduce new pytest fixtures/configuration intended to improve isolation when running tests in parallel (SQL schema isolation, per-worker cache dirs).
- Extend
scripts/test-local.shand add test-suite documentation undertests/README.md.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
tests/requirements.txt |
Adds dependencies for parallel runs / flaky retries (but currently drops an async dependency needed by the suite). |
tests/conftest.py |
Adds fixtures/options to support parallel-safe execution across backends (SQL schema + cache-dir isolation). |
tests/README.md |
Adds comprehensive test-suite and parallel-execution documentation. |
scripts/test-local.sh |
Adds -p/-w support and attempts to split out serial local tests while running the rest in parallel. |
pyproject.toml |
Updates pytest/coverage configuration and adds a Black config section. |
Comments suppressed due to low confidence (1)
tests/conftest.py:240
- The custom
--parallel/--parallel-workersoptions are added here but aren’t used anywhere (no hook that converts them into xdist’s-nbehavior). As a result, runningpytest --parallelwill not actually run tests in parallel. Either implement the wiring (e.g., translate these options into-n) or drop these custom options to avoid a misleading CLI.
default="auto",
help="Number of parallel workers (default: auto)",
)
| ### GitHub Actions | ||
|
|
||
| The CI pipeline tests all backends: | ||
|
|
||
| ```yaml | ||
| # Local backends run in parallel | ||
| pytest -m "memory or pickle" -n auto | ||
|
|
||
| # External backends run sequentially for stability | ||
| pytest -m mongo | ||
| pytest -m redis | ||
| pytest -m sql | ||
| ``` |
There was a problem hiding this comment.
The CI example here doesn’t match the repo’s GitHub Actions workflow (.github/workflows/ci-test.yml currently runs local tests without xdist and uses different marker expressions). Please update this section to reflect the actual CI commands, or clearly label it as a suggestion rather than the current pipeline behavior.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
tests/conftest.py
Outdated
| else: | ||
| # Running with pytest-xdist - use worker-specific directory |
There was a problem hiding this comment.
isolated_cache_directory only activates for pickle-marked tests, but maxage tests use @cachier() with the default backend (pickle). When running with xdist, those maxage tests can still conflict on the default cache directory. Consider applying the same isolation when the maxage marker is present too.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
* Initial plan * Fix SIM108: use ternary operator for cache_dir assignment in conftest.py Co-authored-by: shaypal5 <917954+shaypal5@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: shaypal5 <917954+shaypal5@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## master #349 +/- ##
============================================
- Coverage 100.00% 78.95% -21.05%
============================================
Files 12 12
Lines 1701 1701
Branches 213 213
============================================
- Hits 1701 1343 -358
- Misses 0 338 +338
- Partials 0 20 +20
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
@copilot fix failing tests |
|
@copilot fix a regression in a couple of local tests: |
No description provided.