Testing Guide
This document describes the current testing strategy for the project, with emphasis on the live-market processor path and the machinery around it.
For the top-level system map, see Architecture Overview.
For the runtime architecture that these tests exercise, see Live Market Pipeline And Processor Machinery.
Test Framework Conventions
- Test runner — backend modules (
backend-*) use JUnit 5 (@Test,@BeforeAll,@AfterAll,@TestInstance). Frontend/KMP modules (frontend-*,shared-*) use Kotest spec styles (StringSpec, etc.) to support KMP targets. - Assertions — all modules use Kotest assertions (
shouldBe,shouldBeInstanceOf,shouldContain, etc.) regardless of which runner is used. - Coroutines in JUnit tests — wrap suspend calls with
runTest { }. Use@TestInstance(Lifecycle.PER_CLASS)when the test class holds shared state (e.g. a Testcontainer) across all tests.
Shared JVM test fixtures
When a JVM test helper is needed by more than one module, keep it out of production code by placing it in the producing module's src/testFixtures/kotlin source set. The producer applies alias(libs.plugins.javaTestFixtures) and declares fixture-only dependencies with testFixturesImplementation(...); each consumer declares testImplementation(testFixtures(projects.<producer>)). Use this for reusable fakes and fixtures only; module-specific helpers stay in that module's src/test source set.
Test Suite Types
Common suite names in this repo:
test: unit tests, in-process integration tests, and manifest-fixture coveragedbIntegrationTest: database-backed integration tests; Docker is requiredk8sIntegrationTest: real-cluster startup and runtime tests via Testcontainers; Docker is required
Local container-backed suites under rootless Podman
On the current local rootless Podman setup, Testcontainers-backed suites need two explicit environment overrides before running Gradle:
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock
export TESTCONTAINERS_RYUK_DISABLED=true
These overrides are required for the current Podman machine setup because Ryuk otherwise fails during startup while trying to create the Podman socket mountpoint under /var/folders/.../podman-machine-default-api.sock.
Additionally, Podman's API proxy has a default idle connection timeout that can cause Testcontainers operations to fail with Docker API timeouts (see testcontainers-java#7310). To fix this, set service_timeout = 0 in the Podman VM's containers.conf:
[engine]
service_timeout = 0
On macOS, this file must be edited inside the Podman VM (not on the host). To access the VM:
podman machine ssh
# Then edit /etc/containers/containers.conf
sudo vi /etc/containers/containers.conf
# Add or set: service_timeout = 0 under [engine]
# Exit and restart the machine
exit
podman machine stop
podman machine start
Setting service_timeout = 0 disables the idle timeout entirely, which prevents the API proxy from closing connections that Testcontainers expects to remain open.
This applies to local container-backed suites such as dbIntegrationTest, k8sIntegrationTest, and Gel-backed storage regressions that start containers through Testcontainers.
Testing Philosophy
The project uses layered verification rather than one giant end-to-end suite for every change.
The important split is:
- pure strategy semantics live in
backend-strategy - executor/backfill/channel-management behavior lives in
backend-processor - processor-path timing, ordering, lifecycle, and resilience behavior lives in
backend-app - persistence, bridge, and Kubernetes bootstrap behavior are tested in their own modules
That keeps failures localized while still preserving real-path coverage where timing and lifecycle matter.
Coverage Matrix
| Layer | Main suites | What it proves | Main seam |
|---|---|---|---|
| Pure strategy semantics | backend-strategy:test |
strategy math, warm-up, output metadata, entries, exits, reversals | no processor or transport |
| Executor boundary | backend-processor:test |
backfill handoff, live handoff, dynamic per-instrument execution management | real Strategy.execution(...), custom historical provider |
| Generic processor contract | backend-app:test unit tests |
routing, flattening, fan-out, lifecycle wiring, readiness, failure handling | mocked Strategy.executor(...) |
| Real processor path | backend-app:test processor integration tests |
Processor -> StrategyExecutor -> StrategyExecution -> TradeExecutor behavior families |
real processor machinery |
| Recorder persistence | backend-recorder:test and dbIntegrationTest |
QuestDB schema, retrieval, frame-selection audit writes (immediate flush), deduplication | real QuestDB or JKube fixtures |
| Raw-vs-QuestDB reconciliation | backend-reconciliation:test |
shared-policy replay (frame mapper + TickNormalizer), session-anchored raw read, union dedupe, same-key ltp conflicts, all diff kinds incl. INDETERMINATE_CONFLICT, completeness states, unsubscribed-skip, broker filter, diff stream |
faked RawDataRetriever + HistoricalDataProvider |
| Normalizer policy | backend-normalizer:test |
the full behavior table: session-first seeding, baseline/delta/duration evolution, vtt regression, duplicate/late variants, out-of-session recording, hydration (both restart scenarios) | pure JVM, no I/O |
| Broker frame mapping | backend-broker:test |
Upstox envelope validation (missing ltpc, non-finite ltp, non-positive ltt), vtt → seq/volumeFact conversion, null-vtt parity |
pure JVM, no I/O |
| Decimal conformance | shared-decimal tests on JVM + JS |
arithmetic, half-up division boundaries, parse round-trip, malformed rejection, cross-scale equality, serializer, Double canonicalization round-trip incl. exponent thresholds, JVM BigDecimal oracle, JS-format exponent rewrite |
pure multiplatform |
| Bridge and startup | backend-app:test, backend-server:test, k8sIntegrationTest |
kRPC wiring, reconnect behavior, rendered manifests, cluster boot | in-process Ktor or K3s |
Processor-Focused Test Layout
backend-strategy:test
This is the source of truth for pure strategy behavior.
Current key suites:
StrategyExecutionTestEmaStrategyExecutionTestVolumeBreakoutStrategyExecutionTestVolumeBarFoldTest
What belongs here:
- strategy-state transitions
- bucket/volume-bar timing semantics
- output metadata
- entry, exit, and reversal ordering
If a behavior can be proven without Processor, this is the preferred layer.
backend-processor:test
Current key suites:
StrategyExecutorTest-RouteLifecycleModelInterleavingTest-RouteCoordinatorProtocolTest
What they cover:
- historical backfill handoff
- live handoff after backfill
- dynamic instrument add/remove behavior
- per-instrument channel management
- preservation of strategy timing contracts through the executor boundary
- model-based interleaving: a reference transition model of the executor's route
lifecycle (the sweep-mutex queue, StateFlow slot/conflation semantics, gated
initialization outcomes, fatal and stale-fatal callback fires, position flips,
awaiting-history retry deadlines) is checked against the real executor after
every seeded op — per-instrument failure-fact order: the failure fact is
the sole boundary event, so the recorded
executionFailednotifications are compared exactly while route addition/removal correctness is carried by the record/routed/delivery surfaces), tick FIFO across route generations, no live route without a consumer, token coherence, and fixed oracle scripts for the executor-side aspects of the historical race family (init/handoff buffering, the failure fact against teardown, stale fatal callbacks, duplicate fatal no-ops, the open-position drain and heal). The suite owns one executor and mocksStrategyExecution, so it cannot pin the cross-executor route-instance gate, the realStrategyExecution.startsubscriber ordering, or the processor snapshot-before-start ordering — subscriber ordering is permanently beyond a mocked-execution suite and keeps its targeted regression, the publish-before-start ordering proof stays with its gated targeted regression inbackend-app(every model op fully settles, and the fix's guarantee is precisely that no suspension point exists between publication and start, so no settle-separated op can distinguish the orderings), and only the cross-executor gate is model-checked by the processor-level suite (ProcessorRouteModelInterleavingTest,backend-app). All identities derive from the seed, so a reported seed is a complete reproduction. Cross-instrument event order within a single sweep is deliberately not asserted (aConcurrentHashMaphash-order artifact, not a contract). - handshake protocol oracles (
RouteCoordinatorProtocolTest): the protocol mechanics that settle-separated model ops cannot discriminate, pinned between the real worker and itsRouteCoordinator— the acknowledgedInitStartedhandshake (the buffering ingress published and the record flipped to Initializing BEFORE the backfill begins, reproducer-proofed: skipping the ack fails the oracle at exactly the record-phase assertion — the reopened window), stale-ack cancellation (supersession fails the worker fast instead of hanging it), theInitReadyflip barrier (the router redirects to the active ingress atomically; stale flips are cancelled),PositionFlatlevel-set idempotency (the open-position drain/heal/remove decision), the single-writer execution view, and the awaiting-history defer's live-tick drop with deadline retry. The oracles extend to the parked ack: theInitStartedack is PARKED (asserted NOT completed until the publication callback —onTargetsPublished— runs; this harness has no processor loop, so the helpers publish the route's targets themselves), and the executor-level model suite (RouteLifecycleModelInterleavingTest) encodes the parked-ack abort — a dispatched addition not in the live view (desired ∪ routable) at ack time never reaches its gate: the record reverts to Buffering (pending ticks return FIFO) and the sweep continues. - the key gated-publication regression (
ProcessorRouteLifecycleTest): adding an instrument to a LIVE strategy parks its initialization until the processor has published it in the routing snapshot — a REAL executor (constructed through the reflection seam with a test-scheduler-driven scope) behind a second strategy's gated builder (the gated seam): the parked ack holds the backfill (nostrategy.executionentry — where the high-water read happens), a real tick injected while held is dropped before the strategy mailbox and is provably backfill-recoverable, and only the release + centralized publication + route-qualified callback completes the ack (reproducer-proof: with the park disabled, the instrument is Active while the loop is still held). -
phase/resource handoff oracles (
RouteCoordinatorProtocolTest): The sealed state adds handoff oracles for a route that starts draining before InitReady and heals either before or after the flip (same execution/token, preserved delivery stage), registration overflow that retains its ingress while releasing local-buffer quota, and park-time rollback that returns the buffered prefix FIFO before ack cancellation and preserves the record/token on a subsequent attempt. -
the absent-target oracles (
RouteCoordinatorProtocolTest): an absent-instrument publication leaves the ack parked (a GENERIC PROTOCOL INVARIANT — a publication's content can predate the park: a topology reconciliation may suspend on an executor build while membership advances, and its snapshot-exact targets are never re-pulled; absence is not supersession, only the explicit membership-invalid sites cancel), a membership wake dropping the parked instrument cancels it and reverts the record under the lock (purging it in the same wake's sweep, buffering post-cancel ticks as a fresh stray, re-dispatching on re-add), and a park-time-invalid InitStarted aborts with the reverted record owning every subsequent delivery. The processor-level stale-Reconcile regression is RETIRED: the payload-carrying Reconcile it injected no longer exists (the wake is payload-free), so the stale-publication producer is gone; the surviving fresh-but-absent hazard stays pinned by these oracles, with the end-to-end guarantee held by the ordering coverage and the recovery test. - the dynamic-add recovery test (
ProcessorInitializationTickRoutingIntegrationTest): a real volume-breakout execution recovers a pre-publication-dropped tick from the recorded history exactly once. The held tick is appended to the recorded history at live-emission time (modeling the recorder, which records pre-routing) with a deliberately non-aligned delta (14 units against the frame length of 10), leaving the fold's phase at 4 after the backfill; the probe ticks' per-tick outputs then carry the running bar's OHLC — recovered opens the bar at the held tick's price, lost opens it at the probe's own price, and a hypothetical live-and-backfill duplicate would close a new bar on the second probe. Mutation-proof: with the park disabled the initialization runs pre-publication and both feed variants fail at the parked assertion.
Use this layer when the question is about executor behavior rather than app wiring.
backend-app:test: Generic Processor Contract
These tests keep Strategy.executor(...) mocked and verify the processor as infrastructure.
Current suites:
ProcessorTestProcessorReadinessTestProcessorSignalWiringTestProcessorFlatMapInstrumentUpdatesTestProcessorSingleStrategyRoutingTestProcessorMultiStrategyRoutingTestProcessorMultiFeedRoutingTestProcessorOverlappingInstrumentRoutingTest-ProcessorRouteModelInterleavingTest(processor level)
What belongs here:
- feed flattening
- multi-feed routing
- multi-strategy routing
- signal/output fan-out
- readiness and lifecycle wiring
- failure handling that does not depend on concrete strategy timing
- processor-level model-based interleaving (
ProcessorRouteModelInterleavingTest): a reference model of the CURRENT wiring rules — the processor's payload-freeTopologyDirtywake: the repository's current.valueread once at consumption — a delayed wake and a fresh one are indistinguishable, the convergence form) alongside the coordinators' sole per-strategy wake-only membership consumption (the raw repository.valueread at wake consumption), the instrument index derived from the routes' delivery-target views, route-instance gating at the command boundary, and the derived-health projection — is checked against the real command loop driving a generational executor mock after every seeded op (50 seeds × 100 ops over 2 strategies × 2 instruments): health/readiness (the frozen semantics), generation liveness, and per-instrument tick FIFO across route generations. escalation paths (current and stale); the publish-before-start ordering appears as a post-settle routing check only — its proof stays with the gated targeted regression inProcessorRouteLifecycleTest(a settle-separated op cannot distinguish the orderings). The suite is the RouteCoordinator move's frozen-behavior contract, built before any ownership migrates so each green stage retargets it as its acceptance harness. the mid-read projection race keeps its gated targeted test (ProcessorRouteLifecycleTest), and the realStrategyExecution.startsubscriber ordering stays permanently with its targeted regression — a mocked-execution suite cannot see it. All identities derive from the seed, so a reported seed is a complete reproduction.
backend-app:test: Real Processor Path Integration
These tests run the real processor machinery end-to-end in process:
Processor -> StrategyExecutor -> StrategyExecution -> TradeExecutor
Current suites:
ProcessorStrategyEmaSignalIntegrationTestProcessorStrategyEmaTimingIntegrationTestProcessorStrategyVolumeBreakoutEntryIntegrationTestProcessorStrategyVolumeBreakoutExitIntegrationTestProcessorPipelineEmaTimingIntegrationTestProcessorPipelineEmaTradeExecutionIntegrationTestProcessorPipelineVolumeBreakoutEntryIntegrationTestProcessorPipelineVolumeBreakoutExitIntegrationTestProcessorPipelineEventContractIntegrationTestProcessorPipelineResilienceIntegrationTestProcessorPipelineRuntimeLifecycleIntegrationTest
What these suites collectively cover:
- EMA intra-bucket behavior through the full processor path
volume_breakoutclose-gated entries and exits through the full processor path- signal-to-trade execution behavior
- event ordering and linkage contracts
- dynamic add/remove/re-add lifecycle behavior
- retained execution behavior for open positions
- resilience when broker calls fail or trade settings disappear
Current Helper Layout In backend-app
The processor integration helpers were intentionally split by concern. Do not recreate omnibus helper files.
Shared support
ProcessorPipelineIntegrationTestSupport.ktProcessorPipelineEventContractIntegrationHelpers.kt
EMA helper families
ProcessorPipelineEmaTimingIntegrationHelpers.ktProcessorPipelineEmaTradeExecutionIntegrationHelpers.ktProcessorPipelineEmaResilienceIntegrationHelpers.ktProcessorPipelineEmaRuntimeIntegrationHelpers.ktProcessorPipelineEmaRemovedInstrumentIntegrationHelpers.ktProcessorPipelineEmaIntegrationFixtures.kt
Volume breakout helper families
ProcessorPipelineVolumeBreakoutEntryIntegrationHelpers.ktProcessorPipelineVolumeBreakoutExitIntegrationHelpers.ktProcessorPipelineVolumeBreakoutResilienceIntegrationHelpers.ktProcessorPipelineVolumeBreakoutRuntimeIntegrationHelpers.ktProcessorPipelineVolumeBreakoutRemovedInstrumentIntegrationHelpers.ktProcessorPipelineVolumeBreakoutIntegrationFixtures.kt
Mixed-strategy helper families
ProcessorPipelineMixedStrategySharedIntegrationHelpers.ktProcessorPipelineMixedStrategyBrokerFailureIntegrationHelpers.ktProcessorPipelineMixedStrategyTradeSettingResilienceIntegrationHelpers.ktProcessorPipelineMixedStrategyEventContractIntegrationHelpers.ktProcessorPipelineMixedStrategyRuntimeRegressionIntegrationHelpers.ktProcessorPipelineMixedStrategyLifecycleIntegrationHelpers.ktProcessorPipelineMixedStrategyVolumeRetentionIntegrationHelpers.ktProcessorPipelineMixedStrategyEmaRetentionIntegrationHelpers.ktProcessorPipelineMixedStrategyReadditionIntegrationHelpers.kt
Rule of thumb:
- extend the nearest existing helper family
- create a new helper file only when the behavior family is genuinely new
- keep test helpers named by behavior, not by strategy count or ad hoc scenario names
Choosing The Right Layer For A New Test
Use backend-strategy when:
- the change is pure strategy semantics
- the question is about outputs, signals, or reversal ordering without processor concerns
Use backend-processor when:
- the change is about
StrategyExecutor - the question is about backfill/live handoff or per-instrument execution lifecycle
Use backend-app processor unit tests when:
- the change is about generic processor routing or readiness
- the concrete strategy behavior is irrelevant
Use backend-app real-path processor integration when:
- timing semantics matter at the processor boundary
- batching, fan-out, signal ordering, or lifecycle retention matter
- you need to prove behavior through
TradeExecutor
Do not add a processor-path integration test for every new strategy by default.
Add one only when the strategy introduces a new processor-visible family such as:
- a new timing model
- a different backfill model
- a new signal-ordering contract
- a new lifecycle or retention contract
The existing real-path strategy families are intentionally represented by EMA and volume_breakout.
Event-Time Assertions
The processor-path tests use two different time assertions on purpose:
StrategyOutput.occurrenceTimeshould match the live tick that caused the outputStrategySignalEvent.timeshould fall inside the local emission window, because signals currently use emission time rather than tick time
If you need source tick context for a signal, use:
signal.strategyOutputId- the linked
StrategyOutput.occurrenceTime
Running The Useful Verification Sets
For processor-path timing or lifecycle changes, the useful default command is:
./gradlew :backend-strategy:test :backend-processor:test :backend-app:test
For focused processor-path verification inside backend-app:
./gradlew :backend-app:test \
--tests "com.timemanx.quant.server.app.processor.ProcessorPipelineEventContractIntegrationTest" \
--tests "com.timemanx.quant.server.app.processor.ProcessorPipelineResilienceIntegrationTest" \
--tests "com.timemanx.quant.server.app.processor.ProcessorPipelineRuntimeLifecycleIntegrationTest"
For full backend-app verification, keep in mind that backend-app:test also includes:
DataBridgeLauncherin-process kRPC coverage- startup unit tests for concurrent DI and fail-fast behavior
Database and cluster suites:
dbIntegrationTestrequires Dockerk8sIntegrationTestrequires Docker and is intentionally slower and more operational
Other Important Project Test Areas
backend-app:test
Beyond processor tests, this module also contains:
- seam-free
DataBridgeLaunchertests usingtestApplication { externalServices { ... } } - startup tests for concurrent Ktor module initialization and failure propagation
AuthStateCoordinatorTest— verifies recovery publication, obsolete-prompt cleanup, datasource resume onValidtransition, idempotent start, multi-broker support, anddistinctUntilChangedfilteringResilientTokenBrokerServiceTest— verifies single upstream subscription across multiple consumers (cold flow with subscription counter) and ZERODHA passthroughResilientProvisionedTokenBrokerServiceTest— verifies single upstream subscription across multiple consumers for provisioned-token handles and delegation ofinvalidateToken/reloadTokenOAuthTokenHealthReporterTest— verifies health status mapping for allOAuthTokenStatevariants, active/inactive broker partitioning, FAILED for non-recoverable failures, INACTIVE for no active brokersProvisionedTokenHealthReporterTest— verifies health status mapping forProvisionedTokenState(Valid→HEALTHY,Failed→DEGRADED)ResilientTokenStateFlowTest— verifies ArrowSchedule-based retry with backoff reset on successful emissionRequiredFeedReadinessReporterTest— verifies feed-health aggregation withHEALTHY/DEGRADED/BLOCKEDprecedenceApplicationReadinessTest— verifiesDEGRADEDreporters still yield 200 OK on/readiness
backend-server:test
This module contains the symmetric bridge-side tests for AppDataBridgeManager, plus startup tests for concurrent initialization and dependency failure handling.
FeedRouterTest covers full snapshots, delta status/headers and polymorphic record encoding, unchanged versions, and empty JSON arrays. A local Netty test pauses the outgoing Flow before its second record and verifies the client receives the first record before the producer resumes.
backend-token-broker:test
This module contains TokenManager and ProvisionedTokenManager tests covering:
TokenManager (OAuth):
- suspend factory initialization (DataStore load before instance is returned)
- concurrent
invalidate()/submitAuthCode()serialization underinitGuardmutex _activeSubmitCountatomic counter preventingExchangingstate wedge after joiner completionCancellationExceptionpropagation from exchange strategies without becomingOAuthTokenState.Failed- non-recoverable exchange failures (
NonRecoverableTokenException) resulting inOAuthTokenState.Failed - write-through persistence with
drop(1)skip for the init emission
ProvisionedTokenManager (provisioned tokens, runTest with virtual time):
- startup with missing/expired/unparseable/valid token files
invalidate()with unchanged vs changed filesreload()with valid vs missing files- poll-loop recovery after file update and poll-loop stops after success
- startup with missing/expired files starts poller and recovers after file update
- concurrent invalidations do not create duplicate polling jobs
- stale expiry timer does not override newer valid token (identity check)
- transient unreadable file followed by same bytes recovers via poller
backend-broker:test
This module contains HttpClientAuthInvalidationTest covering auth-invalidation paths in shared-httpclient's HttpClient:
- REST 4xx
TokenErrorclassification viaUpstoxErrorParsertriggersclearTokenCache()+onUnauthorized() - REST 401 fallback triggers both callbacks even without
TokenErrorclassification - REST 4xx non-token error does not trigger callbacks
onUnauthorizedfailure propagation (not swallowed byrunCatching)- WebSocket upgrade 401 fallback triggers both callbacks
- WebSocket upgrade 4xx
TokenErrorclassification triggers both callbacks - WebSocket 4xx non-token error does not trigger callbacks
- WebSocket
onUnauthorizedfailure propagation
These tests exercise the actual HttpClient.withConfig code path against a real Netty test server, verifying both REST (ClientRequestException) and WebSocket (WebSocketException) error branches.
backend-datasources:test
This module contains UpstoxDataSource tests covering:
- terminal token failure handling (
TokenUnavailableExceptionstops retry, records terminal failure) - structured health reporting (
DEGRADEDafter terminal failure,HEALTHYwhen stream is active,BLOCKEDwhen not running) resumeIfStopped()idempotency (no-op when stream already running or no subscribers)- new subscriber restarts upstream after terminal failure without
resumeIfStopped() - reports
HEALTHYafterresumeIfStopped()when upstream reconnects without emitting ticks (quiet market) - day-boundary detection via vtt-decrease and time-delta heuristics
- tick-to-MarketData conversion with per-tick volume delta computation
backend-readiness:test
This module contains DataSourceReadinessReporter tests covering:
HEALTHYcomponent health when datasource is healthyDEGRADEDcomponent health when datasource has a terminal failureBLOCKEDcomponent health when datasource is not ready
backend-recovery:test
This module contains RecoveryManager tests covering:
- logical recovery coalescing (same
recoveryUrlproduces one error) - targeted recovery (removes only the matching error)
clearLogicalRecovery()for obsolete promptsclearLogicalRecovery()resumes waiting collectors
backend-reconciliation:test
This module contains the unit tests for the raw-vs-QuestDB cross-check library (no Kubernetes manifest; pure JVM):
UpstoxFrameDecoderTest— protobuf decode across all feed variants (Market/Index/Ltpc/Greeks) and per-variantvttextraction (Index→0, Market null-vtt→0).ReconciliationServiceTest— all diff kinds (MISSING_IN_STORE,MISSING_IN_RAW,LTP_MISMATCH), emission-gate dedup of dropped ticks, day-boundary reset emitting again, unsubscribed-instrument skip, broker filtering, and thereconcileDiffsstream — using fakes forRawDataRetrieverandHistoricalDataProvider.
backend-recorder
Important coverage is split between:
- manifest assertions in
test - QuestDB-backed persistence assertions in
dbIntegrationTest - real-cluster bootstrap assertions in
k8sIntegrationTest
backend-sync
Important coverage is split between:
- application logic, failure-propagation, and manifest assertions in
test - Postgres-backed recorder assertions in
dbIntegrationTest - real-cluster bootstrap assertions in
k8sIntegrationTest
backend-storage
Important coverage is split between:
- unit and integration tests in
test - Gel-backed storage regression tests in
dbIntegrationTest - stress tests in
dbIntegrationTesttagged with@Tag("stress")
DataStoreImplTest is a Gel-backed integration suite:
- Starts a Gel 7.1 Testcontainer, bootstraps the schema, and runs all storage operations against a real database.
- Covers feeds, instruments, strategies, trade settings, orders, and positions with full round-trip assertions.
- Uses
DATA_RESET_QUERYto clear state between tests.
DataStoreStressTest is a Gel-backed stress suite:
- Uses a local
complete.jsonresource (~136k Upstox instruments) to exerciseaddInstrumentsat production scale. - Tagged with
@Tag("stress")for selective execution. - Uses
UpstoxInstrumentDeserializerfrombackend-brokerfor production-quality instrument parsing (same code path asUpstoxApiDecorator). - Tests: full sync timing, incremental sync with 10% churn, concurrent reads during writes, idempotent re-sync, and full read performance with data integrity spot-checks.
- Timing-sensitive tests use
@RepeatedTest(3)withmeasureTimedValuefor throughput calculation and regression guards. - Requires a running Docker daemon (Testcontainers).
Current Coverage Posture And Gaps
Strongly covered today:
- EMA timing families
volume_breakouttiming families- processor event-contract behavior
- processor runtime lifecycle behavior
- resilience to broker failures and missing trade settings
- recorder persistence against a real QuestDB instance
- bridge reconnect and Kubernetes startup paths
- terminal token failure handling and DEGRADED health reporting
- datasource and feed-level health aggregation (HEALTHY/DEGRADED/BLOCKED)
- RecoveryManager coalescing, targeted recovery, and obsolete-prompt cleanup
- REST and WebSocket auth-invalidation paths in
shared-httpclient(8 tests via Netty test server) TokenManagerconcurrentinvalidate()/submitAuthCode()serialization and suspend factoryProvisionedTokenManagermutex-owned state machine, polling recovery, concurrent invalidations, stale expiry timers, and transient I/O recovery (16 tests)ResilientTokenBrokerServiceandResilientProvisionedTokenBrokerServicesingle-subscription guarantee (cold-flow subscription counter)OAuthTokenHealthReporter(HEALTHY/DEGRADED/BLOCKED/FAILED with active/inactive broker partitioning) andProvisionedTokenHealthReporter(HEALTHY/DEGRADED) health status mapping- Arrow
Schedule-based retry with backoff reset for token-state stream resilience AuthStateCoordinatorrecovery publication, obsolete-prompt cleanup, and datasource resume
Current gaps or intentionally deferred areas:
backend-trade-executorcurrently has no module-local test suite undersrc/test; its behavior is mostly exercised throughbackend-appprocessor-path tests- there is no single in-process suite that runs
Processor -> TradeExecutor -> DataRecorder -> QuestDBas one cohesive test; processor-path behavior and recorder persistence are verified separately - bridge forwarding and recorder persistence are covered, but not as one monolithic full-stack test
backend-syncstill has no end-to-end broker-to-Gel instrument-sync regression that exercises a real datasource payload plus final Gel persistence assertionsbackend-syncstill has no dedicated test for the feed-bootstrap precondition it relies on, or for the current "log-and-skip malformed source row but still report success" behavior
Those are reasonable trade-offs today, but they are useful to keep in mind when adding new behavior.