TestConcurrentHandshakes performs a several, concurrent ALTS handshakes between a test client and server, where both client and server offload to a local, fake handshaker service.
(t *testing.T)
| 359 | // between a test client and server, where both client and server offload to a |
| 360 | // local, fake handshaker service. |
| 361 | func (s) TestConcurrentHandshakes(t *testing.T) { |
| 362 | // Set the max number of concurrent handshakes to 3, so that we can |
| 363 | // test the handshaker behavior when handshakes are queued by |
| 364 | // performing more than 3 concurrent handshakes (specifically, 10). |
| 365 | handshaker.ResetConcurrentHandshakeSemaphoreForTesting(3) |
| 366 | |
| 367 | // Start the fake handshaker service and the server. |
| 368 | var wait sync.WaitGroup |
| 369 | defer wait.Wait() |
| 370 | stopHandshaker, handshakerAddress := startFakeHandshakerService(t, &wait) |
| 371 | defer stopHandshaker() |
| 372 | stopServer, serverAddress := startServer(t, handshakerAddress) |
| 373 | defer stopServer() |
| 374 | |
| 375 | // Ping the server, authenticating with ALTS. |
| 376 | var waitForConnections sync.WaitGroup |
| 377 | for i := 0; i < 10; i++ { |
| 378 | waitForConnections.Add(1) |
| 379 | go func() { |
| 380 | establishAltsConnection(t, handshakerAddress, serverAddress) |
| 381 | waitForConnections.Done() |
| 382 | }() |
| 383 | } |
| 384 | waitForConnections.Wait() |
| 385 | |
| 386 | // Close open connections to the fake handshaker service. |
| 387 | if err := service.CloseForTesting(); err != nil { |
| 388 | t.Errorf("service.CloseForTesting() failed: %v", err) |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | func version(major, minor uint32) *altspb.RpcProtocolVersions_Version { |
| 393 | return &altspb.RpcProtocolVersions_Version{ |
nothing calls this directly
no test coverage detected