Locust : Not able to use the config value from env file

40 Views Asked by At

I am trying to run a locust test but I am not able to use the .env file values

.env file contains "Value": diuqriqjqj

In the locust.py I have added

apiKey = os.environ.get("VALUE", "")
class Api(HttpUser):
    wait_time = between(1, 5)

    @task
    def test_api(self):
        self.client.get(
            f"/api/test/apiKey={apiKey}"
        )

I run the locust using

if test -f .env; then locust -f locust.py; fi

and receive connection errors. If I hardcode the apiKey value all works fine.

1

There are 1 best solutions below

0
Tanu On BEST ANSWER
ifneq (,$(wildcard ./.env))
    include .env
    export
endif
        env VALUE =$(VALUE) locust -f locust.py