0

I am just getting started with Locust. Here is my locustfile.py

from locust import HttpLocust, TaskSet, between, TaskSequence

def select_user(l):
    pass

def get_company(l, company):

    target = "https://URL"
    print(f"Company: {company} URL: {target}")

    response = l.client.get(target, {"name": company })

    return response

class UserBehavior(TaskSequence):

    def on_start(self):
        response = get_company(self, "LoadTest")
        print(response)

    # @seq_task(1)
    # def first_task(self):
    #     pass

class User(HttpLocust):
    tasks = [UserBehavior]
    wait_time = between(5, 60)

when I run locust in the same directory as locustfile.py I get the error:

% locust
[2020-05-15 20:43:08,131] host/ERROR/locust.main: No Locust class found!

It is unclear to me what I have wrong. I am using TaskSequence because once I get this working, I will be adding tasks which must be executed in a specific order.

Additionally, if I uncomment the @seq_task(1) decorator I get an error that seq_task is not defined.

This is on

% locust --version
locust 0.14.4
Chris Hare
  • 161
  • 2
  • 12

1 Answers1

0

The error message should actually have read "No Locust class with tasks found!".

Just uncomment your task and it will be found correctly.

For your other problem, you just need to import it: from locust import seq_task

Finding Locust classes to run is done a little bit different in locust 1.0, where Locust classes (actually called User now) are explicitly marked abstract (1.0 will be released soon, maybe even this week, so there is probably no point in clarifying it :)

seq_task is reworked as well

Cyberwiz
  • 11,027
  • 3
  • 20
  • 40