Skip to content

Centralize duplicated queue/test helpers (clearOutbox, flushSpans, eventually/expectEventually, meaningful) #488

Description

@sjvans

Several test helpers are copy-pasted across many test files. Centralize them into a shared test-utils module (e.g. test/bookshop/lib/queue-test-utils.js or test/_utils.js) and import from there.

Duplicated helpers (current spread)

  • eventually / expectEventually — the same force-flush-then-poll-assertion pattern under two names: eventually (span/tracing) in tracing-outboxed-batch, tracing-scheduled, tracing.test, tracing-messaging.js; expectEventually (metrics) in metrics-outbox, metrics-outbox-multitenant, metrics.test. Should be one helper (parameterize the flush fn).
  • flushSpanstracing-outboxed-batch, tracing-scheduled, tracing.test, tracing-messaging.js (unwraps the ProxyTracerProvider → delegate, guards the no-op).
  • clearOutboxmetrics-outbox, tracing-messaging.js (timeout-bounded DELETE FROM cds.outbox.Messages).
  • meaningful / isOutboxScanTracetracing-messaging* (×3 via the shared helper), tracing.test, tracing-scheduled, tracing-messaging.js (filters bookkeeping outbox-scan traces).

Why

These landed independently while stabilizing the HANA suite (#481), so the same logic now exists in 2-6 copies — a maintenance and drift hazard (a fix to the poll/flush logic must be applied N times). Centralizing also shrinks the per-file boilerplate.

Notes

  • Keep the shared module dependency-light and consistent with MyInMemorySpanExporter / MyInMemoryMetricReader conventions (must not require('@sap/cds') at module top).
  • Reconcile the metric-flush (forceFlush on the meter provider) vs span-flush (flushSpans on the tracer provider) variants — likely one generic eventually(assertion, {flush}) plus thin flushSpans/flushMetrics wrappers.

Part of the test-quality cluster (#477 / #478 / #475 / #486 / #487).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions