| 123456789101112131415161718192021222324252627282930 |
- from locust import HttpUser, between, task
- class ServicePilotBackendUser(HttpUser):
- wait_time = between(1, 3)
- @task(5)
- def health_check(self):
- with self.client.get("/api/health", name="API-健康检查", catch_response=True) as response:
- if response.status_code == 200 and response.json().get("status") == "ok":
- response.success()
- else:
- response.failure(f"unexpected health response: {response.status_code}")
- @task(3)
- def parse_config(self):
- with self.client.get("/api/config/parse", name="API-Parse配置", catch_response=True) as response:
- if response.status_code == 200 and "serverUrl" in response.text:
- response.success()
- else:
- response.failure(f"unexpected config response: {response.status_code}")
- @task(1)
- def not_found_contract(self):
- with self.client.get("/api/unknown-resource", name="API-404契约", catch_response=True) as response:
- if response.status_code == 404:
- response.success()
- else:
- response.failure(f"expected 404, got {response.status_code}")
|