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

golint fix: context.Context should be the first parameter of a function #7338

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Changes from all commits
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
16 changes: 8 additions & 8 deletions xds/internal/balancer/ringhash/e2e/ringhash_balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func channelIDHashRoute(routeName, virtualHostDomain, clusterName string) *v3rou
// checkRPCSendOK sends num RPCs to the client. It returns a map of backend
// addresses as keys and number of RPCs sent to this address as value. Abort the
// test if any RPC fails.
func checkRPCSendOK(t *testing.T, ctx context.Context, client testgrpc.TestServiceClient, num int) map[string]int {
func checkRPCSendOK(ctx context.Context, t *testing.T, client testgrpc.TestServiceClient, num int) map[string]int {
t.Helper()

backendCount := make(map[string]int)
Expand Down Expand Up @@ -306,7 +306,7 @@ func (s) TestRingHash_AggregateClusterFallBackFromRingHashAtStartup(t *testing.T
defer conn.Close()
client := testgrpc.NewTestServiceClient(conn)

gotPerBackend := checkRPCSendOK(t, ctx, client, 100)
gotPerBackend := checkRPCSendOK(ctx, t, client, 100)

// Since this is using ring hash with the channel ID as the key, all RPCs
// are routed to the same backend of the secondary locality.
Expand Down Expand Up @@ -415,7 +415,7 @@ func (s) TestRingHash_AggregateClusterFallBackFromRingHashToLogicalDnsAtStartup(
defer conn.Close()
client := testgrpc.NewTestServiceClient(conn)

gotPerBackend := checkRPCSendOK(t, ctx, client, 1)
gotPerBackend := checkRPCSendOK(ctx, t, client, 1)
var got string
for got = range gotPerBackend {
}
Expand Down Expand Up @@ -599,7 +599,7 @@ func (s) TestRingHash_ChannelIdHashing(t *testing.T) {
defer conn.Close()
client := testgrpc.NewTestServiceClient(conn)

received := checkRPCSendOK(t, ctx, client, 100)
received := checkRPCSendOK(ctx, t, client, 100)
if len(received) != 1 {
t.Errorf("Got RPCs routed to %v backends, want %v", len(received), 1)
}
Expand Down Expand Up @@ -685,7 +685,7 @@ func (s) TestRingHash_HeaderHashing(t *testing.T) {
// create the entry in the ring.
for _, backend := range backends {
ctx := metadata.NewOutgoingContext(ctx, metadata.Pairs("address_hash", backend.Address+"_0"))
reqPerBackend := checkRPCSendOK(t, ctx, client, 1)
reqPerBackend := checkRPCSendOK(ctx, t, client, 1)
if reqPerBackend[backend.Address] != 1 {
t.Errorf("Got RPC routed to backend %v, want %v", reqPerBackend, backend.Address)
}
Expand Down Expand Up @@ -761,7 +761,7 @@ func (s) TestRingHash_HeaderHashingWithRegexRewrite(t *testing.T) {
gotPerBackend := make(map[string]int)
for _, backend := range backends {
ctx := metadata.NewOutgoingContext(ctx, metadata.Pairs("address_hash", backend.Address+"_0"))
res := checkRPCSendOK(t, ctx, client, 100)
res := checkRPCSendOK(ctx, t, client, 100)
for addr, count := range res {
gotPerBackend[addr] += count
}
Expand Down Expand Up @@ -862,7 +862,7 @@ func (s) TestRingHash_NoHashPolicy(t *testing.T) {
client := testgrpc.NewTestServiceClient(conn)

// Send a large number of RPCs and check that they are distributed randomly.
gotPerBackend := checkRPCSendOK(t, ctx, client, numRPCs)
gotPerBackend := checkRPCSendOK(ctx, t, client, numRPCs)
for _, backend := range backends {
got := float64(gotPerBackend[backend.Address]) / float64(numRPCs)
want := .5
Expand Down Expand Up @@ -927,7 +927,7 @@ func (s) TestRingHash_EndpointWeights(t *testing.T) {

// Send a large number of RPCs and check that they are distributed randomly.
numRPCs := computeIdealNumberOfRPCs(t, .25, errorTolerance)
gotPerBackend := checkRPCSendOK(t, ctx, client, numRPCs)
gotPerBackend := checkRPCSendOK(ctx, t, client, numRPCs)

got := float64(gotPerBackend[backends[0].Address]) / float64(numRPCs)
want := .25
Expand Down
Loading