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.

Parametrized LoadTestShape

See original GitHub issue

It’d be nice if we were able to parametrize custom LoadTestShapes. For example control peak number of users or test duration as a whole.

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

I want to measure resources utilization for different amount of users. To achieve that I’ve prepared usage characteristics from our logs and want to see how much more users we can support with current hardware. To do that I want to test my service with different peak user counts - e.g. 1k, 2k, 3k, etc. For now it’s really frustrating to do because I always need to change that value in file.

Describe the solution you’d like

I’d be nice if we were able to access some kind of context information from LoadTestShape that could contain configuration in form of simple dictionary. e.g.

def tick(self):
    max_users = self.context.parameters['max_users']
    ...

Parameters could be set via HTTP form <input name="load_parameter[max_users]" /> or CLI parameter: --load-parameter max_users=200.

HTTP form could be changed by wraping it with some block and thus allowing to easily overwrite it with custom form.

Describe alternatives you’ve considered

For CLI usage probable environment variables would be good enough, but for HTTP it’s not really viable - especially because we’re using k8s.

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
kadet1090commented, Nov 19, 2020

I tought more about being able to overwrite actual form and provide our own html (via template extending, for example, or some other way):

{% extend 'path/to/templates/index.html' %}

{% block swarm_form %}
    <label for="peak_count">Number of peak users to simulate</label>
    <input type="text" name="parameter[peak_count]" id="peak_count" value="1000" class="val"/><br>
    <label for="total_time">Total time of the load (in seconds)</label>
    <input type="text" name="parameter[total_time]" id="total_time" value="600" class="val"/><br>
{% endblock %}

And it would look like this: image

It’d require change to templates/index.html by wraping it with {% block swarm_form %}{% endblock %}. Then everything that was sent by form inside parameter dictionary should be accessible to LoadTestShape.

By default we could of course just display <textarea name="parameter[data]"></textarea> that could be parsed - so if someone for any reason don’t want to be bothered with HTML modification.

I could try to achieve something like that in free time, and give you some kind of response how hard was to implement that (eventually submit PR if it’d be good enough) 😃

1reaction
max-rocket-internetcommented, Nov 19, 2020

OK I see. Sounds good. There was some previous PR IIRC about making the UI more editable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom load shapes — Locust 2.14.0 documentation
Define a class inheriting the LoadTestShape class in your locust file. ... If you use the Web UI, you can add the —class-picker...
Read more >
How to select the load shape class from command line?
Define a class inheriting the LoadTestShape class in your locust file. If this type of class is found then it will be automatically...
Read more >
Parameterize load tests with secrets and environment variables
Learn how to create configurable load tests by using secrets and environment variables as parameters in Azure Load Testing.
Read more >
locust/CHANGELOG and locust Releases (Page 9) | LibHunt
Remove step load feature now that LoadTestShape is possible? ... Add missing parameter to render_template to grey out UI fields #1533 (max-rocket-internet) ...
Read more >
Use start_automatic_run in locust With Examples | LambdaTest
... 26from .shape import LoadTestShape 27from .input_events import input_listener ... 148 sys.stderr.write("[DEPRECATED] The --hatch-rate parameter has been ...
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