Performance Stub Walkthrough – Request Response Matching

The stub works by parsing any incoming requests on it's assigned IP and Port. It then attempts to match the request with the appropriate pre-defined response.

In this example/walkthrough we will guide you through creating the ACME stub simulating a service on an IIS web server, which we want to host on port 9000 and a method called "amIquick", when a request comes in for roadrunner we want to reply with some JSON saying true, when we request Wile_E we want to say false

Examples requests are:

http://localhost:9000/amIquick?name=roadrunner

http://localhost:9000/amIquick?name=wile_e

Example responses will be

{"answer": true}

{"answer": false}

Step 1 configuring the main window details.

On the main window by default we have an example HTPP and HTTPS stub. Go ahead an delete those. Notice that we can delete a stub when it's running, so stop the stub first, then delete it.

Step 2

We are simulating a service that exists on a single IP and port. Therefore we only need to add one new stub by clicking "Add New Stub" on the bottom right hand side of the main window.

Add new stub button

Add new stub button

Step 3

We need to populate the following fields.

DelayInMs - we can put a figure in here or leave as default. If we want to simulate a slow system this is where we would add the delay. If we want to simulate a slow method we can do this in the responses part later.

StubName - this is a friendly name for your stub, something that will help you identify it.

PerfMonEnabled - this will send metrics to perfmon so you can monitor the stub externally or through your load test tool.

BoundIp - this can be any IP address on the local machine, note that 0.0.0.0 is all local IPv4 addresses and 127.x.x.x is internal only.

BoundPort - This can be any available port, to see what ports are already in use (to avoid) use the following commands:

As administrator - netstat -aonb -p TCP | more

As any user- netstat -aon -p TCP | more

The difference between the two is that the first one will tell you the process that is using the port.

In our case we are using port 9000, if you use another port be sure to note it down for when we come to test the stub later.

Certificate details are covered in this walkthrough : Performance Stub Walkthrough : HTTPS and Certificates

Step 4

Now you have the main details for the stub in place it's time to setup some responses.

Below is a screenshot of our roadrunner example response

Sample for roadrunner repsonse

The important bits to note are that we are saying that our path and query must be like "roadrunner" to give this response and the response is populated with our JSON for answer=true

Now we want to add a response for wile_e. To do this click the add new button top left.

Below is the screenshot for our wile_e response, this time we check for wile_e and we respond with false.

Wile E example

Step 5

Save the changes and start the stub.

Step 6

Test the stub by opening a browser and trying the following URLs. Depending on your browser it will either download a text file containing JSON or display the raw JSON on the screen.

http://localhost:9000/amIquick?name=roadrunner

http://localhost:9000/amIquick?name=wile_e

Congratulations you've setup an ACME stub which will stand up to thousands of requests asking if either Wile E or Roadrunner are fast

Optional Steps

Add a default response, by clicking add new and making the path match "/"

Make it HTTPS by following the steps here Performance Stub Walkthrough : HTTPS and Certificates