Locust Load Testing running into infinite loop

1.2k Views Asked by At

i am really new to Python with Locust load testing. I Created the below Python script but its running into infinite loop. I have used Number of total users to simulate = 1 Spawn rate = 1

Please let me know where i am going wrong.

from locust import HttpUser, task, between, TaskSet


class Behaviour(TaskSet):

    @task
    def first_task(self):
        self.client.get('/LoginHome.aspx')
 
class WebsiteTestUser(HttpUser):
    tasks = [Behaviour]
    wait_time = between(5, 15)
    host = "http://DEV/LoadTesting"

Thanks.

1

There are 1 best solutions below

0
On

It doesn’t look like you’ve done anything wrong. I assume by “infinite loop” you mean that you tell it to spawn 1 user and then one user starts but then you get repeated requests to your endpoint that you defined in your task until you stop Locust.

This is by design. When one Locust user finishes its tasks, a new one is spawned in its place. Locust will try to keep the specified number of users running indefinitely. As a load test tool, you’re not telling it to run the defined tasks X number of times, you define a user flow from start to finish and then tell it the number of users you want to throw at your system you’re testing to make sure/find out if your system can handle the load you want.