Skip to content

Regression Testing

Regression is the test platform's primary mode: 78 tests across eight flows — CDR rating, DIAMETER, invoicing, subscriber lifecycle, Mediation (Flow 5), Roaming (Flow 6), Product Catalogue (Flow 7) and the end-to-end convergent-billing use-cases (Flow 8) — with one documented SKIP. Run everything from usr/share/tests/backend/.

Quick start

After the shared prerequisites are in place:

cd usr/share/tests/backend

# Platform already up: just run everything.
./run_tests.sh

# Cold-start the platform, run the suite, then tear it down.
./run_tests.sh --bring-up

Expected outcome:

77 passed, 1 skipped

The single remaining SKIP is the one M-2 parked feature:

Test Reason
F1-11 Missing-functionality M-2 (time-of-day pricing).

Price assertions (F1-04..06, F2-12) never hardcode a unit price: they read the price of the plan version in force on the event date via lib.refdata.active_unit_price and round it up to whole eurocents with ceil_cents, the same way the rater does — so a dated price-plan version (the seed data ships a second plan-3 version from 2026-07-01) cannot stale them.

F1-12 (roaming pricing) asserts against the live roaming rating path (the Rater roaming-tariff branch + the roaming role) and delegates its coverage to Flow 6.

If you see additional skips or failures, the suite has surfaced something new — go to the Triage section.

Selecting a subset

Stage-level shortcuts (the canonical regression gates):

./run_tests.sh --stage 3       # Flow 1 + Flow 2 (CDR + DIAMETER)
./run_tests.sh --stage 4       # Flow 3 + Flow 4 (Invoice + Subscriber)
./run_tests.sh --stage 5       # everything (all eight flows)

Per-flow shortcuts:

./run_tests.sh --flow cdr        # Flow 1 only
./run_tests.sh --flow diameter   # Flow 2 only
./run_tests.sh --flow invoice    # Flow 3 only
./run_tests.sh --flow subscriber # Flow 4 only
./run_tests.sh --flow mediation  # Flow 5 only
./run_tests.sh --flow roaming    # Flow 6 only
./run_tests.sh --flow catalogue  # Flow 7 only
./run_tests.sh --flow e2e        # Flow 8 only

Combinations are valid (./run_tests.sh --stage 4 --flow invoice --bring-up). For finer selection, call pytest directly from the suite directory: .venv/bin/python -m pytest tests/flow6_roaming -k tapout -q.

What each flow exercises

Flow 1 — Postpaid CDR rating (14 tests)

Writes protobuf-serialised .cdr files into var/spool/cdr/new/, waits for cdr_loader to pick them up, asserts on the resulting offline rows, the file's terminal location (processed/.done, error/.error, duplicate/.duplicate), and any notifications emitted along the way.

Timing budget: each test waits up to ~90 s for one loader cycle. Flow 1 dominates suite runtime.

Flow 2 — Prepaid DIAMETER (19 tests)

Opens raw RFC 6733 frames against the prepaid acceptor on TCP 10100 for negative-path coverage, and shells out to bin/diameter_client for positive-path traffic. Asserts on Result-Code values, granted units, and balance_reserve rows.

Timing budget: all tests complete in a few seconds.

Flow 3 — Invoice (11 tests)

Drives CRMService.ExecuteBilling (per-subscriber) and ExecuteBillCycle (cycle-wide) over gRPC, waits for the bill_formatter poll loop, asserts on bills columns (per-service costs, VAT triple, reissue counters, ISO currency code) and on the rendered PDF on disk. F3-10 covers the billing role's resilience to a DB outage: it starts a throwaway billing1 instance with bad credentials and asserts the process survives multiple ticks (skip-and-retry) instead of aborting, and that the real connector error reaches the log.

Timing budget: each test waits up to ~90 s for one formatter tick.

Flow 4 — Subscriber Lifecycle (15 tests)

Drives Create / Modify / Suspend / Reactivate / Terminate / RedeemVoucher over gRPC, and cross-validates the DIAMETER lifecycle gate: a suspended subscriber gets Result-Code 4010 (F4-08), and a pending subscriber gets 4010 until ActivateSubscriber, then 2001 (F4-15). Pure DB / gRPC, no formatter waits.

