Skip to content

Migrate testing from source to Docker#3336

Draft
Dgramada wants to merge 6 commits intospring-projects:mainfrom
Dgramada:migrate-testing-to-docker
Draft

Migrate testing from source to Docker#3336
Dgramada wants to merge 6 commits intospring-projects:mainfrom
Dgramada:migrate-testing-to-docker

Conversation

@Dgramada
Copy link
Copy Markdown
Contributor

Description:

Replace the existing test infrastructure that downloads and compiles Redis from source with Docker Compose containers.

Motivation

The current testing setup is not ideal for future features that include Redis modules (JSON, Search, Bloom filter, etc.). When using source, testing would require developers to install extra dependencies like clang and would increase the Makefile complexity.

Docker Compose gives us pre-built images with modules already included and faster startup.

What changed

Makefile start, stop, and clean commands now delegate to docker compose. The IMAGE environment variable controls which Redis/Valkey image is used. The test and all-tests targets now properly preserve the Maven exit code before cleanup.

Docker Compose (src/test/resources/docker-env/docker-compose.yml) — defines the same topology as before:

  • 4 standalone nodes (master + 2 replicas + 1 auth-protected)
  • 4 sentinels (3 standard + 1 auth-protected)
  • 4 cluster nodes with automatic initialization.

All services use network_mode: host so tests connect to the same 127.0.0.1: addresses as before. Healthchecks ensure services are ready before dependents start.

CI action (.github/actions/setup-redis/action.yml) — instead of passing VERSION, PROJECT, and GH_ORG for source compilation, the action now passes a single IMAGE env var. The Redis binary cache step was removed since Docker image layers are handled by the container runtime.

Test fix — corrected hpExpireAtReturnsSuccessAndSetsTTL which was calling hTtl (seconds) instead of hpTtl (milliseconds) and asserting the wrong range.

Important: The CI pipeline will probably need adjustment and CI configs will probably need to be updated from using project version and name to the equivalent testing images.


  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

Signed-off-by: Yordan Tsintsov <yordan.tsintsov@redis.com>
Signed-off-by: Yordan Tsintsov <yordan.tsintsov@redis.com>
…dated fragile test for TTL.

Signed-off-by: Yordan Tsintsov <yordan.tsintsov@redis.com>
…ure.

Signed-off-by: Yordan Tsintsov <yordan.tsintsov@redis.com>
…ching.

Signed-off-by: Yordan Tsintsov <yordan.tsintsov@redis.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 24, 2026
@Dgramada Dgramada changed the title Migrate testing from source to Docke Migrate testing from source to Docker Mar 24, 2026

actual.add(connection.hpExpireAt("hash-hexpire", inFiveSeconds, "key-2"));
actual.add(connection.hTtl("hash-hexpire", "key-2"));
actual.add(connection.hpTtl("hash-hexpire", "key-2"));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not quite sure this change meets the description of the pull request description. HTTL is retrieving seconds and assertions check 0 to 5 second range. Now, the check is using milliseconds without actually fixing something.

Copy link
Copy Markdown
Member

@mp911de mp911de left a comment

Choose a reason for hiding this comment

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

Generally, appreciate the change, however, tests fail because of connection issues:

 spring-data-redis   main ●  make start
Starting Redis infrastructure...
docker compose -f src/test/resources/docker-env/docker-compose.yml up -d --wait redis-master redis-replica-1 redis-replica-2 redis-auth sentinel-1 sentinel-2 sentinel-3 sentinel-auth cluster-node-0 cluster-node-1 cluster-node-2 cluster-node-3
[+] Running 16/16
 ✔ Container cluster-7381                                                     Healthy                                                                            6.4s
 ✔ Container redis-6379                                                       Healthy                                                                            6.4s
 ✔ Container cluster-7380                                                     Healthy                                                                            6.4s
 ✔ Container cluster-7379                                                     Healthy                                                                            6.4s
 ✔ Container redis-6382                                                       Healthy                                                                            6.4s
 ✔ Container cluster-7382                                                     Healthy                                                                            6.4s
 ✔ Container sentinel-26382                                                   Healthy                                                                           11.3s
 ✔ Container sentinel-26380                                                   Healthy                                                                           11.3s
 ✔ Container redis-6381                                                       Healthy                                                                           11.3s
 ✔ Container redis-6380                                                       Healthy                                                                           11.3s
 ✔ Container sentinel-26379                                                   Healthy                                                                           11.3s
 ✔ Container sentinel-26381                                                   Healthy                                                                           11.3s
Initializing cluster...
docker compose -f src/test/resources/docker-env/docker-compose.yml up -d cluster-init
[+] Running 5/5
 ✔ Container cluster-7381  Healthy                                                                                                                               0.5s
 ✔ Container cluster-7380  Healthy                                                                                                                               0.5s
 ✔ Container cluster-7379  Healthy                                                                                                                               0.5s
 ✔ Container cluster-7382  Healthy                                                                                                                               0.5s
 ✔ Container cluster-init  Started                                                                                                                               0.6s
Redis infrastructure is ready!
 spring-data-redis   main ●  redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused

Adding ports or expose did't change anything because of the host network mode.

@Dgramada
Copy link
Copy Markdown
Contributor Author

This version of the testing works for Linux but it would require Docker Desktop for MacOS. Also it would require enabling shared network mode in Docker Desktop.

I understand this is not ideal as it requires developers that use MacOS to do additional setup, so I will change my approach and try another solution.

… networking completely.

Signed-off-by: Yordan Tsintsov <yordan.tsintsov@redis.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants