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

Function startORCAServer

interop/orcalb_test.go:57–94  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

55}
56
57func startORCAServer(t *testing.T) *orcaServer {
58 t.Helper()
59
60 smr := orca.NewServerMetricsRecorder()
61 ts := NewTestServer(NewTestServerOptions{MetricsRecorder: smr})
62
63 stub := &stubserver.StubServer{
64 UnaryCallF: func(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
65 return ts.UnaryCall(ctx, in)
66 },
67 FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error {
68 return ts.FullDuplexCall(stream)
69 },
70 }
71
72 sopts := []grpc.ServerOption{orca.CallMetricsServerOption(nil)}
73
74 oso := orca.ServiceOptions{
75 ServerMetricsProvider: smr,
76 MinReportingInterval: time.Second,
77 }
78 internal.ORCAAllowAnyMinReportingInterval.(func(so *orca.ServiceOptions))(&oso)
79 sopts = append(sopts, stubserver.RegisterServiceServerOption(func(s grpc.ServiceRegistrar) {
80 if err := orca.Register(s, oso); err != nil {
81 t.Fatalf("Failed to register ORCA service: %v", err)
82 }
83 }))
84
85 if err := stub.StartServer(sopts...); err != nil {
86 t.Fatalf("Error starting server: %v", err)
87 }
88 t.Cleanup(stub.Stop)
89
90 return &orcaServer{
91 StubServer: stub,
92 metricsRecorder: smr,
93 }
94}
95
96func orcaSvcConfig() string {
97 return `{"loadBalancingConfig": [{"test_backend_metrics_load_balancer": {}}]}`

Callers 6

TestORCAPerRPCReportMethod · 0.85
TestORCAOOBReportMethod · 0.85
TestORCAOOBFallbackMethod · 0.85
TestEndpointUpdateMethod · 0.85

Calls 9

StartServerMethod · 0.95
NewServerMetricsRecorderFunction · 0.92
CallMetricsServerOptionFunction · 0.92
RegisterFunction · 0.92
NewTestServerFunction · 0.85
UnaryCallMethod · 0.65
FullDuplexCallMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected