Skip to content

Instantly share code, notes, and snippets.

@Batou99
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Batou99/9804561 to your computer and use it in GitHub Desktop.
Save Batou99/9804561 to your computer and use it in GitHub Desktop.
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