{"action":"created","issue":{"url":"https://api.github.com/repos/locustio/locust/issues/766","repository_url":"https://api.github.com/repos/locustio/locust","labels_url":"https://api.github.com/repos/locustio/locust/issues/766/labels{/name}","comments_url":"https://api.github.com/repos/locustio/locust/issues/766/comments","events_url":"https://api.github.com/repos/locustio/locust/issues/766/events","html_url":"https://github.com/locustio/locust/issues/766","id":309383919,"number":766,"title":"Wrong tasks weight calculation over several TaskSet's","user":{"login":"mkusz","id":9740637,"avatar_url":"https://avatars3.githubusercontent.com/u/9740637?v=4","gravatar_id":"","url":"https://api.github.com/users/mkusz","html_url":"https://github.com/mkusz","followers_url":"https://api.github.com/users/mkusz/followers","following_url":"https://api.github.com/users/mkusz/following{/other_user}","gists_url":"https://api.github.com/users/mkusz/gists{/gist_id}","starred_url":"https://api.github.com/users/mkusz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkusz/subscriptions","organizations_url":"https://api.github.com/users/mkusz/orgs","repos_url":"https://api.github.com/users/mkusz/repos","events_url":"https://api.github.com/users/mkusz/events{/privacy}","received_events_url":"https://api.github.com/users/mkusz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-03-28T14:09:56Z","updated_at":"2018-03-29T14:55:57Z","closed_at":null,"author_association":"NONE","body":"### Description of issue / feature request\r\n\r\nDefining weight of tasks spread across more than one `TaskSet` lead to a wrong probability of task execution. Take a look at the following code:\r\n\r\n```\r\nfrom locust.core import HttpLocust, task, TaskSet\r\n\r\nclass LightSet(TaskSet):\r\n    @task(1)\r\n    def light_1(self):\r\n        print('Light 1')\r\n\r\nclass HeavySet(TaskSet):\r\n    @task(100)\r\n    def heavy_1(self):\r\n        print('Heavy 1')\r\n\r\nclass Light(HttpLocust):\r\n    task_set = LightSet\r\n    weight = 1\r\n    host = 'localhost'\r\n\r\nclass Heavy(HttpLocust):\r\n    task_set = HeavySet\r\n    weight = 1\r\n    host = 'localhost'\r\n```\r\n### Actual and expected behavior\r\n\r\nUsing above code, my expectation is to execute `heavy_1` over 100 times more likely than `light_1`.\r\nIt's not happening. Instead, both task probability of execution is 1:1.\r\nWhen both tasks are in the same `TaskSet` it works as expected.\r\nWhen we add dummy task to `Heavy` like this:\r\n```\r\n@task(1)\r\n    def dummy(self):\r\n        pass\r\n```\r\nEverything started to work correctly.\r\nIt seems that weight calculation is always against task with lowes weight not one common value for all `TaskSet`'s.\r\n\r\n### Environment settings (for bug reports)\r\n\r\n- OS: Ubuntu 16.04 and Windows 10\r\n- Python version: 3.6 (not tested on other but I expect the same)\r\n- Locust version: 0.8\r\n\r\n### Steps to reproduce (for bug reports)\r\n\r\nDescribed above."},"comment":{"url":"https://api.github.com/repos/locustio/locust/issues/comments/377262200","html_url":"https://github.com/locustio/locust/issues/766#issuecomment-377262200","issue_url":"https://api.github.com/repos/locustio/locust/issues/766","id":377262200,"user":{"login":"aldenpeterson-wf","id":17010500,"avatar_url":"https://avatars0.githubusercontent.com/u/17010500?v=4","gravatar_id":"","url":"https://api.github.com/users/aldenpeterson-wf","html_url":"https://github.com/aldenpeterson-wf","followers_url":"https://api.github.com/users/aldenpeterson-wf/followers","following_url":"https://api.github.com/users/aldenpeterson-wf/following{/other_user}","gists_url":"https://api.github.com/users/aldenpeterson-wf/gists{/gist_id}","starred_url":"https://api.github.com/users/aldenpeterson-wf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aldenpeterson-wf/subscriptions","organizations_url":"https://api.github.com/users/aldenpeterson-wf/orgs","repos_url":"https://api.github.com/users/aldenpeterson-wf/repos","events_url":"https://api.github.com/users/aldenpeterson-wf/events{/privacy}","received_events_url":"https://api.github.com/users/aldenpeterson-wf/received_events","type":"User","site_admin":false},"created_at":"2018-03-29T14:55:57Z","updated_at":"2018-03-29T14:55:57Z","author_association":"CONTRIBUTOR","body":"> @aldenpeterson-wf It won't work \r\n\r\nOops. Needs to be:\r\n\r\n```\r\nclass LightAndHeavy(HttpLocust):\r\n    class AllTasks(TaskSet):\r\n        task_set = [LightSet , HeavySet]\r\n    task_set = AllTasks\r\n```\r\n\r\n> Mostly because of the third point, I think that all weights should be calculated against one common value not the task with the lowest weight.\r\n\r\n\r\nThis isn't really the idea behind locust though. The paradigm Locust is designed with is to simulate _users_ that have task sets associated with the users. What you are requesting is more of a \"lots of users that all share a task set.\"\r\n\r\nYou could pretty easily accomplish what you are looking to do with a custom client, too."}}
{"actor":{"display_login":"aldenpeterson-wf"}}