Skip to content

Commit

Permalink
fix race in test
Browse files Browse the repository at this point in the history
Signed-off-by: crazycs520 <[email protected]>
  • Loading branch information
crazycs520 committed Apr 1, 2024
1 parent 2a07af4 commit a6e4f8b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,8 @@ func TestRandomRestartStoreAndForwarding(t *testing.T) {
wg := sync.WaitGroup{}
done := int64(0)
concurrency := 500
addr1 := store1.Addr()
addr2 := store2.Addr()
wg.Add(1)
go func() {
defer wg.Done()
Expand All @@ -927,7 +929,7 @@ func TestRandomRestartStoreAndForwarding(t *testing.T) {
}
}()

conn, err := client1.getConnArray(store1.Addr(), true)
conn, err := client1.getConnArray(addr1, true)
assert.Nil(t, err)
for j := 0; j < concurrency; j++ {
wg.Add(1)
Expand All @@ -940,8 +942,9 @@ func TestRandomRestartStoreAndForwarding(t *testing.T) {
req := &tikvpb.BatchCommandsRequest_Request{Cmd: &tikvpb.BatchCommandsRequest_Request_Coprocessor{Coprocessor: &coprocessor.Request{}}}
forwardedHost := ""
if i%2 != 0 {
forwardedHost = addr2
}
_, err := sendBatchRequest(context.Background(), store1.Addr(), forwardedHost, conn.batchConn, req, time.Millisecond*50, 0)
_, err := sendBatchRequest(context.Background(), addr1, forwardedHost, conn.batchConn, req, time.Millisecond*50, 0)
if err == nil ||
err.Error() == "EOF" ||
err.Error() == "rpc error: code = Unavailable desc = error reading from server: EOF" ||
Expand Down

0 comments on commit a6e4f8b

Please sign in to comment.