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

Function channelzTraceEventFound

internal/idle/idle_e2e_test.go:69–87  ·  view source on GitHub ↗

channelzTraceEventFound looks up the top-channels in channelz (expects a single one), and checks if there is a trace event on the channel matching the provided description string.

(ctx context.Context, wantDesc string)

Source from the content-addressed store, hash-verified

67// single one), and checks if there is a trace event on the channel matching the
68// provided description string.
69func channelzTraceEventFound(ctx context.Context, wantDesc string) error {
70 for ctx.Err() == nil {
71 tcs, _ := channelz.GetTopChannels(0, 0)
72 if l := len(tcs); l != 1 {
73 return fmt.Errorf("when looking for channelz trace event with description %q, found %d top-level channels, want 1", wantDesc, l)
74 }
75 trace := tcs[0].Trace()
76 if trace == nil {
77 return fmt.Errorf("when looking for channelz trace event with description %q, no trace events found for top-level channel", wantDesc)
78 }
79
80 for _, e := range trace.Events {
81 if strings.Contains(e.Desc, wantDesc) {
82 return nil
83 }
84 }
85 }
86 return fmt.Errorf("when looking for channelz trace event with description %q, %w", wantDesc, ctx.Err())
87}
88
89// Registers a wrapped round_robin LB policy for the duration of this test that
90// retains all the functionality of the round_robin LB policy and makes the

Calls 4

GetTopChannelsFunction · 0.92
ErrMethod · 0.80
ErrorfMethod · 0.65
TraceMethod · 0.45

Tested by

no test coverage detected