Applying a delay to all responses¶
Let’s apply a 2 second delay to all responses. First, we need to create and export a simulation.
hoverctl start
hoverctl mode capture
curl --proxy localhost:8500 http://time.jsontest.com
curl --proxy localhost:8500 http://date.jsontest.com
hoverctl export simulation.json
hoverctl stop
Take a look at the "globalActions"
property within the simulation.json
file you exported. It
should look like this:
1 "globalActions": {
2 "delays": [],
3 "delaysLogNormal": []
Edit the file so the "globalActions"
property looks like this:
1 "globalActions": {
2 "delays": [
3 {
4 "urlPattern": ".",
5 "httpMethod": "",
6 "delay": 2000
7 }
8 ],
9 "delaysLogNormal": []
Hoverfly will apply a delay of 2000ms to all URLs that match the "urlPattern"
value. We want
the delay to be applied to all URLs, so we set the "urlPattern"
value to the regular expression "."
.
Now import the edited simulation.json
file, switch Hoverfly to Simulate mode and make the requests
again.
hoverctl start
hoverctl import simulation.json
curl --proxy localhost:8500 http://time.jsontest.com
curl --proxy localhost:8500 http://date.jsontest.com
hoverctl stop
The responses to both requests are delayed by 2 seconds.