Last active
August 29, 2015 13:57
-
-
Save Batou99/9804561 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from locust import HttpLocust, TaskSet, task | |
from random import randint | |
class UserBehavior(TaskSet): | |
HEADERS = { "Accept": "application/vnd.myvendor+json; version=2" } | |
TOPICS = [452, 459, 460, 461, 462, 467, 470, 477, 479, 521, 524, 582, 591, 609, 506, 510, 513, 514, 515, 520, 525, 526, 527, 529, 530, 531, 532, 133, 282, 429] | |
@task(2) | |
def topics(self): | |
page = randint(1,10) | |
url = "/api/topics.json?page=%(page)s" % locals() | |
self.client.get(url, headers=self.HEADERS) | |
@task(3) | |
def debate(self): | |
topic = self.TOPICS[randint(0,29)] | |
url = "/api/user_topics/%(topic)s/content.json" % locals() | |
self.client.get(url, headers=self.HEADERS) | |
class WebsiteUser(HttpLocust): | |
task_set = UserBehavior | |
min_wait=5000 | |
max_wait=9000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment