forked from retoor/devplacepy
fix: add port cleanup and server health checks to locust make targets and seed script
Add `fuser -k` to kill stale processes on the locust port before starting the uvicorn server, and improve the server readiness loop to detect startup failures early. In the locustfile seed function, cap user creation attempts at 25 and log a clear error if fewer than 5 seed users are created, preventing silent hangs or partial test data.
This commit is contained in:
+11
-1
@@ -72,7 +72,10 @@ def seed_data(environment, **kwargs):
|
||||
import http.cookiejar
|
||||
|
||||
created = 0
|
||||
while created < 5:
|
||||
attempts = 0
|
||||
max_attempts = 25
|
||||
while created < 5 and attempts < max_attempts:
|
||||
attempts += 1
|
||||
username = random_username()
|
||||
email = f"{username}@locust.devplace"
|
||||
body = urllib.parse.urlencode({
|
||||
@@ -88,6 +91,13 @@ def seed_data(environment, **kwargs):
|
||||
except Exception as e:
|
||||
logger.warning(f"Create seed user failed: {e}")
|
||||
|
||||
if created < 5:
|
||||
logger.error(
|
||||
f"Seeding aborted: only {created}/5 users created after "
|
||||
f"{attempts} attempts. Is the server healthy at {host}?"
|
||||
)
|
||||
return
|
||||
|
||||
logger.info(f"Created {len(SEED_USERS)} seed users")
|
||||
|
||||
def logged_in_opener(email):
|
||||
|
||||
Reference in New Issue
Block a user