fix(toxiproxy): add Toxiproxy container module - #1105
Open
JonnasFigueiredo wants to merge 1 commit into
Open
Conversation
Adds a ToxiproxyContainer under testcontainers.community.toxiproxy for simulating adverse network conditions (latency, bandwidth limits, connection drops, ...) in integration tests, mirroring the Toxiproxy modules already available for testcontainers Java, Go and .NET. - ToxiproxyContainer exposes the HTTP control API and a range of proxy ports and provides create_proxy() to route traffic to an upstream. - ToxiproxyProxy.add_toxic() injects toxics via the control API. - No extra runtime dependencies (the control API is called over urllib). - Adds an integration test (proxying + latency toxic), a docs page and example, and the community extra in pyproject.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New Container
Fixes #1104
Adds a
ToxiproxyContainer(testcontainers.community.toxiproxy) that wraps Toxiproxy for simulating adverse network conditions — latency, bandwidth limits, connection drops and more — in integration tests. Toxiproxy modules already exist for testcontainers Java, Go and .NET; this brings the same to Python.What it does
ToxiproxyContainerexposes the HTTP control API (8474) and a range of proxy ports, and waits on the control API before it's ready.create_proxy(name, upstream)routes traffic to an upstream (e.g."nginx:80"of a container that shares a network) and returns aToxiproxyProxywhosehost/proxy_portyou connect through.ToxiproxyProxy.add_toxic(...)injects toxics via the control API.urllib.Usage
The included integration test starts nginx behind Toxiproxy, verifies traffic flows through the proxy, then injects a latency toxic and asserts the response is delayed.
PR Checklist
fix(toxiproxy):as recommended for community modules.src/testcontainers/community/toxiproxy/testcontainers.community.toxiproxy.*.tests/community/toxiproxy/.docs/community/toxiproxy.rstwith the.. autoclassand.. titledirectives.__init__.pywith corresponding tests. Docs page + example added underdocs/modules/and the nav entry inmkdocs.yml.pyproject.tomlunderproject.optional-dependenciesastoxiproxy = [](no extra dependencies).