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

Merged
merged 18 commits into from
Feb 7, 2025

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.47%. Comparing base (79b6830) to head (d38ed6e).
Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7907      +/-   ##
==========================================
+ Coverage   82.42%   82.47%   +0.04%     
==========================================
  Files         387      387              
  Lines       39042    39065      +23     
==========================================
+ Hits        32179    32217      +38     
+ Misses       5546     5530      -16     
- Partials     1317     1318       +1     

see 37 files with indirect coverage changes

test/gracefulstop_test.go Outdated Show resolved Hide resolved
test/gracefulstop_test.go Outdated Show resolved Hide resolved
@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
test/gracefulstop_test.go Outdated Show resolved Hide resolved
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.

test/gracefulstop_test.go Outdated Show resolved Hide resolved
@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.

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

test/gracefulstop_test.go Show resolved Hide resolved
@easwars easwars assigned pvsravani and unassigned easwars Dec 20, 2024
@easwars easwars self-assigned this Jan 6, 2025
test/gracefulstop_test.go Outdated Show resolved Hide resolved
test/gracefulstop_test.go Outdated Show resolved Hide resolved
test/gracefulstop_test.go Show resolved Hide resolved
@purnesh42H purnesh42H requested a review from easwars January 7, 2025 13:53
@purnesh42H
Copy link
Contributor

@easwars gentle ping on this

Copy link
Contributor

@easwars easwars left a comment

Choose a reason for hiding this comment

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

Apologies for the delay.

test/gracefulstop_test.go Outdated Show resolved Hide resolved
test/gracefulstop_test.go Outdated Show resolved Hide resolved
test/gracefulstop_test.go Outdated Show resolved Hide resolved
test/gracefulstop_test.go Outdated Show resolved Hide resolved
@easwars easwars assigned pvsravani and unassigned easwars Jan 28, 2025

// 1. Start Server
Copy link
Contributor

Choose a reason for hiding this comment

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

don't revert the step number

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

wg.Done()
}()

// 2. GracefulStop() Server after listener's Accept is called, but don't
Copy link
Contributor

Choose a reason for hiding this comment

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

don't revert the step number

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

}()

// 2. GracefulStop() Server after listener's Accept is called, but don't
// GracefulStop() Server after listener's Accept is called, but don't
Copy link
Contributor

Choose a reason for hiding this comment

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

don't revert the step number

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

}()

// 3. Create a new connection to the server after listener.Close() is called.
Copy link
Contributor

Choose a reason for hiding this comment

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

don't revert the step number

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

if err != nil {
t.Fatalf("grpc.DialContext(_, %q, _) = %v", lis.Addr().String(), err)
}
client := testgrpc.NewTestServiceClient(cc)
defer cc.Close()

// 4. Send an RPC on the new connection.
// Send an RPC on the new connection.
Copy link
Contributor

Choose a reason for hiding this comment

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

don't revert the step number

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

Copy link
Contributor

@easwars easwars left a comment

Choose a reason for hiding this comment

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

LGTM, modulo minor nits.


// 2. GracefulStop() Server after listener's Accept is called, but don't
// allow Accept() to exit when Close() is called on it.
//2. Call GracefulStop from a goroutine. It will trigger Close on the listener
Copy link
Contributor

Choose a reason for hiding this comment

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

Please leave a space after the // and before the first character of the comment.

Also, please ensure that comment lines are wrapped at 80-cols wide. See: https://google.github.io/styleguide/go/decisions#comment-line-length

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


<-dlis.closeCalled // Block until GracefulStop calls dlis.Close()

// Now dial. The listener's Accept method will return a valid connection,
// even though GracefulStop has closed the listener.
//Dial the server. This will cause a connection to be accepted. This will also unblock the Close method.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Ensure space after the // and ensure wrapping at 80-cols.

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

@easwars
Copy link
Contributor

easwars commented Feb 3, 2025

@purnesh42H : Please feel free to merge once my last two comments have been addressed.

Copy link
Contributor

@purnesh42H purnesh42H left a comment

Choose a reason for hiding this comment

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

@pvsravani please wrap all comments under 80 cols

test/gracefulstop_test.go Outdated Show resolved Hide resolved
test/gracefulstop_test.go Outdated Show resolved Hide resolved
}
s := grpc.NewServer()
testgrpc.RegisterTestServiceServer(s, ss)
// 1.Start Server and start serving by calling Serve().
Copy link
Contributor

Choose a reason for hiding this comment

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

@pvsravani. You missed space here. Please recheck all comments

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 merged commit e0d191d into grpc:master Feb 7, 2025
15 checks passed
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.

4 participants