In this second part, I’m showing how to perform real load tests
Carry out load test with loader.io
Phan Binh Minh (PBM), senior QA of the Safewhere team, knows a thing or two about doing load testing which she wrote about in this post.
In Part 1, I described how to register an account on loader.io. In this second part, I’m showing how to perform real load tests for simple OAuth 2.0 flows in which a client sends a request to a server and receives a response.
Add and run a test
Firstly, we need to add a new test by selecting [+ New Test] on the [Tests] tab:
Enter test settings as below:
In which:
- Name: name of your test
- Test type: select [Clients per second] for load testing.
- Clients: number of clients that will send requests concurrently to your domain per second
- Duration: time to run this test
For example, settings in the screenshot above mean loader.io will send 48 requests/second concurrently to my web application over the period of 1 minute.
Set up load test for the refresh token flow
This is a typical OAuth 2.0 flow: a client application uses a refresh token to exchange for a new access token:
In which:
- Method, Protocol, Host, Path are information to access my service’s endpoint
- Headers: describe my actual content type of data that will be sent to the server. Other http headers also go here.
- Parameters & Request Body: add 3 parameters:
- grant_type: because this test is used for testing the refresh token flow, the value of this field is “refresh_token”
- refresh_token: the refresh token that will be used to exchange the access token. client_id: client id of a test client application
Set up load test for the client credentials flow
This test case is similar to the test case above, but instead it needs to send client credentials, client ID and client secret to the authorization server.
After adding the test, click [Run Test] to start testing the server’s endpoint:
Result
After sending 48 requests/second concurrently to my web application over the period of 1 minute, the result is:
Summary
Loader.io is a very useful tool to perform load tests for web applications. However, its free plan allows for running tests for one minute. Running longer tests needs a paid plan.
References
- https://loader.io/
- https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2#grant-type-client-credentials
-Phan Binh Minh-