-
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 #7951
base: master
Are you sure you want to change the base?
Conversation
test/local_creds_test.go
Outdated
|
||
testgrpc.RegisterTestServiceServer(s, ss) | ||
defer ss.S.Stop() | ||
stubserver.StartTestService(nil, ss) |
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.
why are you passing nil? You can pass t
from caller and provide the same here?
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/local_creds_test.go
Outdated
} | ||
|
||
go s.Serve(lis) | ||
stubserver.StartTestService(nil, ss) |
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.
why are you passing nil? You can pass t
from caller and provide the same here?
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
1094840
to
a57bfbd
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #7951 +/- ##
==========================================
+ Coverage 82.05% 82.21% +0.15%
==========================================
Files 381 381
Lines 38539 38539
==========================================
+ Hits 31622 31683 +61
+ Misses 5602 5555 -47
+ Partials 1315 1301 -14 |
test/goaway_test.go
Outdated
defer s1.Stop() | ||
ts := &funcServer{ | ||
unaryCall: func(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { | ||
//s1 := grpc.NewServer() |
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.
why are these commented out? They should be removed?
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/goaway_test.go
Outdated
go s1.Serve(lis1) | ||
stubserver.StartTestService(t, ss1) | ||
defer ss1.S.Stop() | ||
//testgrpc.RegisterTestServiceServer(s1, ts) |
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.
same. Please remove instead of commenting out
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/goaway_test.go
Outdated
if err != nil { | ||
t.Fatalf("Failed to create listener: %v", err) | ||
} | ||
|
||
ss := &stubserver.StubServer{ |
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.
nit: this can be ss1 and then others can ss2, ss3 and so on.
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/goaway_test.go
Outdated
|
||
conn2Established := grpcsync.NewEvent() | ||
lis2, err := listenWithNotifyingListener("tcp", "localhost:0", conn2Established) | ||
if err != nil { | ||
t.Fatalf("Error while listening. Err: %v", err) | ||
} | ||
s2 := grpc.NewServer() | ||
/*s2 := grpc.NewServer() |
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.
remove
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/goaway_test.go
Outdated
t.Errorf("unexpected error from send: %v", err) | ||
return err | ||
} | ||
// Wait forever. |
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.
Its not wait forever. Its wait until a message is received from client
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
lis, err := net.Listen("tcp", "localhost:0") | ||
if err != nil { | ||
t.Fatalf("net.Listen(tcp, localhost:0) failed: %v", err) | ||
} | ||
ss := &stubserver.StubServer{ | ||
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.
listener also needs to be assigned here?
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/local_creds_test.go
Outdated
@@ -162,18 +160,15 @@ func spoofDialer(addr net.Addr) func(target string, t time.Duration) (net.Conn, | |||
} | |||
} | |||
|
|||
func testLocalCredsE2EFail(dopts []grpc.DialOption) error { | |||
func testLocalCredsE2EFail(t *testing.T, dopts []grpc.DialOption) error { | |||
ss := &stubserver.StubServer{ | |||
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.
same. Listener needs to be assigned here?
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/goaway_test.go
Outdated
t.Log("Gracefully stopping server 1.") | ||
go s1.GracefulStop() | ||
go ss2.S.GracefulStop() |
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.
the comment says we are stopping server 1 and the change is stopping server 2?
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/goaway_test.go
Outdated
@@ -637,7 +653,7 @@ func (s) TestGoAwayThenClose(t *testing.T) { | |||
lis2.Close() | |||
|
|||
t.Log("Hard closing connection 1.") | |||
s1.Stop() | |||
ss2.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.
same here
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/local_creds_test.go
Outdated
@@ -40,8 +40,14 @@ import ( | |||
testpb "google.golang.org/grpc/interop/grpc_testing" | |||
) | |||
|
|||
func testLocalCredsE2ESucceed(network, address string) error { | |||
func testLocalCredsE2ESucceed(t *testing.T, network, address string) 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.
nix new line
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/goaway_test.go
Outdated
go s.Serve(lis) | ||
|
||
ss1 := &stubserver.StubServer{ | ||
Listener: lis, |
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.
let's do the same with listeners to be consistent. lis1, lis2, lis3.
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/goaway_test.go
Outdated
s2 := grpc.NewServer() | ||
defer s2.Stop() | ||
testgrpc.RegisterTestServiceServer(s2, ts) | ||
ss3 := &stubserver.StubServer{ |
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.
why did you create ss3? I don't think its used anywhere. The existing test only has 2 servers and 2 listeners
Partially Addresses: #7291
RELEASE NOTES: None