Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run results show tasks action ratio may be incomprehensible。 #1003

Closed
zhu-xiangtao opened this issue Apr 21, 2019 · 1 comment
Closed

Run results show tasks action ratio may be incomprehensible。 #1003

zhu-xiangtao opened this issue Apr 21, 2019 · 1 comment

Comments

@zhu-xiangtao
Copy link

Description of issue

In Locust tasks class,define some specific tasks(just use ‘seq_task’ decorate, not use 'task' decorate),also use 'tasks' attribute associate these specific tasks,run results show tasks action ratio may be incomprehensible。

Environment settings

  • OS: Win10
  • Python version: Python 2.7
  • Locust version: 0.11.0

Steps to reproduce (for bug reports)

Locust tasks class as below:

class WebsiteTasks(TaskSequence):

def on_start(self):
    print "start hello imooc..."

@seq_task(1)
def hello_imooc(self):
    self.client.get("/imooc")

@seq_task(2)
def hello_imooc_1(self):
    self.client.get("/imooc_1")

@seq_task(3)
def hello_imooc_2(self):
    self.client.get("/imooc_2")

tasks = {hello_imooc:1, hello_imooc_1:4, hello_imooc_2:2}

Locust user class as below:

class WebsiteUser(HttpLocust):
"""test"""
task_set = WebsiteTasks
host = "http://www.imooc.com"

run in window cmd as below:

locust -f demo.py --logfile=111.log

In web use 1 uses and 1 hatch rate, run a moment, I found task 'hello_imooc' 、'hello_imooc_1'、‘helo_imooc_2’ requests ratio about 1:2.375:1.125,I think the raito may be about 1:4:2

In Locust.core.TaskSetMeta.init , I print some information

print "old_tasks: {}".format(new_tasks)
for item in six.itervalues(classDict):
print "item: {}".format(item)
print hasattr(item, "locust_task_weight")
if hasattr(item, "locust_task_weight"):
print "item lociust task weight: {}".format(item.locust_task_weight)
for i in xrange(0, item.locust_task_weight):
new_tasks.append(item)
print new_tasks

    print "new_tasks: {}".format(new_tasks)

In log file:

old tasks list, 'hello_imooc' 、'hello_imooc_1'、‘helo_imooc_2’, raito is 1:4:2

[2019-04-21 13:14:12,914] PC-20190216VJAU/INFO/stdout: old_tasks: [<function hello_imooc_1 at 0x0000000004F20F98>, <function hello_imooc_1 at 0x0000000004F20F98>, <function hello_imooc_1 at 0x0000000004F20F98>, <function hello_imooc_1 at 0x0000000004F20F98>, <function hello_imooc at 0x0000000004F20F28>, <function hello_imooc_2 at 0x0000000004F3B048>, <function hello_imooc_2 at 0x0000000004F3B048>]

new taks list, every task add one , raito is 2:5:3, as web run result。
[2019-04-21 13:14:12,914] PC-20190216VJAU/INFO/stdout: new_tasks: [<function hello_imooc_1 at 0x0000000004F20F98>, <function hello_imooc_1 at 0x0000000004F20F98>, <function hello_imooc_1 at 0x0000000004F20F98>, <function hello_imooc_1 at 0x0000000004F20F98>, <function hello_imooc at 0x0000000004F20F28>, <function hello_imooc_2 at 0x0000000004F3B048>, <function hello_imooc_2 at 0x0000000004F3B048>, <function hello_imooc_2 at 0x0000000004F3B048>, <function hello_imooc_1 at 0x0000000004F20F98>, <function hello_imooc at 0x0000000004F20F28>]

In Locust.core.seq_task, if task have no locust_task_weight attribute,will be assignment default value 1

def seq_task(order):
def decorator_func(func):
func.locust_task_order = order
if not hasattr(func, 'locust_task_weight'):
func.locust_task_weight = 1
return func

return decorator_func

I just think the weight raito should be make clear。
thanks

@cgoldberg
Copy link
Member

can you be much more clear? I really have no idea what this issue report is about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants