Skip to content

valkey test container#1

Open
daric93 wants to merge 15 commits intomainfrom
valkey_test_container
Open

valkey test container#1
daric93 wants to merge 15 commits intomainfrom
valkey_test_container

Conversation

@daric93
Copy link
Copy Markdown
Owner

@daric93 daric93 commented Dec 8, 2025

No description provided.

@daric93 daric93 self-assigned this Dec 8, 2025
"""
return int(super().get_exposed_port(self.port))

@wait_container_is_ready(ValkeyNotReady)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Deprecated Decorator Usage

Location: modules/valkey/testcontainers/valkey/__init__.py, line 113

Current Code:

@wait_container_is_ready(ValkeyNotReady)
def _connect(self) -> None:
    """Wait for Valkey to be ready by sending PING command."""
    # ... connection logic

Issue:

The @wait_container_is_ready decorator is deprecated in the codebase. Recent commits show active migration away from this pattern:

Evidence from Codebase:

# From pytest.ini_options filterwarnings:
"ignore:The @wait_container_is_ready decorator is deprecated.*:DeprecationWarning"

Recommended Fix:

Migrate to modern wait strategy pattern:

from testcontainers.core.wait_strategies import ExecWaitStrategy

class ValkeyContainer(DockerContainer):
    def __init__(self, image: str = "valkey/valkey:latest", port: int = 6379, **kwargs) -> None:
        super().__init__(image, **kwargs)
        self.port = port
        self.password: Optional[str] = None
        self.with_exposed_ports(self.port)
        
    def start(self) -> "ValkeyContainer":
        # Build wait strategy based on password
        if self.password:
            # Use custom wait strategy for authenticated connections
            self.waiting_for(self._create_auth_wait_strategy())
        else:
            # Use exec strategy for simple PING
            self.waiting_for(
                ExecWaitStrategy(["valkey-cli", "ping"])
            )
        super().start()
        return self

Benefits:

  • Aligns with project direction
  • More composable and testable
  • Consistent with other modules
  • Better error messages

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

fixed

daric93 and others added 14 commits December 11, 2025 11:36
🤖 I have created a release *beep* *boop*
---


##
[4.14.2](testcontainers/testcontainers-python@testcontainers-v4.14.1...testcontainers-v4.14.2)
(2026-03-18)


### Features

* **kafka:** allow configurable listener name and security protocol
([testcontainers#966](testcontainers#966))
([44dd40b](testcontainers@44dd40b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: David Ankin <daveankin@gmail.com>
…filter logs (testcontainers#984)

This was originally only to fix
testcontainers#983 but I
took the time to fix some other stuff that made reading and running the
tests less optimal.

- Fix test_ryuk flakiness: replace fixed sleep with polling helper
(_wait_for_container_removed) that waits for Ryuk to finish reaping
- Suppress expected error logs in test_compose_volumes and
test_wait_strategies to reduce test noise
- Add __test__ = False to TestcontainersConfiguration to prevent pytest
from trying to collect it as a test class
- Add `long_running` pytest marker to pyproject.toml
- Mark DinD/DooD tests as long_running since they build Docker images
and take x4 than all the other tests combined
- Add `quick-core-tests` Makefile target to run core tests excluding
long_running tests for faster feedback loops

---------

Co-authored-by: David Ankin <daveankin@gmail.com>
This PR enables the testcontainer MosquittoContainer (which I
contributed to this project a few years ago) to work with version 2.1.2
and higher of Mosquitto.

In particular this PR is fixing an issue where rw mode is now needed for
/data partition for Mosquitto version 2.1.1 (released 2026-02-04), which
fixed a PUID/PGID issue.
In addition, it contains a fix for Mosquitto warnings generated by the
`listener` directive appearing after `protocol` directive.
Related to testcontainers#884
Trying to replace the old generic.py in core to a nicer version under
the generic module.

`SqlContainer` its not as good (in being generic) as `ServerContainer`
but it should allow us to deprecate
`core/testcontainers/core/generic.py` with minimal effort for users, it
could lead to a more Generic version like `DBContainer` in the future.

Update 1: Refactor to use `SqlConnectWaitStrategy`
Update 2: Now `SqlConnectWaitStrategy` is required and the users can
provide `SqlContainer` with any wait strategy.
Update 3: Now utilizes all the latest improvements from `WaitStrategy`

Note: I think the added tests + documentation (provided in this PR) are
by themselves a great improvement over the current generic.py
In testcontainers#676 for
copying to/from `DockerContainer`, it was suggested that we should
clarify the interface & usage a bit before proceeding. This PR aims to
push that conversation forward with some test cases illustrating
proposed usages. Although here I created a `Transferable` object, in
most cases there's no need for the caller to explicitly construct a
Transferable, just pass the `bytes | Path`

**Proposed use cases:**

1. Copy into a container by passing a `TransferSpec` into the
initializer:
```
DockerContainer(... transferrables=[TransferSpec(source, destination_in_container), ...)
```

2. Copy into the container via the builder pattern, prior to starting
the container:
```
DockerContainer(...)
     .with_copy_into_container(b"some_bytes", destination_in_container)
     .with_copy_into_container(some_path, destination_in_container)
 ```

3. Copy into the container at runtime:
```
with DockerContainer(...) as container:
container.copy_into_container(b"some_bytes", destination_in_container)
    container.copy_into_container(some_path, destination_in_container)
```

---------

Co-authored-by: Roy Moore <roy@moore.co.il>
This fixes bug testcontainers#994.

---------

Co-authored-by: Jan Koprowski <jan.koprowski@openchip.com>
testcontainers#982)

When these parameters were set, the functions get_url() and
get_management_url() did return the wrong URLs (without the prefix)

Now the implementation checks if the parameter is checked and adds it to
the returned URL

This solves
testcontainers#964

Co-authored-by: Baitinger Jens <jens.baitinger@de.bosch.com>
Co-authored-by: David Ankin <daveankin@gmail.com>
Follow-up to testcontainers#852, cleaning up the copy file feature after it landed.
(Related to testcontainers#676)
…tpWaitStrategy (testcontainers#971)

Hi there, I've seen this deprecation warning in a generic container.
This is my first PR in this project; I'm open to any feedback you may
have!

Related:
testcontainers#874

Also updates the docs, highlighted in [this
comment](testcontainers#874 (comment))

Co-authored-by: Jon Miller <jonmiller@netflix.com>
Co-authored-by: Roy Moore <roy@moore.co.il>
…stcontainers#903)

Related to
testcontainers#874.

Since those containers first need to be started to know their exposed
ports, we cannot use `DockerContainer._wait_strategy`. We have to keep
checking logs manually in their own `start` methods.

Let me know if there is anything to change.

---------

Co-authored-by: Hugo-C <Hugo-C@users.noreply.github.com>
Co-authored-by: David Ankin <daveankin@gmail.com>
Closes testcontainers#926 by adding PEP-561 marker file `py.typed`

Co-authored-by: Roy Moore <roy@moore.co.il>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants