testcontainers-python icon indicating copy to clipboard operation
testcontainers-python copied to clipboard

New Container: TestContainer for Valkey

Open daric93 opened this issue 3 weeks ago • 6 comments

What is the new container you'd like to have?

I’d like to add Valkey, the open-source fork of Redis, as a dedicated Testcontainers module.

  • Docker container: valkey/valkey:latest
  • Valkey website: https://valkey.io/
  • Documentation: https://valkey.io/docs/

Why not just use a generic container for this?

  • Valkey adoption is growing as an alternative to Redis to avoid licensing constraints, so reliable test coverage with real Valkey instances is important.
  • Valkey‑Search enables advanced features like vector search and hybrid queries with tags/filters—common in GenAI workloads. Having a container with correct modules ensures realistic integration tests.
  • Valkey GLIDE provides multi-language clients (Python/Java/Node/Go) with async support and best practices; a ValkeyContainer would align with this ecosystem for integration testing.
  • Parity with existing Testcontainers DB modules: Similar to RedisContainer, a dedicated ValkeyContainer simplifies setup (config, wait strategy, connection helpers) beyond what a generic container can offer.

daric93 avatar Dec 08 '25 18:12 daric93

I’ll start working on this issue and plan to submit a PR soon.

daric93 avatar Dec 08 '25 18:12 daric93

aren't they drop in compatible? or is that no longer the case, like different log messages? another reason i initially dont want to accept is that redis went back to agpl (although it seems very confusing so i can see that being a weak driver of adoption for valkey still)

alexanderankin avatar Dec 08 '25 19:12 alexanderankin

glide also supports redis, the search module is interesting and would be the only reason i dont have a response for, if in fact a separate module is needed (e.g. to listen for different log messages)

alexanderankin avatar Dec 08 '25 19:12 alexanderankin

You’re right—Valkey is largely drop-in compatible with Redis for core commands, and GLIDE supports both. For most basic use cases, a generic container or even RedisContainer works fine.

The main reasons for proposing a dedicated module are:

  • Valkey-Search (vector search, hybrid queries) is unique to Valkey and increasingly used in GenAI workloads. Tests that rely on these features need a container with the module preloaded.
  • Parity and simplicity: Similar to RedisContainer, a ValkeyContainer provides API for developers adopting Valkey without manual tweaks.

daric93 avatar Dec 08 '25 19:12 daric93

While Valkey is largely drop in compatible for older versions of Redis, the latest Valkey versions include some features that are not supported in Redis like Multi-db support for cluster configurations. Additionally, there are small differences in some commands. Also, the various modules can have significant differences especially in Valkey-Search and Valkey-JSON modules. Effective testing requires testing against the actual db you will use in production and not something that is "close".

jbrinkman avatar Dec 11 '25 14:12 jbrinkman

drop in support in this context means you can change the redis container image argument and it works

alexanderankin avatar Dec 11 '25 18:12 alexanderankin