From b70c1f70fddb4204804a7ffe59a64398db16b9c4 Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Mon, 27 Mar 2023 15:46:12 +0200 Subject: [PATCH] De-flake admin test --- clientapi/admin_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/clientapi/admin_test.go b/clientapi/admin_test.go index 3e7cb875c..791b1d5e5 100644 --- a/clientapi/admin_test.go +++ b/clientapi/admin_test.go @@ -262,6 +262,25 @@ func TestAdminEvacuateRoom(t *testing.T) { } }) } + + // Wait for the FS API to have consumed every message + js, _ := natsInstance.Prepare(processCtx, &cfg.Global.JetStream) + timeout := time.After(time.Second) + for { + select { + case <-timeout: + t.Fatalf("FS API didn't process all events in time") + default: + } + info, err := js.ConsumerInfo(cfg.Global.JetStream.Prefixed(jetstream.OutputRoomEvent), cfg.Global.JetStream.Durable("FederationAPIRoomServerConsumer")+"Pull") + if err != nil { + time.Sleep(time.Millisecond * 10) + continue + } + if info.NumPending == 0 && info.NumAckPending == 0 { + break + } + } }) }