I'm new to Locust and want to create a simple test to simulate users making HTTP GET requests to a website. How do I structure my `locustfile.py` for this? Please provide a minimal Python code example that includes defining user behavior, making a basic HTTP GET request, and setting a wait time between requests. Explain what each key part of the code does.
Navigate to 'docs.locust.io'. Click on the 'Writing a locustfile' link. Identify the basic structure of a `locustfile.py` for HTTP testing, specifically using the `HttpUser` class. Locate how tasks (user actions) are defined using the `@task` decorator. Find an example of how to make an HTTP GET request using `self.client.get()` within a task. Identify the `wait_time` attribute and its purpose. Synthesize this information into a minimal code example and provide explanations for the `HttpUser` class, `@task` decorator, `self.client.get()` method, and `wait_time` attribute.
The agent successfully navigates to the 'Writing a locustfile' page. The agent provides a minimal Python code example for a `locustfile.py` that includes: - A class inheriting from `HttpUser`. - At least one method decorated with `@task`. - An example of an HTTP GET request using `self.client.get('/')` or similar. - A `wait_time` attribute (e.g., `wait_time = between(1, 5)` or similar). The agent explains that the `HttpUser` class is used to define simulated users that can make HTTP requests. The agent explains that the `@task` decorator defines methods that represent user actions. The agent explains that `self.client.get()` (or similar methods like `post`, `put`) is used to make HTTP requests. The agent explains that the `wait_time` attribute defines the pause between the execution of tasks for a user.