mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
How best to manage/switch remote configuration for proxying(recording) versus matching(mocking) ? #410
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 @PrzemekScott on GitHub (Mar 15, 2022).
After some local experiments with WM, now I started some with WM running as a Kubernetes pod.
When in local, each time I wanted to use WM for proxying or for matching I was simply restarting it with configuration changed appropriately. Mappings were kept on local folder so sucha a restart wasn’t a problem - mappings were not lost.
Yet now, when WM running as a pod its space for keeping folders/files will be vanished each time WM will be redeployed with changed configuration.
So, @StefH could you please share if it is possible to change the configuration on the fly? - the /settings endpoint does not reach to Proxy settings.
@StefH commented on GitHub (Mar 15, 2022):
@PrzemekScott
In case of proxy mode; I could ignore all calls made to
/__admin/***.Would that help you?
@PrzemekScott commented on GitHub (Mar 16, 2022):
@StefH
hm... not sure
your context = thorough knowledge of WM
my context = still very basic knowledge of WM
so can you please elaborate more on your idea?
You mean "ignore all calls made to /__admin/*** " from being saved to mappings?
P.S. I've tried to change settings on the fly - when WM is running as a pod - with POST /__admin/settings.
WM is running with "AllowPartialMapping": false,
so I've sent "AllowPartialMapping": true,
I got response 200 "Status": "Settings updated"
yet when sending GET /__admin/settings
unfortunately got still "AllowPartialMapping": false
@StefH commented on GitHub (Mar 18, 2022):
What I mean is that when WireMock.Net is running in proxy mode, it should still allow you to change the configuration by allowing calls to
/__admin/settings. (This requires a change in the code.)@PrzemekScott commented on GitHub (Mar 18, 2022):
Ok, yes, that would be great.
Maybe I missconcept something, so please @StefH correct me.
But I understand that the best way to work with WM when testing is to create mappings (less often usage) during proxying/recording, and then to switch WM to matching mode (most of the time usage).
So I can configure it to work as proxy for recording (example below) - less often:
Or I can configure it to work as a matcher (example below) - most of the time:
When WM is run remotely, as mine, as a Kubernetes pod, deployed from Azure as a web application, when initialised it reads configuration from appsettings.json file.
But it would be great to have option to switch between these ^ configurations when service is running, so by the usage of some endpoint, without a need of redeploying WM cause then all files and folders will be vanished, so one would need first to download them, then upload again etc. Well, this downloading and uploading is still doable.
Also maybe you see a different way of approaching this case (configuring WM), which I do not see cause still learning about WM options, so please share. Thanks!
@PrzemekScott commented on GitHub (Mar 24, 2022):
Hey @StefH have you had a chance to work on this ^, or if not when do you think you could? thanks
@PrzemekScott commented on GitHub (Mar 29, 2022):
Hey @StefH . We went with solution of deploying WM with different settings each time its needed.
@StefH commented on GitHub (Apr 3, 2022):
I noticed that when running WM in Proxy, you can GET and UPDATE the settings via the admin interface (WM still responds to calls to the
_adminendpoint).However, I found a small bug that not all settings were retrieved.
And there is no way yet to GET or SET the ProxyAndRecordSettings, I'll need to update the code to support these settings also.
@StefH commented on GitHub (Apr 4, 2022):
@PrzemekScott
I've changed the code so that you now can get / post the (proxy)settings to a running WireMock instance.
You need preview version
1.4.40-ci-16011for that.@jatin-prusty-travelport commented on GitHub (Apr 12, 2022):
@StefH I was checking the preview version and found that post was able to update the proxy settings correctly. But after that when I try to mock a call I get error. So here is the sequence of steps:
But then I received this error response:
{
"Status": "Object reference not set to an instance of an object."
}
Can you please check?
cc: @PrzemekScott
@StefH commented on GitHub (Apr 14, 2022):
Please check preview version 1.4.40-ci-16018
@StefH commented on GitHub (Apr 16, 2022):
@jatin-prusty-travelport
@PrzemekScott
I think the functionality works fine now:
Please try version
1.4.40-ci-16022.@StefH commented on GitHub (Apr 21, 2022):
@jatin-prusty-travelport
@PrzemekScott
Did you have time to test ?
@jatin-prusty-travelport commented on GitHub (Apr 21, 2022):
@StefH I tested the versions today. It works fine in 1.4.40-ci-16018 but it's broken in 1.4.40-ci-16022.
cc: @PrzemekScott
@StefH commented on GitHub (Apr 21, 2022):
Broken means incorrect behavior?
Or 'Object reference not set to an instance of an object.'?
@jatin-prusty-travelport commented on GitHub (Apr 21, 2022):
Apologies @StefH. I checked again and both the version are working fine. Probably last time the nuget packages weren't restored correctly.
Thanks for all the help!
cc: @PrzemekScott
@StefH commented on GitHub (Apr 21, 2022):
Cool.
I'll merge this branch today and create a new official version.
@PrzemekScott commented on GitHub (Apr 21, 2022):
Thanks @StefH !