mirror of
https://github.com/gravitational/teleport
synced 2024-10-19 16:53:57 +00:00
fix flaky teleterm daemon test (#29218)
This commit is contained in:
parent
b0a787021b
commit
ed8d212812
|
@ -22,7 +22,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/gravitational/trace"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
|
@ -451,12 +450,22 @@ func newMockTSHDEventsServiceServer(t *testing.T) (service *mockTSHDEventsServic
|
|||
|
||||
grpcServer := grpc.NewServer()
|
||||
api.RegisterTshdEventsServiceServer(grpcServer, tshdEventsService)
|
||||
t.Cleanup(grpcServer.GracefulStop)
|
||||
|
||||
serveErr := make(chan error)
|
||||
go func() {
|
||||
err := grpcServer.Serve(ls)
|
||||
assert.NoError(t, err)
|
||||
serveErr <- grpcServer.Serve(ls)
|
||||
}()
|
||||
t.Cleanup(func() {
|
||||
grpcServer.GracefulStop()
|
||||
|
||||
// For test cases that did not send any grpc calls, test may finish
|
||||
// before grpcServer.Serve is called and grpcServer.Serve will return
|
||||
// grpc.ErrServerStopped.
|
||||
err := <-serveErr
|
||||
if len(tshdEventsService.callCounts) > 0 || err != grpc.ErrServerStopped {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
})
|
||||
|
||||
return tshdEventsService, ls.Addr().String()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue