Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xds/resolver: fix flaky test TestResolverRemovedWithRPCs with a workaround #7804

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions xds/internal/resolver/xds_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,36 @@ func (s) TestResolverRemovedWithRPCs(t *testing.T) {
}
}

// Re-add the listener and expect everything to work again.
configureResourcesOnManagementServer(ctx, t, mgmtServer, nodeID, listeners, routes)
// Read the update pushed by the resolver to the ClientConn.
cs = verifyUpdateFromResolver(ctx, t, stateCh, wantDefaultServiceConfig)
// Workaround for https://github.com/envoyproxy/go-control-plane/issues/431.
//
// The xDS client can miss route configurations due to a race condition
// between resource removal and re-addition. To avoid this, continuously
// push new versions of the resources to the server, ensuring the client
// eventually receives the configuration.
waitForStateUpdate:
for {
sCtx, sCancel := context.WithTimeout(ctx, defaultTestShortTimeout)
defer sCancel()

configureResourcesOnManagementServer(ctx, t, mgmtServer, nodeID, listeners, routes)

select {
case state = <-stateCh:
if err := state.ServiceConfig.Err; err != nil {
t.Fatalf("Received error in service config: %v", state.ServiceConfig.Err)
}
wantSCParsed := internal.ParseServiceConfig.(func(string) *serviceconfig.ParseResult)(wantDefaultServiceConfig)
if !internal.EqualServiceConfigForTesting(state.ServiceConfig.Config, wantSCParsed.Config) {
t.Fatalf("Got service config:\n%s \nWant service config:\n%s", cmp.Diff(nil, state.ServiceConfig.Config), cmp.Diff(nil, wantSCParsed.Config))
}
break waitForStateUpdate
case <-sCtx.Done():
}
}
cs = iresolver.GetConfigSelector(state)
if cs == nil {
t.Fatal("Received nil config selector in update from resolver")
}

res, err = cs.SelectConfig(iresolver.RPCInfo{Context: ctx, Method: "/service/method"})
if err != nil {
Expand Down
Loading