Fix flakes

This commit is contained in:
Chris S. Kim 2022-08-22 14:31:32 -04:00
parent 03e92826aa
commit cdc8b0634d

View File

@ -634,12 +634,23 @@ func TestSubscriptionManager_ServerAddrs(t *testing.T) {
backend := newTestSubscriptionBackend(t) backend := newTestSubscriptionBackend(t)
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() t.Cleanup(cancel)
// Create a peering // Create a peering
_, id := backend.ensurePeering(t, "my-peering") _, id := backend.ensurePeering(t, "my-peering")
partition := acl.DefaultEnterpriseMeta().PartitionOrEmpty() partition := acl.DefaultEnterpriseMeta().PartitionOrEmpty()
payload := autopilotevents.EventPayloadReadyServers{
autopilotevents.ReadyServerInfo{
ID: "9aeb73f6-e83e-43c1-bdc9-ca5e43efe3e4",
Address: "198.18.0.1",
Version: "1.13.1",
ExtGRPCPort: 8502,
},
}
// mock handler only gets called once during the initial subscription
backend.handler.expect("", 0, 1, payload)
// Only configure a tracker for CA roots events. // Only configure a tracker for CA roots events.
tracker := newResourceSubscriptionTracker() tracker := newResourceSubscriptionTracker()
tracker.Subscribe(pbpeerstream.TypeURLPeeringServerAddresses) tracker.Subscribe(pbpeerstream.TypeURLPeeringServerAddresses)
@ -651,23 +662,13 @@ func TestSubscriptionManager_ServerAddrs(t *testing.T) {
ConnectEnabled: true, ConnectEnabled: true,
}, },
connect.TestTrustDomain, connect.TestTrustDomain,
backend, func() StateStore { backend,
func() StateStore {
return backend.store return backend.store
}, },
tracker) tracker)
subCh := mgr.subscribe(ctx, id, "my-peering", partition) subCh := mgr.subscribe(ctx, id, "my-peering", partition)
payload := autopilotevents.EventPayloadReadyServers{
autopilotevents.ReadyServerInfo{
ID: "9aeb73f6-e83e-43c1-bdc9-ca5e43efe3e4",
Address: "198.18.0.1",
Version: "1.13.1",
ExtGRPCPort: 8502,
},
}
// mock handler only gets called once during the initial subscription
backend.handler.expect("", 0, 1, payload)
testutil.RunStep(t, "initial events", func(t *testing.T) { testutil.RunStep(t, "initial events", func(t *testing.T) {
expectEvents(t, subCh, expectEvents(t, subCh,
func(t *testing.T, got cache.UpdateEvent) { func(t *testing.T, got cache.UpdateEvent) {