I want my locust program to run a set of tasks every 10th time. I.e in the below code, out of 10 task instances I want task1 to run in all and task2, task3 to run only once. How to do that?
class WebsiteUser(HttpUser):
host = "http://localhost:8085/api/"
wait_time = constant(1)
@task
class SequenceOfTasks(SequentialTaskSet):
id = None
application_json = 'application/json'
@task(10)
def task1(self):
request = read_json('order.json')
self.id = str(uuid.uuid4())
request['id'] = self.id
response = self.client.post('createRequest', json.dumps(request),
headers={'Content-Type': self.application_json})
assert response.status_code == 200
@task(1)
def task2(self):
request={self.id}
response = self.client.post('cancelRequest', json.dumps(request),
headers={'Content-Type': self.application_json})
assert response.status_code == 200
@task(1)
def task3(self):
request = read_json('updateRequest.json')
request['id'] = self.id
response = self.client.post('updaterequest', json.dumps(request),
headers={'Content-Type': self.application_json})
assert response.status_code == 200