From eca10c0c192be545ef3bc4a65f63e2adf35dd492 Mon Sep 17 00:00:00 2001 From: "M. J. Fromberger" Date: Thu, 18 Sep 2025 17:25:34 -0700 Subject: [PATCH] appc: check events in TestUpdateRoutesDeadlock Change-Id: I13a63e0cbb31bc4ffa00ccc47d5434b7d7b019dd --- appc/appconnector_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/appc/appconnector_test.go b/appc/appconnector_test.go index e8aa9aed9..4eff703cf 100644 --- a/appc/appconnector_test.go +++ b/appc/appconnector_test.go @@ -765,9 +765,14 @@ func TestMetricBucketsAreSorted(t *testing.T) { // routeAdvertiser, calls to Advertise/UnadvertiseRoutes can end up calling // back into AppConnector via authReconfig. If everything is called // synchronously, this results in a deadlock on AppConnector.mu. +// +// TODO(creachadair, 2025-09-18): Remove this along with the advertiser +// interface once the LocalBackend is switched to use the event bus and the +// tests have been updated not to need it. func TestUpdateRoutesDeadlock(t *testing.T) { ctx := t.Context() bus := eventbustest.NewBus(t) + w := eventbustest.NewWatcher(t, bus) rc := &appctest.RouteCollector{} a := NewAppConnector(Config{ Logf: t.Logf, @@ -819,6 +824,15 @@ func TestUpdateRoutesDeadlock(t *testing.T) { if want := []netip.Prefix{netip.MustParsePrefix("127.0.0.1/32")}; !slices.Equal(slices.Compact(rc.Routes()), want) { t.Fatalf("got %v, want %v", rc.Routes(), want) } + + if err := eventbustest.ExpectExactly(w, + eqUpdate(RouteUpdate{Advertise: prefixes("127.0.0.1/32", "127.0.0.2/32")}), + eventbustest.Type[RouteInfo](), + eqUpdate(RouteUpdate{Advertise: prefixes("127.0.0.1/32"), Unadvertise: prefixes("127.0.0.2/32")}), + eventbustest.Type[RouteInfo](), + ); err != nil { + t.Error(err) + } } type textUpdate struct {