Open vforvikash opened 3 years ago
looking forward to the feature too.
we have support for wiremock in spring-cloud-contract. This is outside the scope of spring cloud gateway.
looking forward to the feature too.
@qqeasonchen here if you are still interested. https://github.com/ExpressScripts/sample-gateway-mock-apis
looking forward to the feature too.
@qqeasonchen here if you are still interested. https://github.com/ExpressScripts/sample-gateway-mock-apis
@vforvikash thanks, let me try it.
@spencergibb Please guide if i can contribute towards this feature based-of above mentioned repository.
@vforvikash -
@grabdoc I do like the idea of having a route to mock://. Can you elaborate on that please? Do you have an implementation that provides this route?
- why not use spring cloud wire mock .
yes wire mock is good choice. I didnt wanted to add mock code to actual code and with gateway mechanism i could do mock for multiple REST apis/application.
i'm not sure about your second suggestion. @grabdoc.
You are not going to add mock code.. It's another filter that routes request to wiremock instead of actual backend. When your backend is ready you can just switch over.
I don't thing a uri of mock://
makes much sense since you wouldn't be testing any real routes. Maybe something along the lines of boots "slice" testing, with an annotation @GatewayTest(mock=true)
or something along those lines that replaces normal routes with mocked ones. Or combined with openapi to generate respones
it wasnt just limited to my backend ready! using this feature testing team can change and add cases which are difficult to produce normally. This is all runtime changes with the gateway capability.
What are these abnormal cases ? The filter with wiremock should be able to handle that ? Do you mind sharing couple of examples
like one of our endpoint calls other services and in case if few services fails to respond or responds with unexpected messages or cases which are hard to setup....in such cases the testing team can write mock responses and use gateway capability to produce such cases and test the same in integration environment. Time to time this feature has helped as its easy to change and maintain by QAs.
Services always fail and return unexpected messages. This can be handled with a mock route filter that routes to wiremock. Wiremock being standard and well documented for mocking - QAs will find it easier to write wiremock files and commit them to GIT assuming QAs are technical as well.
OK. Sounds good. Well i loved the feature with gateway. Thanks for your suggestion.
@Controlix Hi - Here is a skeleton implementation of the idea with mock://
https://github.com/kdhrubo/scg-wiremock
I have created the filter and configuration. I have checked the requests are picked up by the mock filter.
I have not implemented the loading of the wiremock response files. I am sure you will get the idea.
Bit busy with my other project.
@kdhrubo thank you, but I get a 404 when navigating to your github repo. Maybe it's not public?
Please check now. I have changed visibility to public.
@Controlix did you get a chance to review ? Is this something you need ?
Please let me know.
Is your feature request related to a problem? Please describe. Needed a mock service based on proxy capability. The required mock service must be able to intercept incoming requests and return mock response if configured or forwards to existing live service.
Describe the solution you'd like I have developed a framework on top of Spring Cloud Gateway to enable mock configuration based on properties/config service. This framework allows to add mock configuration for a given API endpoint. This mock API either produces mock response or proxies the requests to live the service. The mock can be turned on/off for a given endpoint. It can also help to simulate difficult cases like timeouts for outbound calls by adding delays to mock response. Also, the mock configuration is property based which doesn’t require any modification.
Describe alternatives you've considered There are few json-server which can be quickly configured and started. But it does not have a proxy capability.
Additional context![image](https://user-images.githubusercontent.com/8757586/107990129-bb6f8d80-6fa1-11eb-83dc-a032002877fa.png)