iVendNextDevelopers Request a sandbox

14. Testing and release

A release gate a customer runs before any change reaches a live shop. It rings test sales on a staging shop and turns red if a booked total differs, by even a cent, from what the till showed or from the answer you recorded.

For: every builder before submitting, and a customer's own team before every change reaches a live shop. Reference implementation: The customer's release gate with ../samples/s12_release_gate/ (the script, the recorded-baskets file, an example pipeline) · The money kit, the idea behind it · the manifest checker ../tools/manifest/.

When to use it

Before any change reaches a live shop: an app, a manifest, a price or tax rule. A customer puts the gate in its own pipeline, so a red comes back to its team without us watching.

The idea in one paragraph. The till shows the customer a total before payment (the preview). The sale is then booked. The two must agree to the cent, on every basket. A difference means something moved money the customer never saw. The gate adds a second test: the booked totals must also equal the answers you recorded. So a change of ours or yours that shifts a price or tax shows up as a red basket.

Steps

  1. Check a manifest locally, before anyone installs it (chapter 7):

    python3 tools/manifest/validate.py samples/s2_bins/manifest.json      # VALID, exit 0
    
  2. Record your baskets with their answers. A basket has a name, its lines, an optional sale discount and the answer you expect (grand total and tax).

    • Write them without answers.
    • Run the gate once with --record on a clean staging shop. It is green when preview equals booking.
    • Fill the answers from that run's own record, never by hand arithmetic:
    python3 record_expect.py baskets.norecord.json runs/<run>.json > baskets.json
    

    Re-record only when a price or tax rule you control changes.

  3. Point the script at your staging shop. Only the block marked HERE in release_gate.sh is yours: the staging shop's container, the command that runs a console script there, where it leaves its record, and the two commands that put your baskets file in and take it out.

    • ⚠ Staging only, one gate at a time on a box: it books real sales (simulated card) and closes real till days.
    • The script exits 2 until GATE_CONSOLE, GATE_RUNS and GATE_CONTAINER are set.
    • It expects the money kit (../tools/moneykit/) inside that staging console, pointed at your shop with a shop file (GATE_KIT_SETTINGS).
    • If the customer is on our hosting, how it reaches its staging shop's console is not covered by the kit yet.
  4. Put it in the pipeline. pipeline.example.yml is a job for a runner that lives on the staging box; the job's exit code is the gate's. The example has not yet been run by a CI service: treat it as a starting point.

  5. Run it and read the lines:

    bash samples/s12_release_gate/release_gate.sh --baskets baskets.json [--app DIR] [--manifest FILE]
    
    • --app runs a check of app code in the shop. It is for apps our team builds, and is skipped (and says so) if you ship none.
    • --manifest is read only together with --app. A manifest on its own is checked by step 1, not by the gate.

    A red basket names itself with both figures:

    GATE   G002 RED "two leather cases, 10% markdown"  expected 2,339.20  booked 2,338.20  preview 2,338.20  <- diverged: grand_total: recorded answer 2339.20, booked 2338.20
    GATE RESULT RED — do not release
    

It checks three things and shows all of them, red or green:

Exit 0 only if all three are green. Exit 1 if any is red. Exit 2 if the gate could not run (a baskets file in the wrong shape, a staging shop it cannot reach, a console that rang nothing). Exit 2 is never a pass.

Other tests.

What is refused, and why

When your service is down, and when the till is offline

If your own service is down: not covered by the kit yet. The gate books online, through the till's own calls. By the till's design an offline sale is queued and replayed, booked at the shop's own total, with any difference sent to review. The kit did not run offline.

Technical notes

What the kit has proven

What it has not

See also

7. Manifests · 16. Possible, not possible, limits · 17. Submitting, support, feedback

This page in the kit