Skip to content

Commit

Permalink
server_test: add Serve()/Shutdown() race test.
Browse files Browse the repository at this point in the history
Signed-off-by: Krisztian Litkey <[email protected]>
  • Loading branch information
klihub committed Sep 13, 2024
1 parent 3f02183 commit b92a55f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,37 @@ func TestServerClose(t *testing.T) {
checkServerShutdown(t, server)
}

func TestImmediateServerShutdown(t *testing.T) {
for i := 0; i < 1024; i++ {
var (
ctx = context.Background()
server = mustServer(t)(NewServer())
addr, listener = newTestListener(t)
errs = make(chan error, 1)
_, cleanup = newTestClient(t, addr)
)
defer cleanup()
defer listener.Close()
go func() {
errs <- server.Serve(ctx, listener)
}()

registerTestingService(server, &testingServer{})

if err := server.Shutdown(ctx); err != nil {
t.Fatal(err)
}
select {
case err := <-errs:
if err != ErrServerClosed {
t.Fatal(err)
}
case <-time.After(time.Second):
t.Fatal("retreiving error from server.Shutdown() timed out")
}
}
}

func TestOversizeCall(t *testing.T) {
var (
ctx = context.Background()
Expand Down

0 comments on commit b92a55f

Please sign in to comment.