Skip to content

Commit

Permalink
Merge pull request #375 from srprash/fix_flaky_tests
Browse files Browse the repository at this point in the history
Local test daemon for grpc server test cases
  • Loading branch information
srprash authored Aug 12, 2022
2 parents 0f2ea34 + 5b2a364 commit 55fd2bf
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions xray/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,6 @@ func TestGrpcUnaryClientInterceptor(t *testing.T) {
}

func TestUnaryServerInterceptor(t *testing.T) {
ctx, td := NewTestDaemon()
defer td.Close()

lis := newGrpcServer(
t,
grpc.UnaryInterceptor(
UnaryServerInterceptor(
WithRecorder(GetRecorder(ctx)),
WithSegmentNamer(NewFixedSegmentNamer("test")))),
)
client, closeFunc := newGrpcClient(context.Background(), t, lis)
defer closeFunc()

testCases := []testCase{
{
name: "success response",
Expand Down Expand Up @@ -300,6 +287,24 @@ func TestUnaryServerInterceptor(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {

// Ideally we shouldn't be creating a local test daemon for each test case.
// However, how the shared channel in the test daemon doesn't guarantee
// segment isolation across test cases. Therefore, for now a local test daemon
// is a workaround.
ctx, td := NewTestDaemon()
defer td.Close()

lis := newGrpcServer(
t,
grpc.UnaryInterceptor(
UnaryServerInterceptor(
WithRecorder(GetRecorder(ctx)),
WithSegmentNamer(NewFixedSegmentNamer("test")))),
)
client, closeFunc := newGrpcClient(context.Background(), t, lis)
defer closeFunc()

var respHeaders metadata.MD
if tc.isTestForSuccessResponse() {
_, err := client.Ping(
Expand Down

0 comments on commit 55fd2bf

Please sign in to comment.