merchant: TestPurchaseSessionGuardHoldsThroughTheOutcomeUnknownWindow fails deterministically without ndsctl on PATH — harness installs no fake (needs installRenewalNdsctl)

Chiusa Adatta ai principianti
#822 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
testing

Direzione di ricerca

Inizia da src/merchant/purchasesession_duplicate_guard_test.go, dove newDuplicateGuardMerchant costruisce l'harness e non installa mai un ndsctl fittizio. Guarda installRenewalNdsctl, che altri test del pacchetto già usano, e richiamalo dall'harness. Esegui go test -race -count=3 -tags testenv . -run TestPurchaseSessionGuardHoldsThroughTheOutcomeUnknownWindow in src/merchant senza ndsctl nel PATH. È completato quando il test passa su un host senza ndsctl.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

TestPurchaseSessionGuardHoldsThroughTheOutcomeUnknownWindow (src/merchant/purchasesession_duplicate_guard_test.go:239) fails deterministically on any host without an ndsctl binary on PATH — in isolation and in every full-suite run. The harness newDuplicateGuardMerchant never installs a fake ndsctl (unlike ~10 other tests in the package that call installRenewalNdsctl), so the test's final assertion — the one assertion in the file that requires a successful grant — walks the real valve.OpenGate → authorizeMAC → exec ndsctl path and dies with "executable file not found".

Verified on

  • Commits: cb4db7f (main) and ad6b22e (PR #718 head) — identical behavior; unrelated to #718 (test-file-local harness gap, pre-existing).
  • linux/amd64, go1.26.8, bare host, no ndsctl on PATH.
  • 0/3 isolated runs and 0/4 full-suite runs passed on this host across both commits.

Evidence (verbatim)

--- FAIL: TestPurchaseSessionGuardHoldsThroughTheOutcomeUnknownWindow (1.78s)
    purchasesession_duplicate_guard_test.go:307: the third submission must grant a session, got {"kind":21023,...,["code","payment-received-grant-pending"]...,"content":"Your payment was received, but this TollGate could not open your access just now (the portal manager did not answer). ..."}

Discriminator experiment — identical command with a trivial fake ndsctl (auth → exit 0) prepended to PATH:

--- PASS: TestPurchaseSessionGuardHoldsThroughTheOutcomeUnknownWindow (0.72s)   # ×3, -race -count=3

Mechanism

  1. Third submission: Receive succeeds (scripted wallet, wallet.calls == 2 holds), then grantSessionAccess → openGateForSession → valve.OpenGate → authorizeMAC → runNdsctl("auth", ...) → exec: "ndsctl": executable file not found in $PATH.
  2. valve.AuthDelay is only ever set in main.go from config; in tests it is always 0, so OpenGate always takes the synchronous ndsctl branch (the AuthDelay > 0 deferred-auth branch is the only one that does not exec synchronously).
  3. The failure surfaces as the owed-grant notice (21023 payment-received-grant-pending) instead of the expected kind-1022 session event.
  4. The sibling tests in the same file (e.g. TestPurchaseSessionGuardFailsOpenOnUnserializableNote, the sequential-resubmit test) pass on ndsctl-less hosts because their assertions end in refusal notices — a failed grant still produces an acceptable 21023 there. Only this test asserts the successful grant, which is why the file looks "half green" and the failure reads like a flake of a different class.

Reproduce

cd src/merchant
go test -race -count=3 -tags testenv . -run 'TestPurchaseSessionGuardHoldsThroughTheOutcomeUnknownWindow'   # 3/3 FAIL on a bare host
# then prepend any auth-success ndsctl stub to PATH and re-run          # 3/3 PASS

Impact

Any ndsctl-less CI runner or dev box has a permanently red make go-battery/full suite regardless of other fixes — including main after #718 merges. It also produces misleading full-suite noise (grant-pending notices, owed-grant reconciler activity) that pollutes the log other flaky investigations (#731/#732/#733) read.

Suggested fix

Have newDuplicateGuardMerchant call the existing in-package installRenewalNdsctl(t) (it already scopes a fake via t.Setenv("PATH", ...) and restores it), so the grant path is exercised for real and the file's assertions stop depending on host state. Alternatively, tolerate payment-received-grant-pending at line 306 when ndsctl is absent — weaker, since it stops testing the grant at all.

References

Lingua principale
Go
Stelle
12
Fork
14
Merge medio
3g 20h
PR unite (30g)
261

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OpenTollGate/tollgate-module-basic-go

Tutte le issue di OpenTollGate/tollgate-module-basic-go

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.