myzhan / locust4j

Locust4j is a load generator for locust, written in Java.
MIT License
81 stars 30 forks source link

Analysing Locust4j - Performance test #17

Closed sirisha-potluri closed 4 years ago

sirisha-potluri commented 4 years ago

I'm exploring Locust for performance test our applications. Would like to reuse the existing Java page objects(selenium web elements) instead of rewriting in Python. Issue: I try to invoke a particular count of users, by entering in the textbox "Number of total users to simulate" (on the locust ui) but actually runs into an infinite loop spawning users forever.

  1. How do I control the no. of requests.
  2. Is this a right approach, where I'm trying to fire Selenium events instead of http get/post requests Attaching the code snippet testcode.TXT

Thanks, Sirisha

myzhan commented 4 years ago

Because the "execute" method runs in an infinite loop, you can't control the number of requests. Instead, you have control of thread-concurency and request per second(aka RPS).

If you really want to control the number of requests, try to keep a counter of requests and do nothing but sleeping in the "execute" method when the threshold exceeded.

myzhan commented 4 years ago

BTW, performance testing using Selenium and WebDriver is generally not advised.

See aslo, https://www.selenium.dev/documentation/en/worst_practices/performance_testing/

sirisha-potluri commented 4 years ago

Because the "execute" method runs in an infinite loop, you can't control the number of requests. Instead, you have control of thread-concurency and request per second(aka RPS).

If you really want to control the number of requests, try to keep a counter of requests and do nothing but sleeping in the "execute" method when the threshold exceeded.

Thanks for the quick response! We also have developed a prototype in python for firing selenium events. But in python, there seems to be no problem as The no. of users input on the locust UI spins up exactly the sam locustfile_python.TXT e count of browsers through selenium. How is it controlled in Python. Attaching the code for reference.