wiremock / wiremock/WireMock.Net
Add to LogEntries before Task completed
@StefH is already working on this.
Since Mar 21, 2023.
- Dominant language
- C#
- Stars
- 1.7k
- Forks
- 240
- Avg merge
- 5d 12h
- Merged PRs (30d)
- 2
Description
Whilst testing timeout and retry policies I came across an issue where LogEntries were not updated before the test finished. Take this example, not exact code:
// handle 5**, 408,
// retry 3 times with a timeout per retry
var retryPolicy = HttpPolicyExtensions
.HandleTransientHttpError()
.Or<TimeoutRejectedException>()
.RetryAsync(3);
var policy = retryPolicy.WrapAsync(
HttpPolicy.TimeoutAsync(TimeSpan.FromMilliseconds(300)));
using var server = WireMockServer.Start();
server
.Given(Request.Create().UsingGet())
.RespondWith(Response.Create()
.WithDelay(1000)
.WithStatusCode(HttpStatusCode.InternalServerError));
var httpClient = CreateHttpClient(policy);
await Assert.ThrowsAsync<TimeoutRejectedException>(() =>
httpClient.GetAsync(server.Url));
// wiremock leaves recording the requests till the end which means timeouts cause LogEntries to go missing.
_testOutputHelper.WriteLine("Calls made: " + wireMockServer.LogEntries.Count());
The WithDelay(1000) will cause the policy to timeout (within 300ms), eventually throwing a TimeoutRejectedException, the test will end with a printed line of Calls made: 1 as the other calls are still processing.
Can we add the LogEntry as soon as the request has been received, update when match has been made, with null values for the response, then update it when a response has been created?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.