RO service (stranger-pings)
    • Integration Medic
    • Repair orders
      • List repair orders
        GET
      • Get repair order
        GET
      • Save edits (local only)
        PUT
      • Select target customer (local only)
        PUT
      • Send to DMS (transfer)
        POST
      • Send 10003 (closed order, expect 422 field=status)
        POST
      • Send 10005 (warranty order, expect 502 seeded defect)
        POST
    • Customer search
      • Search customers
        GET
      • Search, blank q (expect 400 INVALID_QUERY)
        GET
      • Search, pageSize 100 (capped at 25)
        GET
    • Integration status and control
      • Public integration status
        GET
      • Control record
        GET
      • Open circuit
        PUT
      • Half-open circuit
        PUT
      • Force circuit closed (ADMIN)
        PUT
    • Mock DMS admin
      • Health
        GET
      • Reset
        POST
      • Mode: schema v2 (scenario 2)
        POST
      • Mode: schema v1 (back to normal)
        POST
      • Mode: HTTP 503 (DMS unavailable)
        POST
      • Mode: available again
        POST
      • Direct: search customers (registered store e1/s1)
        GET
      • Direct: unregistered store (expect 403)
        GET

    Integration Medic

    Integration Medic: DMS failure runbook#

    One pass through the five DMS failure scenarios, in about 15 minutes, on your own machine. For each step: what to do, what the UI shows, the log lines Integration Medic should find, and the signal that tells the scenarios apart.
    Synthetic data only. Run this against a local mock DMS, never the shared AWS one: sends change the DMS data.
    Checked against the code on 2026-10-27; not yet run end to end as a single pass. Exact log text may differ slightly.

    What you need#

    PartRepoPort
    Mock DMSstranger-pings-mock-dms8081
    RO servicestranger-pings-service8090
    UIstranger-pings-service/ui4200
    The RO service must include the DmsClient fix (PR #4). Without it, every DMS 4xx or 5xx is logged as DMS unreachable … FileNotFoundException and the scenarios look the same in the logs. The UI is in PR #3.
    The commands below are PowerShell. Bash equivalents are at the end.

    Before you start#

    1.
    Mock DMS: run MockDmsApplication with the environment variable PORT=8081.
    2.
    RO service: run RoApplication from the repo root (it reads ./config and ./data) with these environment variables. The tokens are placeholders; never use real ones.
    SERVER_SERVLET_CONTEXT_PATH=/stranger-pings-service;DMS_BASEURL=http://localhost:8081;CONTROL_TOKEN_MEDIC=change-me-medic;CONTROL_TOKEN_WATCHER=change-me-watcher;CONTROL_TOKEN_ADMIN=change-me-admin
    In IntelliJ: Run > Edit Configurations > Modify options > Environment variables.
    3.
    UI: in ui, run npm ci once, then npm start.
    4.
    Open http://localhost:4200/stranger-pings-service/. Don't add ?mock=1: mock mode never reaches the service, so nothing is logged.
    5.
    Keep both logs visible. The RO service log is what Medic reads; the mock DMS log shows the DMS side.
    6.
    Check the RO service startup line: DMS adapter config loaded: baseUrl=http://localhost:8081, enterpriseId=e1, storeId=s1, …
    7.
    No banner on the page means the circuit is CLOSED.
    Clicking any RO in the list logs INFO … RoService - Loaded RO 10001 for <name> <email>. The customer data in that line is there on purpose, for Medic's log scrubbing.

    Summary#

    StepScenarioTriggerKey log signalMedic reason code
    1NormalSend RO 10001sent to DMS, status=204, dmsVersion=1none
    23 bad user dataSend RO 10003, or an unknown VIN409 field status, or 404 field vehicleId, one RO onlynone (user fixes the data)
    35 warrantySend RO 10005500 with no details; DMS log rule=warranty-order-customer-laborcode fix
    42 DMS changeMock DMS to v2400, dmsVersion=2, newCustomerIdDMS_CHANGE
    51 bad configstoreId: s2403 on every call; startup line storeId=s2CONFIG_ISSUE
    64 DMS downStop the mock DMSDMS unreachable … ConnectExceptionDMS_UNAVAILABLE

    Step 1: Normal send (the baseline)#

    Do: RO 10001 → Send to DMS.
    UI: "Sent to the DMS." at the bottom of the page.
    RO service log: Sending RO 10001 to DMS, then RO 10001 sent to DMS, status=204, dmsVersion=1, durationMs=…
    For Medic: the healthy pattern. Step 4 compares against dmsVersion=1.

    Step 2: Bad user data (scenario 3)#

    Do: RO 10003 (CLOSED) → Send. RO 10004 (INVOICED) behaves the same.
    UI: "This repair order is closed or invoiced and cannot be transferred."
    RO service log:
    ERROR … DmsClient - DMS call failed for RO 10003: POST /e1/s1/v1/repair-orders/a0000000-0000-4000-8000-000000000003/transfer returned 409 Conflict, dmsVersion=1, body={…"details":[{"field":"status","value":"CLOSED","issue":"repair order is CLOSED"}]…}
    com.example.ro.dms.DmsClientException: DMS returned 409
    Unknown-vehicle variant:
    1.
    Open RO 10002, change the VIN to TESTVIN9999999999, Save, then Send.
    2.
    UI: "The DMS does not recognise this vehicle…" in the result area and beside the VIN.
    3.
    Log: returned 404 Not Found … "field":"vehicleId" … "vehicle not found".
    4.
    Afterwards set the VIN back to TESTVIN0000000002 and Save.
    For Medic: one RO fails with a 409 or 404 that names a field, while other ROs still succeed. The problem is the user's data, not the integration: don't open the circuit. The user has already seen a specific message.

    Step 3: Warranty order (scenario 5)#

    Do: RO 10005 (labour type WARRANTY) → Send.
    UI: "The DMS could not process this repair order. Please try again later."
    RO service log: DMS call failed for RO 10005: POST …/a0000000-0000-4000-8000-000000000005/transfer returned 500 Internal Server Error, dmsVersion=1, body={…"message":"An unexpected error occurred"…}. The body has no details.
    Mock DMS log: ERROR … transfer failed repairOrderId=a0000000-0000-4000-8000-000000000005 rule=warranty-order-customer-labor
    For Medic: only the warranty RO fails, with an unexplained 500, and the cause appears only in the DMS log. It points at RoMapper, which sends every labour line as linePayer: CUSTOMER.

    Step 4: DMS API change (scenario 2)#

    Do: switch the mock DMS to v2, then send RO 10001.
    Invoke-RestMethod -Method Post -Uri http://localhost:8081/admin/mode -ContentType 'application/json' -Body '{"schemaVersion":"v2"}'
    UI: the generic message.
    RO service log: DMS call failed for RO 10001: … returned 400 Bad Request, dmsVersion=2, body={…"newCustomerId"…"is required"…"customerId"…"unknown field"…}
    Mock DMS log: admin mode changed: schema=v2 availability=up
    For Medic: dmsVersion changed from 1 to 2, every RO now fails with the same 400, and the field names show customerId was renamed to newCustomerId.
    Undo: the same command with "v1".

    Step 5: Bad configuration (scenario 1)#

    Do:
    1.
    In the service's config/dms-adapter.yml, set storeId: s2 and restart the RO service.
    2.
    Check that the startup line now shows storeId=s2.
    3.
    Send RO 10001, then search for "anderson".
    UI: the generic send message. The search shows "The DMS could not search customers. Please try again later."
    RO service log: POST /e1/s2/v1/repair-orders/…/transfer returned 403 Forbidden … "Enterprise or store is not registered", and the same 403 for customer search: GET /e1/s2/v3/customers.
    Mock DMS log: WARN … request rejected rule=unregistered-store enterpriseId=e1 storeId=s2
    For Medic: every call has failed with 403 since the restart, and the startup line shows the changed storeId.
    Undo: set storeId: s1 and restart. Don't commit the change during a rehearsal. For the demo, the service README commits the bad value so Medic can find the change in git; agree that with the team first.

    Step 6: DMS down, and Medic's response (scenario 4)#

    Do: stop the mock DMS, then send RO 10001.
    UI: the generic message.
    RO service log:
    ERROR … DmsClient - DMS unreachable for RO 10001: java.net.ConnectException: Connection refused…
    com.example.ro.dms.DmsUnreachableException: DMS unreachable
    For Medic: there is no HTTP status at all, and every call fails.
    Variants: with the mock DMS running, post {"availability":"timeout"} or {"availability":"http503"} to /admin/mode.
    timeout logs java.net.SocketTimeoutException: Read timed out after 3 seconds.
    http503 logs returned 503 Service Unavailable.
    Post {"availability":"up"} to undo.

    Medic's response (optional)#

    The service never opens the circuit by itself; only Medic does.
    1.
    Open the circuit with the Medic token:
    Invoke-RestMethod -Method Put -Uri http://localhost:8090/stranger-pings-service/internal/integration-control/dms -Headers @{ 'X-Control-Token' = 'change-me-medic' } -ContentType 'application/json' -Body '{"state":"OPEN","reason_code":"DMS_UNAVAILABLE","ticket":"SP-101","auto_recover":true}'
    Log: Circuit state changed CLOSED -> OPEN (set_by=medic, reason=DMS_UNAVAILABLE, ticket=SP-101, …)
    Within 5 seconds the UI shows the amber banner. Search and Send are disabled.
    Saving an edit shows "Pending sync".
    2.
    Start the mock DMS again. Within about 10 seconds the health check logs Circuit state changed OPEN -> HALF_OPEN (set_by=adapter, …) and the banner turns blue.
    3.
    Send RO 10001. While the banner is blue, each send is a trial of the connection.
    Wait 30 seconds and send again. The log shows Circuit state changed HALF_OPEN -> CLOSED (set_by=adapter, 2 successful trials) and the banner disappears.
    A send within those 30 seconds logs WARN … Circuit HALF_OPEN …; skipping DMS call for RO 10001, and the UI shows "Your changes are saved. Please try again later."
    reason_code can be CONFIG_ISSUE, DMS_CHANGE or DMS_UNAVAILABLE; each shows its own banner text. The ticket must look like ABC-123. Only DMS_UNAVAILABLE with auto_recover moves to HALF_OPEN as soon as the DMS health check passes. For the others, the Watcher token moves the circuit from OPEN to HALF_OPEN ({"state":"HALF_OPEN"}), or it moves there by itself when expires_at passes (60 minutes by default).

    Clean up#

    Circuit stuck: force it closed with the admin token.
    Invoke-RestMethod -Method Put -Uri http://localhost:8090/stranger-pings-service/internal/integration-control/dms -Headers @{ 'X-Control-Token' = 'change-me-admin' } -ContentType 'application/json' -Body '{"state":"CLOSED"}'
    Rerunning step 6: after the circuit closes, Medic can't reopen it for 120 seconds (409 ANTI_FLAP).
    Mock DMS: restarting it, or POST /admin/reset, returns it to v1, available, with the original seed data.
    Config: leave config/dms-adapter.yml at storeId: s1, and don't commit local edits.
    Local data: to start the RO service from fresh seed data, stop it and delete its data folder.

    Bash equivalents#

    Modified at 2026-11-10 03:27:40
    Next
    List repair orders
    Built with