cleanup: fixes for issues surfaced by vet (#5617)

This commit is contained in:
Easwar Swaminathan 2022-09-02 14:09:10 -07:00 committed by GitHub
parent 99ae81bf6f
commit 60a3a7e969
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 5 additions and 27 deletions

View File

@ -886,9 +886,7 @@ func (w *wrappingTopLevelBalancer) getStates() []balancer.State {
defer w.mu.Unlock()
states := make([]balancer.State, len(w.states))
for i, s := range w.states {
states[i] = s
}
copy(states, w.states)
return states
}

View File

@ -220,7 +220,7 @@ func testFrameTooLarge(t *testing.T, rp string) {
payload := make([]byte, payloadLen)
c, err := clientConn.crypto.Encrypt(nil, payload)
if err != nil {
t.Fatalf(fmt.Sprintf("Error encrypting message: %v", err))
t.Fatalf("Error encrypting message: %v", err)
}
msgLen := msgTypeFieldSize + len(c)
framedMsg := make([]byte, MsgLenFieldSize+msgLen)
@ -229,7 +229,7 @@ func testFrameTooLarge(t *testing.T, rp string) {
binary.LittleEndian.PutUint32(msg[:msgTypeFieldSize], altsRecordMsgType)
copy(msg[msgTypeFieldSize:], c)
if _, err = buf.Write(framedMsg); err != nil {
t.Fatal(fmt.Sprintf("Unexpected error writing to buffer: %v", err))
t.Fatalf("Unexpected error writing to buffer: %v", err)
}
b := make([]byte, 1)
if n, err := serverConn.Read(b); n != 0 || err == nil {

View File

@ -198,10 +198,7 @@ func (tcc *TestClientConn) WaitForPickerWithErr(ctx context.Context, want error)
case <-ctx.Done():
return fmt.Errorf("timeout when waiting for an error picker with %v; last picker error: %v", want, lastErr)
case picker := <-tcc.NewPickerCh:
for i := 0; i < 5; i++ {
if _, lastErr = picker.Pick(balancer.PickInfo{}); lastErr == nil || lastErr.Error() != want.Error() {
break
}
if _, lastErr = picker.Pick(balancer.PickInfo{}); lastErr != nil && lastErr.Error() == want.Error() {
return nil
}
}

View File

@ -127,7 +127,7 @@ func CheckRoundRobinRPCs(ctx context.Context, client testgrpc.TestServiceClient,
}
return nil
}
return fmt.Errorf("Timeout when waiting for roundrobin distribution of RPCs across addresses: %v", addrs)
return fmt.Errorf("timeout when waiting for roundrobin distribution of RPCs across addresses: %v", addrs)
}
// CheckWeightedRoundRobinRPCs verifies that EmptyCall RPCs on the given

View File

@ -76,13 +76,6 @@ func Test(t *testing.T) {
grpctest.RunSubTests(t, s{})
}
func subConnFromPicker(p balancer.Picker) func() balancer.SubConn {
return func() balancer.SubConn {
scst, _ := p.Pick(balancer.PickInfo{})
return scst.SubConn
}
}
func init() {
NewRandomWRR = testutils.NewTestWRR
}

View File

@ -70,16 +70,6 @@ func init() {
balancer.Register(&anotherRR{Builder: balancer.Get(roundrobin.Name)})
}
func subConnFromPicker(t *testing.T, p balancer.Picker) func() balancer.SubConn {
return func() balancer.SubConn {
scst, err := p.Pick(balancer.PickInfo{})
if err != nil {
t.Fatalf("unexpected error from picker.Pick: %v", err)
}
return scst.SubConn
}
}
// When a high priority is ready, adding/removing lower locality doesn't cause
// changes.
//