Skip to content

Capturing and simulating with two Hoverfly instances misbehaves #229

@larsthorup

Description

@larsthorup

Description of the bug

As described elsewhere (SpectoLabs/hoverfly#864 (comment)) 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions