hoverfly
hoverfly copied to clipboard
Eager caching not behaving as anticipated.
After loading configuration.json, cache is null.
Steps to reproduce the issue
- Start Hoverfly in capture mode
- Run traffic through the proxy and capture both request and responses
- Export configuration.json
- Stop Hoverfly
- Start Hoverfly in Simulation mode (Found webserver and proxy to behave identically)
- Import configuration
- Check cache.
Observed result
None
Cache is null
Expected result
Cache populated with the configuration data in an eager fashion rather than lazy loading
Additional relevant information
- Hoverfly version: 1.3.0
- I found the same behavior if switching from capture to simulate in the same instance. To get a cached request response pair I would have to execute the call in capture, change to simulation, then re-run the request to populate the cache.
@colts45s this is a bug actually, so what happens is that the eager caching function is only called when you run hoverctl mode simulate, but it's not executed when hoverfly starts 🤦
The workaround is that after step 5 in your example, you call hoverctl mode simulate and it should force the cache preloading.
I attempted this work around and was unable to achieve eager caching, I have a valid configuration.json file and even after i explicitly set the mode to simulate, loading the configuration does not add any items to the cache.
ok, the problem is this function checks eagerly cacheable simulation always return nil 😞 https://github.com/SpectoLabs/hoverfly/blob/master/core/models/request_matcher.go#L207
https://github.com/SpectoLabs/hoverfly/pull/1006 should fix the workaround at least
@colts45s raised PR to fix this issue.
@colts45s this is done. You can check and let us know incase of any concerns.
@tommysitu you can close this issue.
This has been fixed since https://github.com/SpectoLabs/hoverfly/releases/tag/v1.5.2