-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
test: modify tests to use stubserver instead of test service #7976
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #7976 +/- ##
==========================================
- Coverage 82.05% 82.04% -0.01%
==========================================
Files 381 381
Lines 38539 38539
==========================================
- Hits 31622 31620 -2
+ Misses 5602 5598 -4
- Partials 1315 1321 +6 |
test/healthcheck_test.go
Outdated
} | ||
healthgrpc.RegisterHealthServer(stub.S, ts) | ||
stubserver.StartTestService(t, stub) | ||
t.Cleanup(func() { stub.Stop() }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be stub.S.Stop()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
test/stats_test.go
Outdated
errCh := make(chan error) | ||
go func() { | ||
errCh <- s.Serve(l) | ||
errCh <- ss.S.Serve(ss.Listener) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should remove the redundant Serve
since StartTestService
already start the server. This has to be followed for every change. Please keep in mind for future changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
test/healthcheck_test.go
Outdated
return s, lis, ts | ||
stub := &stubserver.StubServer{ | ||
Listener: lis, | ||
EmptyCallF: func(_ context.Context, _ *testpb.Empty) (*testpb.Empty, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From where did this EmptyCallF and FullDuplexCallF implementation taken from? How is this being used? I can't find it. The testServer{} which is being replaced has totally different implementation here
Line 150 in 724f450
func (s *testServer) EmptyCall(ctx context.Context, _ *testpb.Empty) (*testpb.Empty, error) { |
@@ -255,6 +246,5 @@ func (s) TestConnsCleanup(t *testing.T) { | |||
t.Fatalf("timeout waiting for lis wrapper conns to clear, size: %v", lenConns) | |||
} | |||
|
|||
server.Stop() | |||
wg.Wait() | |||
ss.S.Stop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be done right after stubserver.StartTestService()
as defer statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Partially Addresses: #7291
RELEASE NOTES: None