WireMock-Net / WireMock.Net

WireMock.Net is a flexible product for stubbing and mocking web HTTP responses using advanced request matching and response templating. Based on the functionality from http://WireMock.org, but extended with more functionality.
Apache License 2.0
1.39k stars 207 forks source link

Request matching WithProbability strange behaviour #1126

Open mihailtrifonovio opened 3 months ago

mihailtrifonovio commented 3 months ago

Based on article for "Chaos Engineering with Fault Injections" I've added following code:

var server = StandAloneApp.Start(new WireMockServerSettings {  Port = 8888 } );

        server
          .Given(Request.Create().WithPath("/test").UsingGet())
          .WithProbability(0.5)
          .RespondWith(Response.Create()
              .WithStatusCode(200)
              .WithBody(@"Success")
            );

        server
          .Given(Request.Create().WithPath("/test").UsingGet())
          .RespondWith(Response.Create()
              .WithStatusCode(500)
              .WithBody(@"Internal Server error")
          );

My expectation is that around 50% of the time there will be faults. However it is 100% of the time. If second matching is removed then there is some distribution between 200 and 404(no matching found), but is not 1:1 and more like 5:1 in favor of 404.

Is there something I'm missing?