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 "globalActions": {
2 "delays": [
3 {
4 "urlPattern": "time\\.jsontest\\.com",
5 "httpMethod": "",
6 "delay": 1000
7 },
8 {
9 "urlPattern": "date\\.jsontest\\.com",
10 "httpMethod": "",
11 "delay": 2000
12 }
13 ],
14 "delaysLogNormal": []
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.