Reputation: 1
stages = [
{
"name": "BigOrderUser Test",
"duration": 400, # 10 minutes
"users": 1,
"spawn_rate": 1,
"user_classes": [BigOrderUser]
},
{
"name": "ShopUser Test",
"duration": 300, # 10 minutes
"users": 1,
"spawn_rate": 1,
"user_classes": [ShopUser]
},
these are my stages
from locustfiles.orders import BigOrderUser
def tick(self):
"""Tick function to manage the transition of stages."""
# Get the current stage details
stage = self.stages[self.current_stage]
current_time = time.time()
elapsed_time = current_time - self.stage_start_time
print("######################### elapsed_time", elapsed_time, self.current_stage)
# Check if we have completed the current stage's duration
if elapsed_time >= stage["duration"]:
# Move to the next stage
self.current_stage += 1
# All stages completed, end the test
if self.current_stage >= len(self.stages):
return None
stage = self.stages[self.current_stage]
# Reset the start time for the new stage
self.stage_start_time = current_time
# Output the transition information
print(f"Transitioning to stage {self.current_stage + 1}: {stage['users']} users for {stage['duration']} seconds")
print("now stage: ", (stage["users"], stage["duration"], stage["user_classes"]))
# Return the number of users for the current stage
return (stage["users"], stage["duration"], stage["user_classes"])
but the first stage keep looping again and again here and not able to transist to next stages.
i want my stages to execute and change the user classes to run the locust script
Upvotes: 0
Views: 25