X-Git-Url: https://gerrit.fd.io/r/gitweb?p=govpp.git;a=blobdiff_plain;f=core%2Fconnection_test.go;fp=core%2Fconnection_test.go;h=81b145c415bc3aef3aee8d5529895ff8288cc738;hp=230eea56a08afabf2d4d73efe51674d9bf5241a6;hb=945b7c7ae69c414ef851f85596be4edeb1d9290e;hpb=4a4094e6cdc7f5d9e5a470ccf82df1c780c7e224 diff --git a/core/connection_test.go b/core/connection_test.go index 230eea5..81b145c 100644 --- a/core/connection_test.go +++ b/core/connection_test.go @@ -16,6 +16,7 @@ package core_test import ( "testing" + "time" . "github.com/onsi/gomega" @@ -91,6 +92,28 @@ func TestAsyncConnection(t *testing.T) { Expect(ev.State).Should(BeEquivalentTo(core.Connected)) } +func TestAsyncConnectionProcessesVppTimeout(t *testing.T) { + ctx := setupTest(t, false) + defer ctx.teardownTest() + + ctx.conn.Disconnect() + conn, statusChan, err := core.AsyncConnect(ctx.mockVpp, core.DefaultMaxReconnectAttempts, core.DefaultReconnectInterval) + ctx.conn = conn + + Expect(err).ShouldNot(HaveOccurred()) + Expect(conn).ShouldNot(BeNil()) + + ev := <-statusChan + Expect(ev.State).Should(BeEquivalentTo(core.Connected)) + + // make control ping reply fail so that connection.healthCheckLoop() + // initiates reconnection. + ctx.mockVpp.MockReply(&vpe.ControlPingReply{ + Retval: -1, + }) + time.Sleep(time.Duration(1+core.HealthCheckThreshold) * (core.HealthCheckInterval + 2*core.HealthCheckReplyTimeout)) +} + func TestCodec(t *testing.T) { RegisterTestingT(t)