Skip to content

Instantly share code, notes, and snippets.

@keegoo
Created June 9, 2020 16:02
Show Gist options
  • Save keegoo/a4d35e4c28bcdf516e8d05b495335103 to your computer and use it in GitHub Desktop.
Save keegoo/a4d35e4c28bcdf516e8d05b495335103 to your computer and use it in GitHub Desktop.
from locust import HttpUser, task, between
import uuid
class User(HttpUser):
wait_time = between(5, 9)
@task
def scenario_01(self):
self.view_computer()
self.create_computer()
def create_computer(self):
suffix = uuid.uuid4().hex
payload = {
'name': 'test_{}'.format(suffix),
'introduced': '2020-06-06',
'discontinued': '2020-06-07',
'company': '1'
}
res = self.client.post('computers', data=payload)
print(res)
def view_computer(self):
res = self.client.get('computers')
# trigger locust through cli
# locust -f locustfile.py --host=http://computer-database.gatling.io/ --headless -u 10 -r 10 -t=10s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment