Test Discovery and Balancing End-to-End
Distributed Services with Go — by Travis Jeffery (67 / 84)
👈 Route and Balance Requests with Pickers | TOC | What You Learned 👉
We’re ready to update our agent’s tests to test everything end-to-end: the client configuring the resolver and picker, the resolver discovering the servers, and the picker picking subconnections per RPC.
Open your agent tests in internal/agent/agent_test.go and add this import:
ClientSideServiceDiscovery/internal/agent/agent_test.go
"github.com/travisjeffery/proglog/internal/loadbalance"
Then update the client function to use your resolver and picker:
ClientSideServiceDiscovery/internal/agent/agent_test.go
func client(
t *testing.T,
agent *agent.Agent,
tlsConfig *tls.Config,
) api.LogClient {
tlsCreds := credentials.NewTLS(tlsConfig)
opts := []grpc.DialOption{
grpc.WithTransportCredentials(tlsCreds),
}
rpcAddr, err := agent.Config.RPCAddr()
require.NoError(t, err)
» conn, err := grpc.Dial(fmt.Sprintf(
» "%s:///%s",
» loadbalance.Name,
» rpcAddr,
» ), opts...)
require.NoError(t, err)
client := api.NewLogClient(conn)
return client
}