Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky gRPC server shutdown in tests #6191

Merged
merged 2 commits into from
May 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions pkg/storage/stores/shipper/gateway_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"log"
"net"
"os"
"path/filepath"
Expand Down Expand Up @@ -115,19 +114,16 @@ func createTestGrpcServer(t *testing.T) (func(), string) {
indexgatewaypb.RegisterIndexGatewayServer(s, &server)
go func() {
if err := s.Serve(lis); err != nil {
log.Fatalf("Failed to serve: %v", err)
t.Logf("Failed to serve: %v", err)
}
}()
cleanup := func() {
s.GracefulStop()
}

return cleanup, lis.Addr().String()
return s.GracefulStop, lis.Addr().String()
}

func TestGatewayClient(t *testing.T) {
cleanup, storeAddress := createTestGrpcServer(t)
defer cleanup()
t.Cleanup(cleanup)

var cfg IndexGatewayClientConfig
cfg.Mode = indexgateway.SimpleMode
Expand Down Expand Up @@ -313,7 +309,7 @@ func Benchmark_QueriesMatchingLargeNumOfRows(b *testing.B) {
func TestDoubleRegistration(t *testing.T) {
r := prometheus.NewRegistry()
cleanup, storeAddress := createTestGrpcServer(t)
defer cleanup()
t.Cleanup(cleanup)

_, err := NewGatewayClient(IndexGatewayClientConfig{
Address: storeAddress,
Expand Down