@ -63,8 +63,6 @@
namespace {
namespace {
const int kFakeHandshakeServerMaxConcurrentStreams = 40 ;
void drain_cq ( grpc_completion_queue * cq ) {
void drain_cq ( grpc_completion_queue * cq ) {
grpc_event ev ;
grpc_event ev ;
do {
do {
@ -104,17 +102,10 @@ grpc_channel* create_secure_channel_for_test(
class FakeHandshakeServer {
class FakeHandshakeServer {
public :
public :
explicit FakeHandshakeServer ( bool check_num_concurrent_rpcs ) {
FakeHandshakeServer ( ) {
int port = grpc_pick_unused_port_or_die ( ) ;
int port = grpc_pick_unused_port_or_die ( ) ;
address_ = grpc_core : : JoinHostPort ( " localhost " , port ) ;
address_ = grpc_core : : JoinHostPort ( " localhost " , port ) ;
if ( check_num_concurrent_rpcs ) {
service_ = grpc : : gcp : : CreateFakeHandshakerService ( " peer_identity " ) ;
service_ = grpc : : gcp : : CreateFakeHandshakerService (
/*expected_max_concurrent_rpcs=*/
kFakeHandshakeServerMaxConcurrentStreams , " peer_identity " ) ;
} else {
service_ = grpc : : gcp : : CreateFakeHandshakerService (
/*expected_max_concurrent_rpcs=*/ 0 , " peer_identity " ) ;
}
grpc : : ServerBuilder builder ;
grpc : : ServerBuilder builder ;
builder . AddListeningPort ( address_ , grpc : : InsecureServerCredentials ( ) ) ;
builder . AddListeningPort ( address_ , grpc : : InsecureServerCredentials ( ) ) ;
builder . RegisterService ( service_ . get ( ) ) ;
builder . RegisterService ( service_ . get ( ) ) ;
@ -139,8 +130,7 @@ class FakeHandshakeServer {
class TestServer {
class TestServer {
public :
public :
explicit TestServer ( )
TestServer ( ) {
: fake_handshake_server_ ( true /* check num concurrent rpcs */ ) {
grpc_alts_credentials_options * alts_options =
grpc_alts_credentials_options * alts_options =
grpc_alts_credentials_server_options_create ( ) ;
grpc_alts_credentials_server_options_create ( ) ;
grpc_server_credentials * server_creds =
grpc_server_credentials * server_creds =
@ -285,8 +275,7 @@ class ConnectLoopRunner {
// Perform a few ALTS handshakes sequentially (using the fake, in-process ALTS
// Perform a few ALTS handshakes sequentially (using the fake, in-process ALTS
// handshake server).
// handshake server).
TEST ( AltsConcurrentConnectivityTest , TestBasicClientServerHandshakes ) {
TEST ( AltsConcurrentConnectivityTest , TestBasicClientServerHandshakes ) {
FakeHandshakeServer fake_handshake_server (
FakeHandshakeServer fake_handshake_server ;
true /* check num concurrent rpcs */ ) ;
TestServer test_server ;
TestServer test_server ;
{
{
ConnectLoopRunner runner (
ConnectLoopRunner runner (
@ -300,8 +289,7 @@ TEST(AltsConcurrentConnectivityTest, TestBasicClientServerHandshakes) {
// Run a bunch of concurrent ALTS handshakes on concurrent channels
// Run a bunch of concurrent ALTS handshakes on concurrent channels
// (using the fake, in-process handshake server).
// (using the fake, in-process handshake server).
TEST ( AltsConcurrentConnectivityTest , TestConcurrentClientServerHandshakes ) {
TEST ( AltsConcurrentConnectivityTest , TestConcurrentClientServerHandshakes ) {
FakeHandshakeServer fake_handshake_server (
FakeHandshakeServer fake_handshake_server ;
true /* check num concurrent rpcs */ ) ;
// Test
// Test
{
{
TestServer test_server ;
TestServer test_server ;
@ -336,8 +324,7 @@ TEST(AltsConcurrentConnectivityTest,
// cancellation, and the corresponding fake handshake server's sync
// cancellation, and the corresponding fake handshake server's sync
// method handler returning, enforcing a limit on the number of active
// method handler returning, enforcing a limit on the number of active
// RPCs at the fake handshake server would be inherently racey.
// RPCs at the fake handshake server would be inherently racey.
FakeHandshakeServer fake_handshake_server (
FakeHandshakeServer fake_handshake_server ;
false /* check num concurrent rpcs */ ) ;
// The fake_backend_server emulates a secure (ALTS based) gRPC backend. So
// The fake_backend_server emulates a secure (ALTS based) gRPC backend. So
// it waits for the client to send the first bytes.
// it waits for the client to send the first bytes.
grpc_core : : testing : : FakeUdpAndTcpServer fake_backend_server (
grpc_core : : testing : : FakeUdpAndTcpServer fake_backend_server (