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

Method TestBothClientAndServerRPCEvents

gcp/observability/logging_test.go:553–638  ·  view source on GitHub ↗

TestBothClientAndServerRPCEvents tests the scenario where you have both Client and Server RPC Events configured to log. Both sides should log and share the exporter, so the exporter should receive the collective amount of calls for both a client stream (corresponding to a Client RPC Event) and a ser

(t *testing.T)

Source from the content-addressed store, hash-verified

551// server stream (corresponding to a Server RPC Event). The specificity of the
552// entries are tested in previous tests.
553func (s) TestBothClientAndServerRPCEvents(t *testing.T) {
554 fle := &fakeLoggingExporter{
555 t: t,
556 }
557 defer func(ne func(ctx context.Context, config *config) (loggingExporter, error)) {
558 newLoggingExporter = ne
559 }(newLoggingExporter)
560
561 newLoggingExporter = func(context.Context, *config) (loggingExporter, error) {
562 return fle, nil
563 }
564
565 serverRPCEventLogAllConfig := &config{
566 ProjectID: "fake",
567 CloudLogging: &cloudLogging{
568 ClientRPCEvents: []clientRPCEvents{
569 {
570 Methods: []string{"*"},
571 MaxMetadataBytes: 30,
572 MaxMessageBytes: 30,
573 },
574 },
575 ServerRPCEvents: []serverRPCEvents{
576 {
577 Methods: []string{"*"},
578 MaxMetadataBytes: 30,
579 MaxMessageBytes: 30,
580 },
581 },
582 },
583 }
584
585 cleanup, err := setupObservabilitySystemWithConfig(serverRPCEventLogAllConfig)
586 if err != nil {
587 t.Fatalf("error setting up observability %v", err)
588 }
589 defer cleanup()
590
591 ss := &stubserver.StubServer{
592 UnaryCallF: func(_ context.Context, _ *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
593 return &testpb.SimpleResponse{}, nil
594 },
595 FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error {
596 _, err := stream.Recv()
597 if err != io.EOF {
598 return err
599 }
600 return nil
601 },
602 }
603 if err := ss.Start(nil); err != nil {
604 t.Fatalf("Error starting endpoint server: %v", err)
605 }
606 defer ss.Stop()
607
608 // Make a Unary RPC. Both client side and server side streams should log
609 // entries, which share the same exporter. The exporter should thus receive
610 // entries from both the client and server streams (the specificity of

Callers

nothing calls this directly

Calls 10

StartMethod · 0.95
StopMethod · 0.95
FatalfMethod · 0.65
RecvMethod · 0.65
UnaryCallMethod · 0.65
FullDuplexCallMethod · 0.65
CloseSendMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected