test: add comprehensive tests for CircuitBreaker service #1

Open
Charon wants to merge 1 commit from feat/test-circuit-breaker into dev
Owner

Fixes core/php-mcp#6

Summary

  • Add CircuitBreakerTest with 35 tests covering all circuit breaker states and transitions
  • Closed state: pass-through execution, exception propagation, fallback on recoverable errors
  • Open state: fast-fail with CircuitOpenException, fallback invocation, operation not executed
  • Half-open state: probe request allowed, circuit closes on success, re-trips on failure, trial lock contention handling
  • Failure threshold: trips after N failures (default 5), respects per-service config overrides
  • Reset timing: transitions to half-open after timeout, custom timeout support
  • Manual reset: clears state and counters, re-enables operations
  • Service isolation: independent circuits per service name
  • Success decay: successful calls decrement failure counter
  • Recoverable errors: SQLSTATE, connection refused/timed out, too many connections, table not found
  • Statistics: tracks failures, successes, threshold, and timeout values

Note: Upstream core/php-mcp is currently archived. This PR targets the fork's dev branch; merge upstream once unarchived.

Fixes core/php-mcp#6 ## Summary - Add `CircuitBreakerTest` with 35 tests covering all circuit breaker states and transitions - **Closed state:** pass-through execution, exception propagation, fallback on recoverable errors - **Open state:** fast-fail with `CircuitOpenException`, fallback invocation, operation not executed - **Half-open state:** probe request allowed, circuit closes on success, re-trips on failure, trial lock contention handling - **Failure threshold:** trips after N failures (default 5), respects per-service config overrides - **Reset timing:** transitions to half-open after timeout, custom timeout support - **Manual reset:** clears state and counters, re-enables operations - **Service isolation:** independent circuits per service name - **Success decay:** successful calls decrement failure counter - **Recoverable errors:** SQLSTATE, connection refused/timed out, too many connections, table not found - **Statistics:** tracks failures, successes, threshold, and timeout values > Note: Upstream `core/php-mcp` is currently archived. This PR targets the fork's dev branch; merge upstream once unarchived.
Charon added 1 commit 2026-03-24 14:03:45 +00:00
Cover all three circuit states (closed, open, half-open), failure
threshold logic, reset timing, manual reset, success tracking,
recoverable error detection, and per-service isolation.

Fixes #6

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Charon force-pushed feat/test-circuit-breaker from 30fb229ba4 to 3e14b367c3 2026-03-24 16:11:44 +00:00 Compare
Charon changed title from test: add tests for CircuitBreaker service to test: add comprehensive tests for CircuitBreaker service 2026-03-24 16:13:15 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/test-circuit-breaker:feat/test-circuit-breaker
git checkout feat/test-circuit-breaker

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout dev
git merge --no-ff feat/test-circuit-breaker
git checkout feat/test-circuit-breaker
git rebase dev
git checkout dev
git merge --ff-only feat/test-circuit-breaker
git checkout feat/test-circuit-breaker
git rebase dev
git checkout dev
git merge --no-ff feat/test-circuit-breaker
git checkout dev
git merge --squash feat/test-circuit-breaker
git checkout dev
git merge --ff-only feat/test-circuit-breaker
git checkout dev
git merge feat/test-circuit-breaker
git push origin dev
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Charon/php-mcp#1
No description provided.