-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
alts: Perform full handshake in ALTS tests. #6177
Conversation
|
||
// Close closes all open connections to the handshaker service. | ||
// | ||
// For testing purposes only. |
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 seems like a generic close function. Why is it expected to be used in tests only?
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.
In practice, the connection to the handshaker service is kept open until the application is killed, so this Close function is never needed/called.
However, in the e2e test, we need to do call this Close function so that we don't get a goroutine leak.
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 can't you explicitly close the connection from the test?
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.
Disclaimer: I'm not a Go expert so apologies if I'm missing something obvious. :)
The hsConnMap
, which holds the connection, is not exported. So we have 2 options:
- Add a test-only
Close
API to close any connections in the map, which we call inTestFullHandshake
. - Call
Dial
to get the same connection and then manually close it. This feels hacky, because we never want users to callDial
(it should only be called by the internals of the ALTS libraries) and so I didn't want to set this precedent).
WDYT?
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.
Thanks for the exaplaination. How about calling the method CloseForTesting
or something which makes is very obvious that the method is only for testing purposes. We do that regularly in our codebase. Thanks.
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.
Sure thing, done.
|
||
// Close closes all open connections to the handshaker service. | ||
// | ||
// For testing purposes only. |
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 can't you explicitly close the connection from the test?
credentials/alts/alts_test.go
Outdated
t.Fatalf("LocalTCPListener() failed: %v", err) | ||
} | ||
s := grpc.NewServer() | ||
altspb.RegisterHandshakerServiceServer(s, &testutil.FakeHandshaker{}) |
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 altsgrpc
with a separate import.
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, sorry I missed this one. :)
|
||
// Close closes all open connections to the handshaker service. | ||
// | ||
// For testing purposes only. |
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.
Thanks for the exaplaination. How about calling the method CloseForTesting
or something which makes is very obvious that the method is only for testing purposes. We do that regularly in our codebase. Thanks.
One of the tests is failing because of a flake which we recently fixed. I've kicked off another run of the tests. If it fails again, maybe rebase your branch to master. |
The ALTS tests in this repo do not perform full ALTS handshakes against a fake handshaker service. This leads to changes in this repo breaking e2e/interop tests once the change is imported internally. This PR will (hopefully) reduce the frequency with which that happens.
RELEASE NOTES: none