Flow 5 — Mediation (3 tests)

Drops GRUR usage files into var/spool/mediation/in/ and asserts the mediation role's behaviour: a valid built-in record normalizes + roaming-rates into offline (F5-01); an unrecognized file is quarantined to mediation/reject/ with a .reason and produces no offline row (F5-02); and — the M3 headline — a new vendor format (nokia_nwg_v1.toml, ;-delimited, MB→bytes + ms→s transforms) is added by config and exercised without any recompile (F5-03 writes only a descriptor + a sample, restarts the role, and asserts the record decodes + normalizes).

Timing budget: F5-03 restarts the mediation role mid-test; F5-01 traverses two roles (Mediation → Roaming).

Flow 6 — Roaming (6 tests)

Covers both roaming directions. Direction 1: a roaming CDR is charged at the roaming tariff, not the home price (F6-01); a non-roaming CDR still prices at the home tariff — the B1 canary for the Rater branch (F6-02); a duplicate mediation_id is routed to roaming/duplicate/ with a single offline row (F6-03). Direction 2 (via the CRM gRPC RPCs): the visitor lifecycle bring-in → simulate-usage → end-visit (F6-10); TAP-out output priced at the wholesale IOT with reconciled audit totals and a gap-free per-recipient sequence (F6-11); and the isolation guard that a visitor never produces a home offline/bills/subscriber row (F6-12).

Flow 7 — Product Catalogue (7 tests)

Drives the catalogue gRPC RPCs: service add/rename/retire (with the retire guard that names the blocking plan + bundle), price-plan / bundle / bill-cycle CRUD with their active-subscriber retire guards, and the per-subscriber ChangeSubscriberPlan cutover (a dated subscriber_plan_assignment row + the retired-plan assignment guard, and reactivate-blocked-by-retired-plan).

Flow 8 — End-to-end convergent-billing use-cases (2 tests)

Full multi-flow walks driven through the CRM gRPC surface and the Mediation front door. UC-1 provisions a postpaid subscriber (plan + free-unit bundle, MSISDN/IMSI/card inline), confirms it lands in Pending activation, activates it, pushes two home usage records through Mediation (consuming 99 then the last 1 free Voice minute, rating the remaining 29), and bills on demand to a PDF whose Voice line equals the rated overage. UC-2 exercises a Voice price-plan cutover within one billing period: the free-unit bundle is removed over gRPC (backdated), two Voice events — one before, one after the cutover — enter through Mediation, and the invoice carries both, rated at the old and the new price respectively.

These exercise the Pending/Activate lifecycle and Mediation's home-CDR front door (native passthrough + home-format translation → cdr/new → the home rating path).

Output

By default every test emits the verbose-tag chain on stdout ([TEST]/[SETUP]/[SEND]/[RECV]/[ASSERT]/[RESULT]). For machine-readable output (CI ingestion):

.venv/bin/pip install pytest-json-report
./run_tests.sh --report json        # → run_report.json

For richer pytest tracebacks on failure: ./run_tests.sh --verbose.

Trigger What to run
Local change to a single flow --flow <name>
Local change spanning flows --stage <n> (3, 4 or 5)
Before commit / before PR --bring-up (full suite, cold-start)
Nightly / CI gate --bring-up --report json
Post-platform-restart full suite with --bring-up

Triage

When a test that previously passed begins to fail, work through this in order:

  1. Repro from a cold platform with --bring-up. Half-stuck state from a previous session is the most common false positive (especially bill_formatter).
  2. Read the [RECV] / [ASSERT] lines — the verbose-tag chain says exactly what was expected and what was observed.
  3. Inspect the platform log for the same window:
    ls -t var/log/*/*.log | head -5
    grep <billing_id_or_session_id> var/log/*/*.log
    
  4. Decide the disposition: test bug (fix the test), platform regression (open a non-conformity per the workflow), or environmental (MySQL down, ports busy, license expired).

Known platform issues

The authoritative ledger is ./.claude/NON_CONFORMITIES.md, with each entry referenced from the test that surfaced it. Any failure mode that is not already in the ledger should be captured there per the workflow.