Skip to content

Commit e793dda

Browse files
committed
feat(test-local): add S3 core support and document local S3 testing in README
1 parent c7717ee commit e793dda

2 files changed

Lines changed: 27 additions & 11 deletions

File tree

README.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ This script automatically handles Docker container lifecycle, environment variab
736736
.. code-block:: bash
737737
738738
make test-mongo-local # Run MongoDB tests with Docker
739-
make test-all-local # Run all backends with Docker
739+
make test-all-local # Run all backends locally (Docker used for mongo/redis/sql)
740740
make test-mongo-inmemory # Run with in-memory MongoDB (default)
741741
742742
**Option 3: Manual setup**
@@ -762,18 +762,21 @@ Contributors are encouraged to test against a real MongoDB instance before submi
762762
Testing all backends locally
763763
-----------------------------
764764

765-
To test all cachier backends (MongoDB, Redis, SQL, Memory, Pickle) locally with Docker:
765+
To test all cachier backends (MongoDB, Redis, SQL, S3, Memory, Pickle) locally:
766766

767767
.. code-block:: bash
768768
769769
# Test all backends at once
770770
./scripts/test-local.sh all
771771
772-
# Test only external backends (MongoDB, Redis, SQL)
772+
# Test only external backends that require Docker (MongoDB, Redis, SQL)
773773
./scripts/test-local.sh external
774774
775+
# Test S3 backend only (uses moto, no Docker needed)
776+
./scripts/test-local.sh s3
777+
775778
# Test specific combinations
776-
./scripts/test-local.sh mongo redis
779+
./scripts/test-local.sh mongo redis s3
777780
778781
# Keep containers running for debugging
779782
./scripts/test-local.sh all -k
@@ -784,7 +787,7 @@ To test all cachier backends (MongoDB, Redis, SQL, Memory, Pickle) locally with
784787
# Test multiple files across all backends
785788
./scripts/test-local.sh all -f tests/test_main.py -f tests/test_redis_core_coverage.py
786789
787-
The unified test script automatically manages Docker containers, installs required dependencies, and runs the appropriate test suites. The ``-f`` / ``--files`` option allows you to run specific test files instead of the entire test suite. See ``scripts/README-local-testing.md`` for detailed documentation.
790+
The unified test script automatically manages Docker containers for MongoDB/Redis/SQL, installs required dependencies (including ``tests/requirements_s3.txt`` for S3), and runs the appropriate test suites. The ``-f`` / ``--files`` option allows you to run specific test files instead of the entire test suite. See ``scripts/README-local-testing.md`` for detailed documentation.
788791

789792

790793
Running pre-commit hooks locally

scripts/test-local.sh

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ CORES:
4545
mongo MongoDB backend tests
4646
redis Redis backend tests
4747
sql SQL (PostgreSQL) backend tests
48+
s3 S3 backend tests (no Docker needed)
4849
memory Memory backend tests (no Docker needed)
4950
pickle Pickle backend tests (no Docker needed)
50-
all All backends (equivalent to: mongo redis sql memory pickle)
51+
all All backends (equivalent to: mongo redis sql s3 memory pickle)
5152
external All external backends (mongo redis sql)
5253
local All local backends (memory pickle)
5354
@@ -133,7 +134,7 @@ expand_cores() {
133134
for core in $1; do
134135
case $core in
135136
all)
136-
cores="$cores mongo redis sql memory pickle"
137+
cores="$cores mongo redis sql s3 memory pickle"
137138
;;
138139
external)
139140
cores="$cores mongo redis sql"
@@ -158,6 +159,7 @@ get_markers_for_core() {
158159
mongo) echo "mongo" ;;
159160
redis) echo "redis" ;;
160161
sql) echo "sql" ;;
162+
s3) echo "s3" ;;
161163
memory) echo "memory" ;;
162164
pickle) echo "pickle or maxage" ;;
163165
*) echo "$1" ;; # Default to core name
@@ -166,11 +168,11 @@ get_markers_for_core() {
166168

167169
# Validate cores
168170
validate_cores() {
169-
local valid_cores="mongo redis sql memory pickle"
171+
local valid_cores="mongo redis sql s3 memory pickle"
170172
for core in $1; do
171173
if ! echo "$valid_cores" | grep -qw "$core"; then
172174
print_message $RED "Error: Invalid core '$core'"
173-
print_message $YELLOW "Valid cores: mongo, redis, sql, memory, pickle"
175+
print_message $YELLOW "Valid cores: mongo, redis, sql, s3, memory, pickle"
174176
exit 1
175177
fi
176178
done
@@ -265,6 +267,17 @@ check_dependencies() {
265267
fi
266268
fi
267269

270+
# Check S3 dependencies if testing S3
271+
if echo "$SELECTED_CORES" | grep -qw "s3"; then
272+
if ! python -c "import boto3; import moto" 2>/dev/null; then
273+
print_message $YELLOW "Installing S3 test requirements..."
274+
pip install -r tests/requirements_s3.txt || {
275+
print_message $RED "Failed to install S3 requirements"
276+
exit 1
277+
}
278+
fi
279+
fi
280+
268281
print_message $GREEN "All required dependencies are installed!"
269282
}
270283

@@ -498,7 +511,7 @@ main() {
498511
# Add markers if needed (only if no specific test files were given)
499512
if [ -z "$TEST_FILES" ]; then
500513
# Check if we selected all cores - if so, run all tests without marker filtering
501-
all_cores="memory mongo pickle redis sql"
514+
all_cores="memory mongo pickle redis s3 sql"
502515
selected_sorted=$(echo "$SELECTED_CORES" | tr ' ' '\n' | sort | tr '\n' ' ' | xargs)
503516
all_sorted=$(echo "$all_cores" | tr ' ' '\n' | sort | tr '\n' ' ' | xargs)
504517

@@ -507,7 +520,7 @@ main() {
507520
fi
508521
else
509522
# When test files are specified, still apply markers if not running all cores
510-
all_cores="memory mongo pickle redis sql"
523+
all_cores="memory mongo pickle redis s3 sql"
511524
selected_sorted=$(echo "$SELECTED_CORES" | tr ' ' '\n' | sort | tr '\n' ' ' | xargs)
512525
all_sorted=$(echo "$all_cores" | tr ' ' '\n' | sort | tr '\n' ' ' | xargs)
513526

0 commit comments

Comments
 (0)