Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.