Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment Variables for Locust playbooks #244

Closed
vasiliyb opened this issue Feb 15, 2015 · 4 comments
Closed

Environment Variables for Locust playbooks #244

vasiliyb opened this issue Feb 15, 2015 · 4 comments

Comments

@vasiliyb
Copy link

Folks,
Is there a way to pass the host variable into the playbook?

class MainPageSet(TaskSet):
    # Main Page
    @task(1)
    def main_page(self):
        response = self.client.get("${URI}")

class UserBehaviour(TaskSet):
    tasks = {MainPageSet:10}

class MainPage(HttpLocust):
    host = "${HOSTNAME}"
    task_set = UserBehaviour
    min_wait = 1000
    max_wait = 1000%

In other words, I would like to pass in http://foo.com and /index.html into the playbook as parameters ${HOSTNAME} and ${URI}. Is this possible?

Thanks!

@heyman
Copy link
Member

heyman commented Feb 16, 2015

Sorry, I'm no sure what it is you want to do, so I'm guessing here. Could you use environment variables to pass in variables?

import os

class MainPage(HttpLocust):
    host = os.environ.get("LOCUST_HOST")

I might be misunderstanding what it is you want to do. Perhaps you could elaborate?

@vasiliyb
Copy link
Author

great! that will work :) Thanks

@ruchikaChawla
Copy link

Hello Everyone,

I were using jmeter till now but i saw it is taking lots of resources and memory to run,
so now i started reading locust. i am new to locust.
i want to use locust in no-web mode e.g $ locust -f locust_files/my_locust_file.py --no-web -c 1000 -r 100 but same as above question , i dont want to hard code the URL or you can say header parameter like unique request id and all, i want to pass it from command line, like we can pass in jmeter and we can get it in configuration file using __P() function.
how we can get the same thing in locust, i know the way of using environment variables but i do not want to use this.

@ruchikaChawla
Copy link

Hello Everyone,

I were using jmeter till now but i saw it is taking lots of resources and memory to run,
so now i started reading locust. i am new to locust.
i want to use locust in no-web mode e.g $ locust -f locust_files/my_locust_file.py --no-web -c 1000 -r 100 but same as above question , i dont want to hard code the URL or you can say header parameter like unique request id and all, i want to pass it from command line, like we can pass in jmeter and we can get it in configuration file using __P() function.
how we can get the same thing in locust, i know the way of using environment variables but i do not want to use this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants