true // 를 두고 임계 초과를 유발한 뒤, 대시보드의 '경보 SMS 발송 실패' 배너와 오프라인 재시도 // 예약(error_log)을 확인하고, 끝나면 반드시 다시 false 로 되돌린다. // // 주의: config.local.php 가 SMS_FORCE_FAIL 을 명시 설정하면 아래 env 주입은 무시된다. // ============================================================================= declare(strict_types=1); if (php_sapi_name() !== 'cli') { http_response_code(403); header('Content-Type: text/plain; charset=utf-8'); exit("CLI only\n"); } putenv('SMS_FORCE_FAIL=1'); // config 로드 전에 주입(cfg 가 getenv 로 읽음) $root = dirname(__DIR__); require_once $root . '/php/sms_send.php'; // config.php 포함 $failures = []; function chk(bool $cond, string $msg): void { global $failures; if (!$cond) { $failures[] = $msg; } } chk(SMS_FORCE_FAIL === true, 'SMS_FORCE_FAIL should be forced ON for the drill (env override). config.local.php 가 명시 설정하면 무시될 수 있음.'); $r = send_sms_cafe24('01000000000', '드릴 메시지'); chk(($r['success'] ?? null) === false, 'forced send must report failure (success=false).'); chk(($r['result_code'] ?? '') === 'FORCED_FAIL', 'forced send must use FORCED_FAIL result code.'); chk(array_key_exists('remaining', $r), 'result must include the remaining key.'); if ($failures) { fwrite(STDERR, "Chaos drill FAILURES:\n"); foreach ($failures as $f) { fwrite(STDERR, "- {$f}\n"); } exit(1); } echo "Chaos drill passed: SMS 실패 주입 경로 동작 확인.\n"; echo "라이브 드릴: config.local.php 에 'SMS_FORCE_FAIL'=>true 후 임계초과 유발 → 대시보드 실패 배너/오프라인 재시도 확인 → 반드시 false 로 복구.\n";