0
0
Testing Fundamentalstesting~10 mins

Load testing concepts in Testing Fundamentals - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test simulates multiple users accessing a web application simultaneously to verify if the system can handle the expected load without performance degradation or failure.

Test Code - Locust
Testing Fundamentals
from locust import HttpUser, task, between

class WebsiteUser(HttpUser):
    wait_time = between(1, 3)

    @task
    def load_homepage(self):
        response = self.client.get("/")
        assert response.status_code == 200

    @task(3)
    def load_about_page(self):
        response = self.client.get("/about")
        assert response.status_code == 200

# To run this test, use the command: locust -f this_script.py --headless -u 10 -r 2 -t 30s
# This runs 10 users, spawning 2 users per second, for 30 seconds.
Execution Trace - 7 Steps
StepActionSystem StateAssertionResult
1Test starts by launching Locust with 10 users and spawn rate of 2 users per second.Locust initializes and prepares to simulate users.-PASS
2First simulated user opens the homepage by sending GET request to '/' endpoint.Web server receives request and processes it.Check that response status code is 200 (OK).PASS
3User waits between 1 to 3 seconds before next action.User is idle for a short random time.-PASS
4User sends GET request to '/about' page three times more frequently than homepage.Server processes multiple requests to '/about' endpoint.Each response status code must be 200.PASS
5More users spawn gradually until total 10 users are active, repeating the tasks.Server handles increasing load of simultaneous requests.All responses return status code 200 without errors.PASS
6Test runs for 30 seconds, monitoring server response times and error rates.Server performance metrics are collected.No server errors or timeouts occur during test duration.PASS
7Test ends and Locust generates a report summarizing requests, failures, and response times.Test report is available for analysis.Verify that failure count is zero and average response time is acceptable.PASS
Failure Scenario
Failing Condition: Server returns error status codes (e.g., 500) or times out under load.
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify when it checks that response status code is 200?
AThe server is overloaded.
BThe server successfully handled the request.
CThe user interface is visible.
DThe network connection is slow.
Key Result
Always verify server response codes during load testing to ensure the system handles expected user traffic without errors.