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

Method TestStreamingRPC_TraceSequenceNumbers

stats/opentelemetry/e2e_test.go:1864–1937  ·  view source on GitHub ↗

TestStreamingRPC_TraceSequenceNumbers verifies that sequence numbers are incremented correctly for multiple messages sent and received during a streaming RPC.

(t *testing.T)

Source from the content-addressed store, hash-verified

1862// are incremented correctly for multiple messages sent and received
1863// during a streaming RPC.
1864func (s) TestStreamingRPC_TraceSequenceNumbers(t *testing.T) {
1865 mo, _ := defaultMetricsOptions(t, nil)
1866 to, exporter := defaultTraceOptions(t)
1867 ss := setupStubServer(t, mo, to)
1868 defer ss.Stop()
1869
1870 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
1871 defer cancel()
1872
1873 stream, err := ss.Client.FullDuplexCall(ctx)
1874 if err != nil {
1875 t.Fatalf("ss.Client.FullDuplexCall failed: %f", err)
1876 }
1877
1878 const numMessages = 3
1879 var wantOutboundEvents, wantInboundEvents []trace.Event
1880 for i := range numMessages {
1881 if err := stream.Send(&testpb.StreamingOutputCallRequest{}); err != nil {
1882 t.Fatalf("stream.Send() failed at message %d: %v", i, err)
1883 }
1884 wantOutboundEvents = append(wantOutboundEvents, trace.Event{
1885 Name: "Outbound message",
1886 Attributes: []attribute.KeyValue{
1887 attribute.Int("sequence-number", i),
1888 attribute.Int("message-size", 0),
1889 },
1890 })
1891 wantInboundEvents = append(wantInboundEvents, trace.Event{
1892 Name: "Inbound message",
1893 Attributes: []attribute.KeyValue{
1894 attribute.Int("sequence-number", i),
1895 attribute.Int("message-size", 0),
1896 },
1897 })
1898 }
1899 stream.CloseSend()
1900 _, err = stream.Recv()
1901 if err != io.EOF {
1902 t.Fatalf("stream.Recv() got unexpected err=%v; want io.EOF", err)
1903 }
1904
1905 wantSpanInfos := []traceSpanInfo{
1906 {
1907 name: "Sent.grpc.testing.TestService.FullDuplexCall",
1908 spanKind: oteltrace.SpanKindClient.String(),
1909 status: otelcodes.Ok,
1910 events: nil,
1911 attributes: nil,
1912 },
1913 {
1914 name: "Recv.grpc.testing.TestService.FullDuplexCall",
1915 spanKind: oteltrace.SpanKindServer.String(),
1916 status: otelcodes.Ok,
1917 events: wantInboundEvents,
1918 attributes: nil,
1919 },
1920 {
1921 name: "Attempt.grpc.testing.TestService.FullDuplexCall",

Callers

nothing calls this directly

Calls 13

defaultMetricsOptionsFunction · 0.85
defaultTraceOptionsFunction · 0.85
setupStubServerFunction · 0.85
waitForTraceSpansFunction · 0.85
validateTracesFunction · 0.85
StopMethod · 0.65
FullDuplexCallMethod · 0.65
FatalfMethod · 0.65
SendMethod · 0.65
CloseSendMethod · 0.65
RecvMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected