Skip to content

Instantly share code, notes, and snippets.

@bodharma
Created October 10, 2018 15:46
Show Gist options
  • Select an option

  • Save bodharma/1f53c8a77a3545adadb5790de0c78475 to your computer and use it in GitHub Desktop.

Select an option

Save bodharma/1f53c8a77a3545adadb5790de0c78475 to your computer and use it in GitHub Desktop.

Revisions

  1. velocyno created this gist Oct 10, 2018.
    26 changes: 26 additions & 0 deletions locust_different_users.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    from locust import HttpLocust, TaskSet, task
    import logging, sys
    from credentials import *

    class LoginWithUniqueUsersSteps(TaskSet):
    email = "NOT_FOUND"
    password = "NOT_FOUND"

    def on_start(self):
    if len(USER_CREDENTIALS) > 0:
    self.email, self.password = USER_CREDENTIALS.pop()

    @task
    def login(self):
    self.client.post("/login", {
    'email': self.email, 'password': self.password
    })
    logging.info('Login with %s email and %s password', self.email, self.password)

    class LoginWithUniqueUsersTest(HttpLocust):
    task_set = LoginWithUniqueUsersSteps
    host = "http://blazedemo.com"
    sock = None

    def __init__(self):
    super(LoginWithUniqueUsersTest, self).__init__()