I am running two client classes inside of a locust file. When I run with --no-web -c 1 -r 1 for testing purposes, the runner was not starting and showing this in the logs:
[2018-12-17 14:40:38,640] ubuntu/INFO/locust.runners: Hatching and swarming 0 clients at the rate 1 clients/s...
[2018-12-17 14:40:38,640] ubuntu/INFO/locust.runners: All locusts hatched: ScenarioPOSTGET: 0, ScenarioPOSTPUTGET: 0
[2018-12-17 17:11:35,855] ubuntu/INFO/locust.runners: All locusts dead
The problem is in runners.py.weight_locusts.py; lines 82 & 83 (see below)
def weight_locusts(self, amount, stop_timeout = None):
"""
Distributes the amount of locusts for each WebLocust-class according to it's weight
returns a list "bucket" with the weighted locusts
"""
bucket = []
weight_sum = sum((locust.weight for locust in self.locust_classes if locust.task_set))
for locust in self.locust_classes:
if not locust.task_set:
warnings.warn("Notice: Found Locust class (%s) got no task_set. Skipping..." % locust.__name__)
continue
if self.host is not None:
locust.host = self.host
if stop_timeout is not None:
locust.stop_timeout = stop_timeout
# create locusts depending on weight
percent = locust.weight / float(weight_sum) # this is 0.5
num_locusts = int(round(amount * percent)) # round of 0.5 is -> '0' :(
bucket.extend([locust for x in xrange(0, num_locusts)])
return bucket
Recommend using math.ceil if percent < 1
Expected behavior
The runner should execute my 2 scenarios in this situation.
Actual behavior
It does not and shows the locusts are dead.
Environment settings (for bug reports)
OS: ubuntu 18.04
Python version: 3.6.6
Locust version: 0.9.0
Steps to reproduce (for bug reports)
1) Create a test with 2 client classes:
e.g.
class ScenarioPOSTGET(HttpLocust):
print("inside ScenarioPOSTGET")
task_set = PostAndGetTask
host = "http://10.203.0.70:30112"
class ScenarioPOSTPUTGET(HttpLocust):
print("inside PostPutAndGetTasks")
task_set = PostPutAndGetTasks
host = "http://10.203.0.70:30112"
Run this way:
locust -f locust_test.py --no-web -c 1 -r 1 --run-time 8s
Description of issue / feature request
I am running two client classes inside of a locust file. When I run with --no-web -c 1 -r 1 for testing purposes, the runner was not starting and showing this in the logs:
[2018-12-17 14:40:38,640] ubuntu/INFO/locust.runners: Hatching and swarming 0 clients at the rate 1 clients/s... [2018-12-17 14:40:38,640] ubuntu/INFO/locust.runners: All locusts hatched: ScenarioPOSTGET: 0, ScenarioPOSTPUTGET: 0 [2018-12-17 17:11:35,855] ubuntu/INFO/locust.runners: All locusts dead
The problem is in runners.py.weight_locusts.py; lines 82 & 83 (see below)
Recommend using math.ceil if percent < 1
Expected behavior
The runner should execute my 2 scenarios in this situation.
Actual behavior
It does not and shows the locusts are dead.
Environment settings (for bug reports)
Steps to reproduce (for bug reports)
1) Create a test with 2 client classes: e.g.
Run this way: locust -f locust_test.py --no-web -c 1 -r 1 --run-time 8s