The tool supports and provide a rich envirnoment for http/https protocol based load testing.
Current project is build using locust version 0.9.0
and python 3.6
. It is also writtten to configure with CI tools such as Jenkins with Dashboard and Email reports functionality.
- Download and Install python version 3.6 based on your device from https://www.python.org/downloads/
- Install locust version 0.9.0 via https://docs.locust.io/en/latest/installation.html
- Plotly
- Panda
- Yattag
- Ymal
There are very basic steps which are needed to be followed :
- Add an API for which you need to make a request to
data/requests.yaml
API_1 :
TYPE : POST
ENDPOINT :
HEADERS :
Content-Type : application/json
BODY :
ent_id:
password:
remember_me:
service:
user_name:
API_1
is your API description.TYPE
is your HTTP/HTTPS request type.ENDPOINT
is your api end point.HEADERS
are the header which you want to send with your request.BODY
is your body container.(Currently it resembles a json body but can be modified as well)
- Create a test class inside
locust/tests/
where we can add a test something like:
class DemoTest(TaskSet):
@task
def test_demo(self):
request = model.RequestModel('API_1')
response = http_request.make_post_request(self.client, request)
if response.status_code == 200 :
response.success()
else :
response.failure('Wrong Response Code')
- Firstly a
request
object is created forAPI_1
via model class present atlocust/packages/models.py
. request
object is passed tomake_post_request
method atlocust/packages/requests_handler.py
which is generic function for making POST requests.- The returned
response
object is then used to validate via assertions.
- Add your class to
locustfile.py
.
There are basically two ways to launch/run the project :
You could directly run the current test set by launching a command prompt / shell based on your choice of operating system and type in locust --host=<Your Host Name>
in there inside your project directory. This will launch the localserver at 8089 port from where you could provide the number of user and hatch rate.
You could directly run the current test set by launching a command prompt / shell based on your choice of operating system and type in locust --host=<Your Host Name> --csv=responses --no-web -c 1000 -r 100 -t 1m
in there inside your project directory. You could look up here https://docs.locust.io/en/stable/running-locust-without-web-ui.html for more details.
Steps
- Create a freestyle project.
- Under
Source Code Management
provide repository path. - Under
Build
chooseExecute Shell
option and type in following in the command area :
locust --host=<Your Host Name> --csv=responses --no-web -c 1000 -r 100 -t 1m
python generate_reports.py $JENKINS_HOME\\jobs\\$JOB_NAME\\builds\\$BUILD_NUMBER\\log
- Configur Email notifications with email template path as
reports\\email_summary.html
. - Configure HTML Publisher Plugin with path
reports\\dashboard_summary.html
.