You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enable local testing for all cachier backends with Docker (#287)
* Add a script for running all cores locallly
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* shorten some line
* safe import of optional dependencies in mongodb core tests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* safer import of opt deps in mongo tests
* fix test dependencies
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fixing
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* more stupid docstring
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* move test_missing_mongetter and mark it as a mongodb core test
* fixes and readme updates
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* shorter comment
* no need for this
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
-`./scripts/test-mongo-local.sh` - Run MongoDB tests only (default)
201
-
-`./scripts/test-mongo-local.sh --mode also-local` - Include memory, pickle, and maxage tests
202
-
-`./scripts/test-mongo-local.sh --keep-running` - Keep MongoDB running after tests
203
-
-`./scripts/test-mongo-local.sh --verbose` - Show verbose output
204
-
-`./scripts/test-mongo-local.sh --coverage-html` - Generate HTML coverage report
205
-
206
200
**Make Targets:**
207
201
208
-
-`make test-mongo-local` - Run MongoDB tests with Docker
209
-
-`make test-mongo-inmemory` - Run with in-memory MongoDB (default)
210
-
-`make mongo-start` - Start MongoDB container
211
-
-`make mongo-stop` - Stop MongoDB container
212
-
-`make mongo-logs` - View MongoDB logs
213
-
214
-
**Note:** By default, MongoDB tests use `pymongo_inmemory` which doesn't require Docker. The above commands let you test against a real MongoDB instance matching the CI environment.
202
+
-`make test-local CORES="mongo redis"` - Test specified cores
203
+
-`make test-all-local` - Test all backends with Docker
204
+
-`make test-external` - Test all external backends
205
+
-`make test-mongo-local` - Test MongoDB only
206
+
-`make test-redis-local` - Test Redis only
207
+
-`make test-sql-local` - Test SQL only
208
+
-`make services-start` - Start all Docker containers
209
+
-`make services-stop` - Stop all Docker containers
210
+
211
+
**Available Cores:**
212
+
213
+
-`mongo` - MongoDB backend
214
+
-`redis` - Redis backend
215
+
-`sql` - PostgreSQL backend
216
+
-`memory` - Memory backend (no Docker)
217
+
-`pickle` - Pickle backend (no Docker)
218
+
-`all` - All backends
219
+
-`external` - All external backends (mongo, redis, sql)
220
+
-`local` - All local backends (memory, pickle)
221
+
222
+
**Options:**
223
+
224
+
-`-v, --verbose` - Verbose pytest output
225
+
-`-k, --keep-running` - Keep containers running after tests
226
+
-`-h, --html-coverage` - Generate HTML coverage report
227
+
228
+
**Note:** External backends (MongoDB, Redis, SQL) require Docker. Memory and pickle backends work without Docker.
This script automatically handles Docker container lifecycle, environment variables, and cleanup. Additional options:
548
551
549
-
- ``--mode also-local``: Include memory, pickle, and maxage tests alongside MongoDB tests
550
-
- ``--keep-running``: Keep MongoDB container running after tests
551
-
- ``--verbose``: Show verbose output
552
-
- ``--coverage-html``: Generate HTML coverage report
552
+
- ``-v, --verbose``: Show verbose output
553
+
- ``-k, --keep-running``: Keep containers running after tests
554
+
- ``-h, --html-coverage``: Generate HTML coverage report
553
555
554
556
**Option 2: Using Make**
555
557
556
558
.. code-block:: bash
557
559
558
-
make test-mongo-local # Run tests with Docker MongoDB
559
-
make test-mongo-inmemory # Run tests with in-memory MongoDB (default)
560
+
make test-mongo-local # Run MongoDB tests with Docker
561
+
make test-all-local # Run all backends with Docker
562
+
make test-mongo-inmemory # Run with in-memory MongoDB (default)
560
563
561
564
**Option 3: Manual setup**
562
565
@@ -578,6 +581,28 @@ Contributors are encouraged to test against a real MongoDB instance before submi
578
581
**HOWEVER, the tests run against a live MongoDB instance when you submit a PR are the determining tests for deciding whether your code functions correctly against MongoDB.**
579
582
580
583
584
+
Testing all backends locally
585
+
-----------------------------
586
+
587
+
To test all cachier backends (MongoDB, Redis, SQL, Memory, Pickle) locally with Docker:
588
+
589
+
.. code-block:: bash
590
+
591
+
# Test all backends at once
592
+
./scripts/test-local.sh all
593
+
594
+
# Test only external backends (MongoDB, Redis, SQL)
595
+
./scripts/test-local.sh external
596
+
597
+
# Test specific combinations
598
+
./scripts/test-local.sh mongo redis
599
+
600
+
# Keep containers running for debugging
601
+
./scripts/test-local.sh all -k
602
+
603
+
The unified test script automatically manages Docker containers, installs required dependencies, and runs the appropriate test suites. See ``scripts/README-local-testing.md`` for detailed documentation.
0 commit comments