question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Capturing and simulating with two Hoverfly instances misbehaves

See original GitHub issue

Description 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:

  1. Hoverfly Java version: 0.12.2

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
larsthorupcommented, Dec 16, 2019

Thank you for the comments! I have merged the PR and cleaned up the code a bit. We will follow this approach.

1reaction
tommysitucommented, Dec 15, 2019

Please close this issue if you’re happy 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Capturing — Hoverfly Java 0.14.0 documentation
This can be a simple way of breaking a test's dependency on an external service; wait until you have a green test, then...
Read more >
Web Test Tools - Software QA Test
Listing of 500 web test tools and management tools - load testing, mobile testing, page speed testing, link checking, html validation, ...
Read more >
SpectoLabs/hoverfly - Gitter
I am looking hoverfly to simulate my services, but how does it can handle multiple microservices? hoverctl start hoverctl mode capture
Read more >
bueno_alex_testing_java_micros...
Developing use cases spanning multiple services that aren't included in ... so capturing and manipulating the object in the test is the safest...
Read more >
A curated list of awesome Go frameworks, libraries and ...
Oto - A low-level library to play sound on multiple platforms. ... hoverfly - HTTP(S) proxy for recording and simulating REST/SOAP APIs with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found