flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[DevOps] Automated Chaos Engineering & Network Latency Fault-Injection Suite

Open blurbeast opened this issue 2 months ago • 8 comments

Overview & Background

In production, distributed blockchain indexers and real-time streaming backends face unpredictable adverse network conditions: Soroban RPC nodes returning HTTP 429 (rate limited) or 504 (gateway timeouts), Redis cluster master failovers, sudden PostgreSQL connection spikes, and WebSocket client drops. Without automated chaos testing, regressions under failure modes remain undiscovered until real money is impacted in production.


Detailed Problem Statement

  1. Unverified Circuit-Breaker Resilience:
    • Although multi-RPC failover and circuit breaker logic have been authored, there is no automated automated test harness that intentionally injects RPC network partitions or latency spikes to prove seamless failover.
  2. Database Deadlock Under Load:
    • Concurrent indexer write operations and high-volume REST traffic risk deadlocks under pool exhaustion.
  3. No CI Chaos Verification:
    • CI currently runs isolated unit tests with mocked or happy-path services, leaving catastrophic degradation modes untested.

Technical Specification & Architecture

1. Fault-Injection Infrastructure (Toxiproxy)

Implement a Dockerized Toxiproxy testing environment in backend/tests/chaos/:

  • Toxic Scenarios:
    • soroban_rpc_latency: Adds 2,000ms latency to Soroban RPC calls with 10% packet jitter.
    • soroban_rpc_timeout: Drops TCP connections after 100 bytes transmitted.
    • soroban_rpc_rate_limit: Returns synthetic HTTP 429 responses under burst traffic.
    • redis_kill_reconnect: Terminates Redis connection midway during SSE pub/sub fanout.
    • postgres_max_connections: Exhausts PostgreSQL connection pool to trigger backpressure.

2. Automated Chaos Test Suite (backend/tests/chaos/resilience.chaos.test.ts)

  • Assertion 1 (RPC Failover):
    • Inject failure on primary RPC node. Verify indexer detects error, trips circuit breaker, and routes requests to secondary RPC node within < 500ms without dropping events.
  • Assertion 2 (Dead-Letter Catch):
    • Inject malformed RPC responses. Verify failed events are safely routed to Dead Letter Queue without crashing worker process.
  • Assertion 3 (Redis Recovery):
    • Sever Redis connection. Verify SSE clients receive automated reconnection notices and reconnect seamlessly once Redis restarts.

3. CI Workflow Integration (.github/workflows/chaos-testing.yml)

  • Run nightly and on release candidates using ephemeral Docker Compose stack.

Target Files

  • backend/tests/chaos/docker-compose.chaos.yml
  • backend/tests/chaos/resilience.chaos.test.ts
  • backend/tests/chaos/helpers/toxiproxy.ts
  • .github/workflows/chaos-testing.yml

Acceptance Criteria

  • [ ] Toxiproxy harness programmatically injects latency, packet loss, and connection resets into CI test runs.
  • [ ] Multi-RPC service automatically fails over to backup RPC endpoint upon injected latency/error.
  • [ ] Indexer survives temporary database drops and resumes event ingestion without duplicating rows.
  • [ ] Chaos test workflow runs reliably in GitHub Actions without flaky test failures.
  • [ ] Documentation explains how developers can run chaos scenarios locally.

blurbeast avatar Sep 27 '26 05:09 blurbeast

@code-ony has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

I would love to work on this issue, please assign it to me

ℹ️ Repo Maintainers: To accept this application, review their application or assign @code-ony to this issue.

code-ony avatar Sep 27 '26 15:09 code-ony

@ghostredeem has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

Hello Maintainer, I've gone through the requirement and i believe I can offer proper solution in line with the criteria. Kindly assign it to me. Thank you

ℹ️ Repo Maintainers: To accept this application, review their application or assign @ghostredeem to this issue.

ghostredeem avatar Sep 28 '26 06:09 ghostredeem

Congratulations, @code-ony! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.

🧑‍💻 @code-ony: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

🌊 Happy Wave 🌊

drips-wave[bot] avatar Sep 29 '26 17:09 drips-wave[bot]

@juliet-unoyiza has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

I've reviewed the issue thoroughly and can start working on it right away. Looking forward to contributing

ℹ️ Repo Maintainers: To accept this application, review their application or assign @juliet-unoyiza to this issue.

juliet-unoyiza avatar Oct 15 '26 15:10 juliet-unoyiza

@Max347bot has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Hello maintainer please I will like to work on this issue

ℹ️ Repo Maintainers: To accept this application, review their application or assign @Max347bot to this issue.

Max347bot avatar Oct 15 '26 23:10 Max347bot

@Hotmopo has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Hello maintainer, i would like to work on this issue

ℹ️ Repo Maintainers: To accept this application, review their application or assign @Hotmopo to this issue.

Hotmopo avatar Oct 16 '26 22:10 Hotmopo

Congratulations, @Hotmopo! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

🧑‍💻 @Hotmopo: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

🌊 Happy Wave 🌊

drips-wave[bot] avatar Oct 16 '26 22:10 drips-wave[bot]

This issue has been completed by @Hotmopo as part of the Stellar Wave Program's 10th Wave 🥳

😎 @Hotmopo: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

drips-wave[bot] avatar Oct 18 '26 12:10 drips-wave[bot]