
Set up a development environment for Locust performance testing by installing Python and PyCharm, creating a project, and installing the Locust module, then run an example script to verify readiness.
Install Python 3.8.3 on windows (information for mac as well)
Install Locust on windows (information for mac as well)
https://www.qamilestone.com/post/setup-locust-on-linux-on-windows
Use Idle. Run the sample script.
Install Pycharm
Create a project in Pycharm
Install Locust in Project environment
Run Sample Script
View Locust web interface
Install Python 3.8.3 on Linux
https://www.qamilestone.com/post/steps-to-setup-python-3-8-on-linux
Create a virtual environment for Python 3.8.3
Install latest Locust version on top of Python 3.8.3
https://www.qamilestone.com/post/steps-to-setup-locust-on-linux
Copy & run sample script
Create basic Locust Script:
Create class inheriting locust User class
add wait_time
add task using task decorator
Inherit HTTPUser class & add host attribute in different ways
example & explanation for locust inbuilt wait functions between, constant, constant_pacing
Add multiple classes to a locust script and weight attribute
Explore Locust command line options and help, learn to run tests in headless mode, and define users, hash rate, runtime, and log file for performance testing.
--headless, -u,-r,-t , --logfile commandline option example
Example & explanation for task decorator . Define the execution ratio for tasks using weight.
Create TaskSet class separately or inline with the User class and define tasks within.
Use self.interrupt to exit a nested task set and trigger rescheduling to other modules in locust, while defining per-task weightage in cart and product modules to balance execution.
Create the first HTTP GET request and understand client attributes. Give a customized name to request in locust metrics.
Learn how to use the http post method to log in to tools.demo.com by sending username and password to login.php and inspecting the request in developer tools, for Locust 1.0.
Learn to extract response data from Locust requests using the response object, print status code and headers, and verify sequential tasks (launch URL then login) to assess script outcomes.
Complete flight booing flow using http post & verify response using catch_response=True
Retrieve cookie from a response and send it in the next task.
Copy the basic underscore cookie to an assignment cookie, then retrieve the session ID and user filter ID from login and pass both cookies in the auto code request.
Extract data using regex and pass to subsequent request
Complete the auto quote workflow by recording and validating each request with cookies, form data, and viewstate, using developer tools to observe post and get calls and responses.
Complete the agent lookup workflow using Locust, extracting cookies (including session id) and viewstate, converting form data to Python dict, and validating responses across login and search steps.
Create Taskset subclasses to main Taskset class to get close to a real-world scenarios where websites are divided into modules.
Create a script for REST API by sending JSON data format and receiving JSON response
Run script with multiple different users in 2 ways.
Fetch user data from csv
Parametrize the borland nested task script for performance testing by reading four user credentials from a csv via csv_utility and using Locust 1.0 to run with those users.
Explore linear vs step load models in locust, showing how total users, spawn rate, and step duration shape ramp-up in ui and headless modes for performance testing.
Learn to make a locust script os independent using the os module, dynamic root path, and join to handle data and config folders with yaml configuration.
Set up a distributed Locust environment on three Linux machines (master and two workers), install Python 3.8, create virtual environments, and run a 60-second headless test from GitHub.
Explore the Locust performance testing interface, run tests with a modified script, monitor statistics, and observe how failures are reported in the web interface.
Explore Locust 1.0 load test by configuring number of users, hatch rate, and host to control linear ramp-up, run swarm tests, and analyze the generated statistics.
Explore how to interpret performance data in Locust by analyzing min, max, average, median, and percentile metrics with real-time statistics, charts, and outlier considerations.
Explore how requests per second (RPS) and user counts drive performance insights in Locust, and analyze average size, response time, and chart data for performance testing.
Learn to retrieve locust test statistics in csv format by configuring csv downloads, the distribution and request csv files, and the interval and runtime options during test runs.
Discover how locust uses event hooks to listen for and fire events, attach handlers, and customize behavior with custom events for extensible performance testing.
Create two custom event handlers for request_success and request_failure in Locust to print per-request data to the console, including metadata such as request type, name, length, and exception.
Learn to implement Locust performance tests with success and failure handlers, print and format per-request data, then accumulate and export results to CSV.
modularize the Locust framework by splitting into three scripts: a custom client with protocol methods and a time-measure decorator that fires events, plus a dedicated Locust file to orchestrate them.
Create a Locust-based ftp performance test using a Python ftp client to connect to an ftp server, log in, change to the target directory, retrieve readme.txt, and disconnect.
Learn how to implement a simple FTP client Locust script to connect, login, download a file, and disconnect, with welcome and login verifications and basic error handling.
Hello,
It's time to swarm your application by modern load testing framework - Locust!
It's easy to start & quick to understand. It simply figures out how many concurrent users an application handle. It is supported by the most popular language python which makes it highly flexible!
It offers highly scalable and distributed testing and all this comes at no cost! There is no reason why you should not learn this light & yet highly powerful tool. It could be an effective tool for both developers & testers.
Here in this course, I will take you through deeper sections of the tool and make sure that you get highly enabled to use this wonderful tool. Multiple assignments at each step will make you more confident about the concepts learned. Additionally, all the scripts walked through during lectures, and also the solution to the assignment are available in corresponding resources of the lectures.
In case of queries/issues, I would try to respond as early as possible.
Happy Learning!
Anuradha