ToxiproxyEx.get!(:mysql_master) |> ToxiproxyEx.toxic(:latency, latency: 1000) |> ToxiproxyEx.apply!(fn -> Repo.all(Shop) # this took at least 1s end)
Toxiproxy is a proxy to simulate network and system conditions. The Elixir API aims to make it simple to write tests that ensure your application behaves appropriately under harsh conditions.
- Simulate slow or unresponsive external services in your tests
- Small and simple API
- Full support for all Toxics supported by Toxiproxy
Most applications rely on some external services such as databases or rest apis.
Testing those services is important.
While testing happy paths and error cases can be achieved with standard tools such as mock http services, testing for more nuanced situations like slow responses and hanging connections require a tool like toxiproxy to make sure that implemented resiliency strategies such as timeouts and bulkheads work as expected.