You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| SQL Server |`mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04`|[NuGet](https://www.nuget.org/packages/Testcontainers.MsSql)|[Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.MsSql)|
[Toxiproxy](https://github.com/Shopify/toxiproxy) is a proxy to simulate network and system conditions for chaos and resiliency testing. It can simulate latency, timeouts, bandwidth limits, and connection issues between services.
4
+
5
+
Add the following dependency to your project file:
6
+
7
+
```shell title="NuGet"
8
+
dotnet add package Testcontainers.Toxiproxy
9
+
```
10
+
11
+
You can start a Toxiproxy container instance from any .NET application. This example demonstrates how to test network conditions by proxying traffic through Toxiproxy to a Redis container. The test creates both containers in the same network and configures Toxiproxy to redirect traffic from the test host to the Redis container.
This example uses xUnit.net's `IAsyncLifetime` interface to manage the lifecycle of the containers. Both the Redis and Toxiproxy containers are started in the `InitializeAsync` method before the test method runs, ensuring that the environment is ready for testing. After the test completes, the containers are removed in the `DisposeAsync` method.
To test network conditions with Toxiproxy, you need to configure the communication between your test host, Toxiproxy, and the service you want to test:
28
+
29
+
1. Place both containers in the same network so the Toxiproxy container and the service container (Redis in this example) can communicate with each other.
30
+
31
+
2. Configure the Toxiproxy proxy to redirect traffic from the test host to the service container. The proxy's `Listen` address specifies where Toxiproxy listens for incoming connections, and the `Upstream` address specifies the target service.
3. Connect through Toxiproxy using its hostname and one of its proxied ports. The Toxiproxy module initializes `32` ports starting from `8666` that can be used to configure proxies and redirect traffic. In the example, the Redis connection uses the Toxiproxy container's hostname and port instead of connecting directly to Redis.
Toxiproxy allows you to configure the `Toxicity` property, which determines the probability (0.0 to 1.0) that a toxic will be applied to the connection. A value of 1.0 means the toxic is applied 100% of the time, while 0.5 would apply it to approximately 50% of requests.
54
+
55
+
The test example uses the following NuGet dependencies:
0 commit comments