/** * 健康檢查冒煙測試 * * 此測試用於 Dev/QA 環境,快速驗證系統健康狀態。 * 測試重點:系統可用性,響應時間。 */ import { healthCheck } from '../../scenarios/apis/health.js'; export const options = { scenarios: { smoke_health: { executor: 'shared-iterations', vus: 1, iterations: 5, // 執行 5 次健康檢查 maxDuration: '10s', tags: { test_type: 'smoke', api: 'health' }, }, }, thresholds: { checks: ['rate==1.0'], // 所有檢查必須通過 http_req_duration: ['p(95)<500'], // 95% 的請求應在 500ms 內完成 health_check_success: ['rate==1.0'], // 健康檢查成功率應為 100% }, }; export default function () { const baseUrl = __ENV.BASE_URL || 'http://localhost:8888'; const result = healthCheck({ baseUrl }); if (!result.success) { console.error('Smoke test failed: Health check failed'); return; } console.log(`Health check passed: Status ${result.status}, Response time ${result.responseTime}ms`); }