mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
Wiremock - WatchStaticMappings only works until the first request is made #407
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jucamo8311 on GitHub (Feb 17, 2022).
Describe the bug
I created a standalone console app to mock requests using WireMock.Net.StandAlone library , the configuration of the server is like below
Expected behavior:
I believe the correct behavior is to detect changes on MappingsFolder an update the mapping accordingly. In some way it seems to work before is made the first request, after that it’s not able to detect changes on the json mapping files (update , delete , add).
Test to reproduce
Other related info
Thanks, in Avance for your time, wiremock.net is a great library
@StefH commented on GitHub (Feb 18, 2022):
@jucamo8311
I see you have a custom logger : CustomLocalLogger, can you please check this logging and copy-past that here in this issue?
(A possible reason that it does not work is an invalid json file.)
See
ccd433b202/src/WireMock.Net/Server/WireMockServer.Admin.cs (L142)ccd433b202/src/WireMock.Net/Server/WireMockServer.Admin.cs (L184)@jucamo8311 commented on GitHub (Feb 18, 2022):
I use serilog for the log (the serilog MinimumLevel is set to dedug in order to print everything ) , checking this log what I can see is
Here I change the response in the mapping file SalesforceCRM.json, from this
After that I can see in the log that a message was printed
Making a call to the mock using postman, the response is the content of Test_Resp_OK_2.json.
if I modify the file SalesforceCRM.json again changing the response file from Test_Resp_OK_2.json to Test_Resp_OK_1.json
nothing in the log is printed , and if I test the mock is still returning Test_Resp_OK_2.json
@StefH commented on GitHub (Feb 18, 2022):
It's very strange.
In .NET old (4.5.2) and .NETCore 3.1, it works / worked fine.
For .NET 5.0, is does not always work correct.
I did a small fix, can you try preview:
1.4.35-ci-15874
https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions
@StefH commented on GitHub (Feb 21, 2022):
Maybe related to?
https://github.com/WireMock-Net/WireMock.Net/pull/729
@jucamo8311 commented on GitHub (Feb 22, 2022):
I checked that build but it behaves the same, I starting to think that maybe it is not a problem of the library, more of .net core framework itself, because testing I noticed something even weirder. On Windows 10 if I execute my application on a console and end the application it is necessary to close the windwos console itself in order to take the changes I made on the mapping file, which made no sense because the app ended and should take the update version of the file when I start it again.
Anyway, tomorrow I am going to check BodyAsFileIsCached to see if make any diference
@StefH commented on GitHub (Feb 25, 2022):
New version (x.x.x.36) will be available on NuGet within some hours.
Maybe can you retest that version.
And maybe did you try this:
https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Settings/WireMockServerSettings.cs#L44
@jucamo8311 commented on GitHub (Feb 28, 2022):
I checked it, but nothing change. It doesn't take the mapping files update. Also I made a test with Framework 4.7.2 and like you said It works. So my conclucion is that something related to .net core framework doesnt work as expected
@StefH commented on GitHub (Feb 28, 2022):
Maybe related to this?
https://www.c-sharpcorner.com/blogs/using-filesystemwatcher-with-net-core-30
@StefH commented on GitHub (Mar 1, 2022):
@jucamo8311
I think I found it.
Can you try preview:
1.4.36-ci-15935
@jucamo8311 commented on GitHub (Mar 1, 2022):
Yes , that does it ,
Tested with .Net core 6.0 win 10 x64.
Tested with .Net core 6.0 win 2012 R2 x64.
@StefH commented on GitHub (Mar 1, 2022):
This bug has been present for some time now.
Thanks for finding this!
@StefH commented on GitHub (Mar 1, 2022):
https://github.com/WireMock-Net/WireMock.Net/pull/733