mdevilliers / Toxiproxy.Net

Toxiproxy.Net is a .Net client for Shopify's Toxiproxy. Toxiproxy is a proxy to test your system by simulating network failure.
MIT License
52 stars 10 forks source link

README examples are no longer accurate #12

Closed LuckyURE closed 6 years ago

LuckyURE commented 7 years ago

I followed the instructions in the README for creating a timeout and the .Upstreams() doesn't exist. Can you please update the examples to reflect the right way to create toxins? Thanks!

Update: This is what I'm trying right now in attempt to get it to timeout but it doesn't seem to do anything as my call actually returns:

`using (var connection = new Connection(true)) { var client = connection.Client(); var localToFeedProxy = new Proxy() { Name = "localToFeed", Enabled = true, Listen = "127.0.0.1:44000", Upstream = "{{domain_im_calling}}" };

            client.Delete(localToFeedProxy);
            var proxy = client.Add(localToFeedProxy);

            var toxic = new TimeoutToxic
            {
                Name = "TimeoutToxicTest",
                Stream = ToxicDirection.UpStream,
                Toxicity = 0.5
            };

            toxic.Attributes.Timeout = 10;
            proxy.Add(toxic);
            proxy.Update();

            // this is where I make the real call that hopefully goes through the proxy
            var parser = new Parser(username, password, feedUrl);
            result = parser.GetXmlFeed().Result;
        }`
TrinhChuong commented 7 years ago

Having the same issue. Trying to setup a Latency toxic and nothing happens. Connection goes through as normal.

TrinhChuong commented 7 years ago

I think I see the issue now. I wasn't setting toxicity, which according to Toxiproxy should default the toxicity to 1.0 (apply 100% of the time). But putting a break point in my code and browsing to localhost:8474/proxies to view what proxies are setup, the toxicity of the toxic is set to 0 (apply 0% of the time). Therefore the latency isn't being applied and the traffic is flowing through as normal. This is probably because toxicity is a double in the client and the default value of a double is 0.

Looking at your tests I noticed you are setting some toxicity levels to 80. This doesn't seem like a valid value!? And also, there are no assertions of the values of toxicity and, forgive me if I have missed it, but after setting up the proxy in your tests, are you physically making a request through the proxy?

On a separate note, having now set the toxicity to 1.0, the latency being applied seems to be higher than what I'm expecting. With a latency set to 1000 (i.e. 1 sec), I am seeing latency of around 7-8 secs. Whether this is as a result of cumulative latency I am not sure yet.

mdevilliers commented 7 years ago

Thanks for trying out the project.

All of the tests, if I remember correctly, were around configuration the proxy rather than testing it was doing the correct thing.

You might need to check the toxiproxy project for the expected behaviour as all this client does is configure it.

I'm afraid I don't do any .net these days so have struggled to keep this project updated. If you had time to do a PR to correct the readme I would appreciate it.