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

test/gracefulstop: use stubserver instead of testservice implementation #7907

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

pvsravani
Copy link
Contributor

@pvsravani pvsravani commented Dec 6, 2024

Partially Addresses: #7291

RELEASE NOTES: None

Copy link

linux-foundation-easycla bot commented Dec 6, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.15%. Comparing base (66ba4b2) to head (a623c8a).
Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7907      +/-   ##
==========================================
+ Coverage   82.04%   82.15%   +0.10%     
==========================================
  Files         377      379       +2     
  Lines       38180    38261      +81     
==========================================
+ Hits        31326    31432     +106     
+ Misses       5551     5532      -19     
+ Partials     1303     1297       -6     

see 36 files with indirect coverage changes

@@ -122,7 +122,8 @@ func (s) TestGracefulStop(t *testing.T) {
},
}
s := grpc.NewServer()
testgrpc.RegisterTestServiceServer(s, ss)
ss.S = s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you have to assign the listener as well when creating the stub server?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -122,7 +122,8 @@ func (s) TestGracefulStop(t *testing.T) {
},
}
s := grpc.NewServer()
testgrpc.RegisterTestServiceServer(s, ss)
ss.S = s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this can be just ss.S = grpc.NewServer() and all the usages can be updated as ss.S. like ss.S.stop() etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@purnesh42H purnesh42H assigned purnesh42H and unassigned pvsravani Dec 14, 2024
@purnesh42H purnesh42H changed the title switching to stubserver test/gracefulstop: use stubserver instead of testservice implementation Dec 16, 2024
@@ -42,7 +42,9 @@ type delayListener struct {
closeCalled chan struct{}
acceptCalled chan struct{}
allowCloseCh chan struct{}
mu sync.Mutex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like we are introducing mutex only to update closed? Then it should be put right above it indicating that anything below is guarded by mutex.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

dialed bool
closed bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pvsravani where and how are we using closed. Why is it needed when switching to stub server?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The closed field ensures the close() method is idempotent. It prevents multiple calls to close() from closing the listener again, which could cause errors.


// 1. Start Server
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
s.Serve(dlis)
ss.S.Serve(dlis)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should remove this as stubserver.StartTestService already starts the server

@purnesh42H purnesh42H assigned pvsravani and unassigned purnesh42H Dec 16, 2024
@purnesh42H purnesh42H assigned easwars and unassigned pvsravani Dec 18, 2024
@purnesh42H
Copy link
Contributor

@easwars for second review

@purnesh42H purnesh42H added this to the 1.70 Release milestone Dec 18, 2024
@@ -113,31 +113,27 @@ func (s) TestGracefulStop(t *testing.T) {
d := func(ctx context.Context, _ string) (net.Conn, error) { return dlis.Dial(ctx) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you are here, could you please rename this d as dialer and move it a line right before it is used. Currently it is only used on line 153, when it is passed to grpc.WithContextDialer in grpc.DialContext.

}
s := grpc.NewServer()
testgrpc.RegisterTestServiceServer(s, ss)
stubserver.StartTestService(t, ss)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is doing the correct thing. What we want as part of this test is for GracefulStop to be called when Accept is in the middle of accepting a connection.

If you folks have convinced yourself that it actually does what it is supposed to do, then we don't need a sync.WaitGroup. The same can be accomplished with a done channel.

@easwars easwars assigned pvsravani and unassigned easwars Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants