MCPcopy
hub / github.com/grpc/grpc-go / TestConcurrentHandshakes

Method TestConcurrentHandshakes

credentials/alts/alts_test.go:361–390  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

359// between a test client and server, where both client and server offload to a
360// local, fake handshaker service.
361func (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
392func version(major, minor uint32) *altspb.RpcProtocolVersions_Version {
393 return &altspb.RpcProtocolVersions_Version{

Callers

nothing calls this directly

Calls 9

CloseForTestingFunction · 0.92
establishAltsConnectionFunction · 0.85
WaitMethod · 0.80
startServerFunction · 0.70
AddMethod · 0.65
ErrorfMethod · 0.65
DoneMethod · 0.45

Tested by

no test coverage detected