Applying different delays based on hostΒΆ
Now let’s apply a delay of 1 second on responses from time.jsontest.com
and a delay of 2 seconds on responses from date.jsontest.com
.
Run the following 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
Edit the simulation.json
file so that the "globalActions"
property looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | "globalActions": {
"delays": [
{
"urlPattern": "time\\.jsontest\\.com",
"httpMethod": "",
"delay": 1000
},
{
"urlPattern": "date\\.jsontest\\.com",
"httpMethod": "",
"delay": 2000
}
]
}
|
Now run the following to import the edited simulation.json
file and run the simulation:
hoverctl start
hoverctl import simulation.json
curl --proxy localhost:8500 http://time.jsontest.com
curl --proxy localhost:8500 http://date.jsontest.com
hoverctl stop
You should notice a 1 second delay on responses from time.jsontest.com
, and a 2 second delay on responses from date.jsontest.com
.
Note
You can easily get into a situation where your request URL has multiple matches. In this case, the first successful match wins.