Reputation: 834
We have two tasks under the same class, both are pointing to different hosts.
Example: First task (Create a new token) pointing to host - HTTP://xyz.abc.new Second task (Create a new token-old) pointing to host- HTTP://xyz.abc.old
import time
from locust import User, HttpUser, task, between, SequentialTaskSet
class LoginTaskSet(SequentialTaskSet):
@task
def generate_token(self):
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
launch_response_new = self.client.post("/oauth2/access?grant_type=password&[email protected]&password=SWr5q3ghhhSd", headers=headers,name = "Create a new token")
print("Launch - Response body: {}".format(launch_response_new.text))
@task
def generate_old_token(self):
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
launch_response_old = self.client.post("/oauth/access?grant_type=password&[email protected]&password=SWr5q3ghhhSd", headers=headers,name = "Create a new token- old")
print("Launch - Response body old: {}".format(launch_response_old.text))
class Login(HttpUser):
tasks = [LoginTaskSet]
wait_time = between(1, 2)
How to send host value's as part of each request ? How to run the locust without passing host value?
Upvotes: 0
Views: 1976
Reputation: 2856
You can give it the full URL in your client calls. It should only use the host
you give it when your endpoints start with /
. So instead of just "/oauth2/…"
you’d do "http://xyz.abc.new/oauth2/..."
.
Upvotes: 1