Skip to content

Commit

Permalink
Use membership resolver for SDK clients in functional tests (#6578)
Browse files Browse the repository at this point in the history
## What changed?
Instead of picking the first frontend for SDK clients, balance using the
grpc resolver.

## Why?
Make tests behave more like real code.

## How did you test it?
is tests
  • Loading branch information
dnr authored Sep 30, 2024
1 parent 62e4e66 commit 0d4e202
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/onebox.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ type (

// This is used to wait for namespace registries to have noticed a change in some xdc tests.
frontendNamespaceRegistries []namespace.Registry
// Address for SDK to connect to, using membership grpc resolver.
frontendMembershipAddress string

// These are routing/load balancing clients but do not do retries:
adminClient adminservice.AdminServiceClient
Expand Down Expand Up @@ -351,9 +353,9 @@ func (c *temporalImpl) FrontendGRPCAddresses() []string {
return c.makeGRPCAddresses(c.frontendConfig.NumFrontendHosts, frontendPort)
}

// Use this to get an address for the Go SDK to connect to.
func (c *temporalImpl) FrontendGRPCAddress() string {
// TODO: use grpc membership resolver to load-balance
return c.FrontendGRPCAddresses()[0]
return c.frontendMembershipAddress
}

func (c *temporalImpl) FrontendHTTPAddress() string {
Expand Down Expand Up @@ -422,6 +424,7 @@ func (c *temporalImpl) startFrontend() {
var rpcFactory common.RPCFactory
var historyRawClient resource.HistoryRawClient
var matchingRawClient resource.MatchingRawClient
var grpcResolver *membership.GRPCResolver

for _, host := range c.hostsByService[serviceName].All {
logger := log.With(c.logger, tag.Host(host))
Expand Down Expand Up @@ -467,7 +470,7 @@ func (c *temporalImpl) startFrontend() {
fx.Supply(c.spanExporters),
temporal.ServiceTracingModule,
frontend.Module,
fx.Populate(&namespaceRegistry, &rpcFactory, &historyRawClient, &matchingRawClient),
fx.Populate(&namespaceRegistry, &rpcFactory, &historyRawClient, &matchingRawClient, &grpcResolver),
temporal.FxLogAdapter,
c.getFxOptionsForService(primitives.FrontendService),
)
Expand All @@ -493,6 +496,9 @@ func (c *temporalImpl) startFrontend() {
// We also set the history and matching clients here, stealing them from one of the frontends.
c.historyClient = historyRawClient
c.matchingClient = matchingRawClient

// Address for SDKs
c.frontendMembershipAddress = grpcResolver.MakeURL(serviceName)
}

func (c *temporalImpl) startHistory() {
Expand Down

0 comments on commit 0d4e202

Please sign in to comment.