question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to run test_start on workers.

See original GitHub issue

Is your feature request related to a problem? Please describe.

I have a load test where some setup is needed, but I really only need to do it once to set some global variables, that all spawned users to use.

Previously this was done with the HttpLocust.setup method. Unfortunately, now there is the test_start functionality which only runs on the master.

Describe the solution you’d like

Allow the test_start functionality to run on workers.

Describe alternatives you’ve considered

I can use the HttpUser.on_start method, but it results in ever single user that is spawned making a request (part of the work that I have to do in the setup), and it’s not ideal.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cyberwcommented, Jun 3, 2020

Also, if what you want it just to do some general one-off initialization (not in the context of a User), you can do it using the init event, which IS triggered on all locust processes:

from locust import events
from locust.runners import MasterRunner
...
@events.init.add_listener
def on_locust_init(environment, **kwargs):
    if not isinstance(environment.runner, MasterRunner):
        # do the setup work
0reactions
cyberwcommented, Sep 24, 2020

Is there a way to access the HTTP client from a listener? I want to be able to make a few HTTP requests to the target during the test_start event, but since that’s not within the User context I can’t do it.

In short, no, not from the test_start/stop events. But there is nothing stopping you from making an HTTP request ”manually”, using requests directly. It just wont be logged.

Read more comments on GitHub >

github_iconTop Results From Across the Web

mimic test_start test_stop events in distributed mode worker
when running in distributed mode, these events occur on the master, not the worker. I am assembling a list of detailed stats for...
Read more >
Javascript Web Workers Test (Source Code) - pmav.eu
startTime : null , // Current test start time. ... 154. this .run(test.workers, test.data.base, test.data.power, test.data.mod);. 155. this .benchmark.
Read more >
Run-Workers does not work for Gherkin / Cucumber BDD ...
Running Gherkin Features in Parallel does not work with run-workers . It repeats the Same Scenarios in each worker more than once.
Read more >
Validation of Physical Ability Tests for High Pressure Cleaning ...
Employees work in crews or teams which allows the workers to alternate performing the cleaning tasks. The Company wished to develop fair and...
Read more >
Modern React testing, part 4: Cypress and ... - Artem Sapegin
The best experience of writing and debugging tests. Ability to inspect the page at any moment during the test run using the browser...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found