Skip to content

Toxiproxy.Net is a .Net client for Shopify's Toxiproxy. Toxiproxy is a proxy to test your system by simulating network failure.

License

Notifications You must be signed in to change notification settings

mdevilliers/Toxiproxy.Net

Repository files navigation

Toxiproxy.Net

Toxiproxy.Net is a .Net client for Shopify's Toxiproxy REST/JSON Api. Toxiproxy is a proxy to test your system by simulating network failure.

Project

Build status

Master branch

Build status

Test Coverage

Coverage Status

Getting started

To install via the nuget package console

Install-Package Toxiproxy.Net

A copy of toxiproxy compiled for windows is in the compiled folder. Linux, Darwin and Windows builds are available from the official release site

Usage

The unit tests give a good overview of how to fully use the api. Here are some examples to get started -

Start Toxiproxy

_proxyProcess = new Process()
    {
        StartInfo = new ProcessStartInfo(@".\packages\Toxiproxy.Net\compiled\Win64\toxiproxy-server-2.1.2-windows-amd64.exe")
    };
_proxyProcess.Start();

Set up a proxy

var connection = new Connection();
var client = connection.Client();

//proxy all traffic from 127.0.0.1:44399 to https://google.com
var localToGoogleProxy = new Proxy() { 
    Name = "localToGoogle", 
    Enabled = true, 
    Listen = "127.0.0.1:44399", 
    Upstream = "google.com:443" 
};

client.Add(localToGoogleProxy);

Disable a proxy

var connection = new Connection();
var client = connection.Client();
var proxy = client.FindProxy("localToGoogle");

proxy.Enabled = false;
proxy.Update();

Timeout a proxy

var connection = new Connection();
var client = connection.Client();
var proxy = client.FindProxy("localToGoogle");

var timeoutProxy = new TimeoutToxic();
timeoutProxy.Attributes.Timeout = 100;
timeoutProxy.Toxicity = 1.0;

proxy.Add(timeoutProxy);
proxy.Update();

Return a list of all proxies

var connection = new Connection();
var client = connection.Client();

client.All();

Reset all proxies to a good state automatically

// assuming the proxy is running with its default settings e.g. localhost:8474
// and there is a connection defined with the name "ms_sql"
// create a connection to toxiproxy that will call reset on disposal
// this resets the state of all the toxics and re-enables all of the proxies
    using (var connection = new Connection(true))
    {

        // find the upstream latency toxic
        var proxy = connection.Client().FindProxy("ms_sql");
        var latency = (LatencyToxic)proxy.GetToxicByName("Latency");


        // set a latency of 1 second 
        latency.Attributes.Latency = 1000;

        // save it
        proxy.Update();

        // do your test....

    }

Thanks

soneyworld Federico Orlandini vromantp mgkeen

About

Toxiproxy.Net is a .Net client for Shopify's Toxiproxy. Toxiproxy is a proxy to test your system by simulating network failure.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy