We plan on doing load testing on a sequence of APIs using locust. So we have a set of APIs we would be calling sequentially on locust using SequentialTaskSet. By default it would run indefinitely if not stopped manually or I can set a timer in the command line to stop after a pre-defined interval. But what we plan to do is, we would be gradually increasing the number of concurrent users. Then we plan to call a separate API every 5 minutes or so which would give us memory consumed on the servers where our sequential APIs are hosted. If the value of memory consumed reaches a threshold, we want the locust script to stop automatically. I tried reading the documentation but couldn't find how we would go about doing this. Any tips?
Basic code we have so far:
import json
class UserBehavior(SequentialTaskSet):
@task
def api_call(self):
with self.client.get('/test_api') as response:
print(response)
class WebsiteUser(HttpUser):
tasks = [UserBehavior]
wait_time = between(2, 10)```