test(messaging): wait for the applied callback counter in the dev end-to-end check

Offen Anfängerfreundlich
#2,916 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
88/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
docker, postgresql, rust, shell
Bereich
backend, testing

Rechercherichtung

Lies products/messaging/scripts/test-dev.sh und finde heraus, wo das Skript nach dem Warten auf den SMS-Status die Metrik messaging_provider_callbacks_total{outcome="applied"} prüft. Frage die Metrik innerhalb der bestehenden begrenzten Wartezeit wiederholt ab, behalte den erwarteten Wert bei 1 und gib bei einer Zeitüberschreitung den letzten Wert aus. Führe das Skript mit Docker aus und prüfe es anschließend mit ShellCheck und shfmt -d; fertig ist es, wenn die Prüfung auf den Zähler wartet und doppelte Callbacks weiterhin ablehnt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

What fails

products/messaging/scripts/test-dev.sh can fail in the Messaging PostgreSQL runtime CI job with:

test-dev: GET /v1/messages/<sms>: status delivered
test-dev: GET /v1/messages/<email>: status submitted
test-dev: Mailpit holds 1 message
test-dev: 0 signed callbacks were applied, expected 1

It failed once on pull request #2913, in a run whose changes touch no Messaging code or script. The same job passed on the previous two runs.

Why

The script waits, with a bound, until the SMS reads delivered. It then reads messaging_provider_callbacks_total{outcome="applied"} once.

The runtime records that counter after the callback is handled. In crates/registry-messaging/src/callbacks.rs, the handler awaits receive_callback, which commits the status change, and then calls state.metrics.record_callback(outcome). A status read that lands between the commit and the counter update sees delivered while the counter is still 0. The single metrics read then fails the check.

The runtime behaviour is fine: the counter is eventually correct, and nothing reads it as a commit signal. The check is too strict about ordering.

Proposed change

Read the applied counter inside the same kind of bounded wait the script already uses for the message status. For example, poll $dev_metrics every 0.5 seconds until the applied count is 1 or settle_seconds passes, then fail with the last value read.

Keep the exact expectation of 1, so a duplicate callback still fails the check.

Verification

  • products/messaging/scripts/test-dev.sh passes locally with Docker.
  • ShellCheck and shfmt -d are clean on the script.
  • Optional: inject a short delay before record_callback in a local build and confirm that the check waits rather than fails.
Vorherrschende Sprache
Rust
Sterne
2
Forks
0
Ø Merge
13 Std. 7 Min.
Gemergte PRs (30 T.)
119

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus registrystack/registry-stack

Alle Issues in registrystack/registry-stack

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.