mirror of https://github.com/grpc/grpc-go.git
xds: Fix TestV2ClientBackoffAfterRecvError (#3815)
The failure seems to have been because of the following: * After the stream failure, and after the backoff, the client tries to register all its existing watches. And there seems to have been a race between the re-register and the client close. Hence a log message was getting printing saying "send failed because of EOF". I've fixed this by making sure that the test waits for the xDS request corresponding to the re-registered watch. I've also tried running it a 1000 times without a failure.
This commit is contained in:
parent
9310253e11
commit
6768e33c1f
|
|
@ -508,14 +508,14 @@ func newV2Client(p xdsclient.UpdateHandler, cc *grpc.ClientConn, n *basepb.Node,
|
||||||
return c.(*client), nil
|
return c.(*client), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestV2ClientBackoffAfterRecvError verifies if the v2Client backoffs when it
|
// TestV2ClientBackoffAfterRecvError verifies if the v2Client backs off when it
|
||||||
// encounters a Recv error while receiving an LDS response.
|
// encounters a Recv error while receiving an LDS response.
|
||||||
func (s) TestV2ClientBackoffAfterRecvError(t *testing.T) {
|
func (s) TestV2ClientBackoffAfterRecvError(t *testing.T) {
|
||||||
fakeServer, cc, cleanup := startServerAndGetCC(t)
|
fakeServer, cc, cleanup := startServerAndGetCC(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
// Override the v2Client backoff function with this, so that we can verify
|
// Override the v2Client backoff function with this, so that we can verify
|
||||||
// that a backoff actually was triggerred.
|
// that a backoff actually was triggered.
|
||||||
boCh := make(chan int, 1)
|
boCh := make(chan int, 1)
|
||||||
clientBackoff := func(v int) time.Duration {
|
clientBackoff := func(v int) time.Duration {
|
||||||
boCh <- v
|
boCh <- v
|
||||||
|
|
@ -532,7 +532,6 @@ func (s) TestV2ClientBackoffAfterRecvError(t *testing.T) {
|
||||||
defer v2c.Close()
|
defer v2c.Close()
|
||||||
t.Log("Started xds v2Client...")
|
t.Log("Started xds v2Client...")
|
||||||
|
|
||||||
// v2c.watchLDS(goodLDSTarget1, func(u ldsUpdate, err error) {})
|
|
||||||
v2c.AddWatch(version.V2ListenerURL, goodLDSTarget1)
|
v2c.AddWatch(version.V2ListenerURL, goodLDSTarget1)
|
||||||
if _, err := fakeServer.XDSRequestChan.Receive(); err != nil {
|
if _, err := fakeServer.XDSRequestChan.Receive(); err != nil {
|
||||||
t.Fatalf("Timeout expired when expecting an LDS request")
|
t.Fatalf("Timeout expired when expecting an LDS request")
|
||||||
|
|
@ -552,6 +551,11 @@ func (s) TestV2ClientBackoffAfterRecvError(t *testing.T) {
|
||||||
case <-callbackCh:
|
case <-callbackCh:
|
||||||
t.Fatal("Received unexpected LDS callback")
|
t.Fatal("Received unexpected LDS callback")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, err := fakeServer.XDSRequestChan.Receive(); err != nil {
|
||||||
|
t.Fatalf("Timeout expired when expecting an LDS request")
|
||||||
|
}
|
||||||
|
t.Log("FakeServer received request after backoff...")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestV2ClientRetriesAfterBrokenStream verifies the case where a stream
|
// TestV2ClientRetriesAfterBrokenStream verifies the case where a stream
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue