Skip to content

Instantly share code, notes, and snippets.

@jacobben85
Created August 1, 2016 03:24
Show Gist options
  • Select an option

  • Save jacobben85/990ddaa9ea6bcdc47f40d9c0de8d8b4c to your computer and use it in GitHub Desktop.

Select an option

Save jacobben85/990ddaa9ea6bcdc47f40d9c0de8d8b4c to your computer and use it in GitHub Desktop.
from locust import HttpLocust, TaskSet, task
# https://httpbin.org/post
# locust -f loadtest.py --host=https://httpbin.org
class WebsiteTasks(TaskSet):
# def on_start(self):
# self.client.post("/login", {
# "username": "test_user",
# "password": ""
# })
@task
def get(self):
response = self.client.get("/get")
print "Create; Response status code:", response.status_code
@task
def post(self):
with open('resources/xac/xacml.xml', 'r') as content_file:
content = content_file.read()
payload = content
headers = {"Content-Type": "application/xml"}
response = self.client.post("/post", data=payload, headers=headers)
print "Create; Response status code:", response.status_code
class WebsiteUser(HttpLocust):
task_set = WebsiteTasks
min_wait = 5000
max_wait = 15000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment