appc: check events in TestUpdateRoutesDeadlock

Change-Id: I13a63e0cbb31bc4ffa00ccc47d5434b7d7b019dd
This commit is contained in:
M. J. Fromberger 2025-09-18 17:25:34 -07:00
parent fde7e17263
commit eca10c0c19

View File

@ -765,9 +765,14 @@ func TestMetricBucketsAreSorted(t *testing.T) {
// routeAdvertiser, calls to Advertise/UnadvertiseRoutes can end up calling // routeAdvertiser, calls to Advertise/UnadvertiseRoutes can end up calling
// back into AppConnector via authReconfig. If everything is called // back into AppConnector via authReconfig. If everything is called
// synchronously, this results in a deadlock on AppConnector.mu. // 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) { func TestUpdateRoutesDeadlock(t *testing.T) {
ctx := t.Context() ctx := t.Context()
bus := eventbustest.NewBus(t) bus := eventbustest.NewBus(t)
w := eventbustest.NewWatcher(t, bus)
rc := &appctest.RouteCollector{} rc := &appctest.RouteCollector{}
a := NewAppConnector(Config{ a := NewAppConnector(Config{
Logf: t.Logf, 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) { 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) 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 { type textUpdate struct {