Capturing and simulating with two Hoverfly instances misbehaves
See original GitHub issueDescription of the bug
As described elsewhere (https://github.com/SpectoLabs/hoverfly/issues/864#issuecomment-559096554) we are using Hoverfly to auto-mock requests in service tests. We want to CAPTURE requests to the service-under-test while SIMULATING requests to external-services. It appears that Hoverfly does not (yet) support capturing and simulating through the same instance, so we are trying to orchestrate 2 Hoverfly instances. Starting them in either order gives different issues.
When starting Hoverfly first in Capture mode, then another instance in Simulate mode, the capture file ends up only including request/response-pairs from the interaction with the Hoverfly Admin end points. See https://github.com/larsthorup/hoverfly-capture-simulate/blob/master/src/test/java/com/example/hoverfly/HoverflyDemoApplicationIntegrationTests.java#L92
When starting Hoverfly first in Simulate mode, then another instance in Capture mode, the simulation is not taking effect, meaning that calls go through to the external service instead of being replayed. See https://github.com/larsthorup/hoverfly-capture-simulate/blob/master/src/test/java/com/example/hoverfly/HoverflyDemoApplicationIntegrationTests.java#L128
Steps to reproduce the issue
Please checkout this repo with code to reproduce this issue:
The repo contains a small Spring Boot service (service-under-test) that invokes time.jsontest.com
(external-service). The relevant part of the tests are linked above. Note, that the tests will pass to show that the issues described above have been reproduced.
Observed result
Either simulate doesn’t happen, or the relevant request isn’t captured, as explained above.
Expected result
Being able to simulate the external request to time.jsontest.com
while simultaneously capturing the request to our own end-point /service/time
.
Additional relevant information
If not indicated above:
- Hoverfly Java version: 0.12.2
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Thank you for the comments! I have merged the PR and cleaned up the code a bit. We will follow this approach.
Please close this issue if you’re happy 😃