Created
August 17, 2020 17:07
-
-
Save snackattas/b38c461e25e79cc92213cf0a82b15823 to your computer and use it in GitHub Desktop.
Sample locust taskset showing off Setup happening outside locust hooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Setup(object): | |
ACCOUNT_ID = None | |
USER_SESSION = None | |
LOCATION_IDS = None | |
REVIEW_IDS = None | |
def __init__(self): | |
self.ACCOUNT_ID = environ.get('ACCOUNT_ID') | |
self.USER_SESSION = self.create_user_session() | |
self.LOCATION_IDS = self.get_location_ids_from_db() | |
self.REVIEW_IDS = self.get_review_ids_from_db() | |
class Entrypoint(HttpUser): | |
Setup() # this will only run once | |
tasks = [MainTask] | |
class MainTask(TaskSet): | |
def on_start(self): | |
self.account_id = Setup.ACCOUNT_ID | |
self.user_session = Setup.USER_SESSION | |
self.location_ids = Setup.LOCATION_IDS | |
self.review_ids = Setup.REVIEW_IDS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment