Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Test Smarter, Not Harder: Achieving Confidence ...

Test Smarter, Not Harder: Achieving Confidence in Complex Distributed Systems

Testing distributed systems is hard, but it doesn't have to be fragile. In this session, we explore how to test services that depend on multiple databases, external providers, and asynchronous events.

Avatar for Elias Nogueira

Elias Nogueira

June 10, 2025
Tweet

More Decks by Elias Nogueira

Other Decks in Technology

Transcript

  1. Architecture – Business View Digital Onboarding Digital Lending Digital Banking

    Digital Assist Digital Engage Core Systems Common Services | Enterprise Integrations | Unified Security Fintech Partners Open Banking API API API Web and Mobile Apps
  2. Architecture – System View Payments API Digital Banking Baches Limits

    Contacts Audit Accounts Approvals Trading Transactions Access Control Forex Loan Cash Flow Cards Dashboard
  3. Architecture – Detailed API View Payment Options Payment Order Limits

    Batches Payment Integration Audit Approvals Core Bank System Payments event-listener Bank Calendar Bank Calendar Integration Batches Integration Anti-fraud 3rd party
  4. 1️⃣ Test with real dependencies 2️⃣ Support multiple databases 3️⃣

    Mock dependencies 4️⃣ Test asynchronous requests 5️⃣ API governance across multiple teams Testing challenges on this architecture
  5. 1️⃣ Test with real dependencies 2️⃣ Support multiple databases 3️⃣

    Mock dependencies 4️⃣ Test asynchronous requests 5️⃣ API governance across multiple teams Testing challenges on this architecture
  6. Coding example All examples are simple and focus on solving

    the problem rather than create a perfect example Payment Audit event-listener Anti-fraud 3rd party
  7. Modern systems often support multiple database engines ❌ Integration tests

    usually runs on in-memory databases, missing database-specific issues ❌ Testing sequentially slows feedback cycles and CI pipelines One Application Multiple Databases
  8. Common problems Don’t show the real problems. Usage of In-Memory

    Databases Manual steps might be required. High-effort for real databases
  9. Multi-database support Payment Run it sequentially is a bad idea!

    MySQL MSSQL Oracle Integration tests: 3min Integration tests: 3min Integration tests: 3 min ~ 9 min
  10. Multi-database support Payment Run it in parallel MySQL MSSQL Oracle

    Integration tests: 3min Integration tests: 3min Integration tests: 3 min ~ 3 min
  11. Takeaways Integration tests must validate behaviour across all target databases

    Containerization brings production-like test fidelity and consistency Parallel execution speeds up feedback and reduces CI bottleneck
  12. Third-Party Systems In-code mocks can solve a problem in one

    team (only) Using sandbox/QA environments from the vendor might be flaky Payment Anti-fraud 3rd party
  13. Can we trust third-party systems in our tests? ❌ Tests

    that rely on them are flaky and slow ❌ Local mocks are often inconsistent or limited to a single team Third-Party Systems
  14. Service Virtualization Service virtualization is a technique used in software

    testing and development to simulate the behaviour of external systems or services that your application depends on — such as third-party APIs, databases, or legacy systems — without requiring the actual systems to be available. Instead of relying on the real services (which might be unavailable, expensive, or unstable), teams use lightweight stand-ins (or virtual services) that mimic the real ones' behaviour. These virtual services respond with realistic data and behaviours, allowing tests and development to continue independently of external constraints.
  15. Replace real external calls with Wiremock hosted in a container

    Share mock setups across teams for collaboration and consistency Enables reliable, repeatable integration testing without hitting sandbox third-party systems Service Virtualization Payment Fraud Check 3rd party
  16. Predictable mocks enable reliable, isolated testing Release processes can move

    independently of third-party stability Dockerized mocks allow reuse across teams without manual setup Takeaways
  17. Testing Asynchronous Events test will fail to check or consume

    the event as it’s async Payment Audit event-listener emit an async event consume an async event 2 seconds
  18. ❌ Systems based on event queues introduce timing uncertainty ❌

    Integration tests fail due to delays in message consumption ❌ Developers are tempted to add sleep or polling hacks Testing Asynchronous Events
  19. ✅ Use Awaitility to wait for expected conditions dynamically ✅

    Avoid fixed timeouts and make tests more resilient ✅ Model realistic event-based behaviour in integration tests Synchronize Tests with Reality
  20. Synchronize Tests with Reality test will wait until the event

    is available Payment Audit event-listener emit an async event consume an async event 2 seconds
  21. Async flows require resilient test assertions Maintain realistic tests while

    ensuring correctness in event processing Awaitility helps you wait just enough, not too long Takeaways