Applying different delays based on host

Now let’s apply a delay of 1 second on responses from api.ipify.org and a delay of 2 seconds on responses from httpbin.org.

Run the following to create and export a simulation.

hoverctl start
hoverctl mode capture
curl --proxy localhost:8500 http://api.ipify.org
curl --proxy localhost:8500 http://httpbin.org
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": "api\\.ipify\\.org",
 5               "httpMethod": "",
 6               "delay": 1000
 7            },
 8            {
 9               "urlPattern": "httpbin\\.org",
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://api.ipify.org
curl --proxy localhost:8500 http://httpbin.org
hoverctl stop

You should notice a 1 second delay on responses from api.ipify.org, and a 2 second delay on responses from httpbin.org.

Note

You can easily get into a situation where your request URL has multiple matches. In this case, the first successful match wins.