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

Function DoORCAPerRPCTest

interop/test_utils.go:895–919  ·  view source on GitHub ↗

DoORCAPerRPCTest performs a unary RPC that enables ORCA per-call reporting and verifies the load report sent back to the LB policy's Done callback.

(ctx context.Context, tc testgrpc.TestServiceClient)

Source from the content-addressed store, hash-verified

893// DoORCAPerRPCTest performs a unary RPC that enables ORCA per-call reporting
894// and verifies the load report sent back to the LB policy's Done callback.
895func DoORCAPerRPCTest(ctx context.Context, tc testgrpc.TestServiceClient) {
896 ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
897 defer cancel()
898 orcaRes := &v3orcapb.OrcaLoadReport{}
899 _, err := tc.UnaryCall(contextWithORCAResult(ctx, &orcaRes), &testpb.SimpleRequest{
900 OrcaPerQueryReport: &testpb.TestOrcaReport{
901 CpuUtilization: 0.8210,
902 MemoryUtilization: 0.5847,
903 RequestCost: map[string]float64{"cost": 3456.32},
904 Utilization: map[string]float64{"util": 0.30499},
905 },
906 })
907 if err != nil {
908 logger.Fatalf("/TestService/UnaryCall RPC failed: ", err)
909 }
910 want := &v3orcapb.OrcaLoadReport{
911 CpuUtilization: 0.8210,
912 MemUtilization: 0.5847,
913 RequestCost: map[string]float64{"cost": 3456.32},
914 Utilization: map[string]float64{"util": 0.30499},
915 }
916 if !proto.Equal(orcaRes, want) {
917 logger.Fatalf("/TestService/UnaryCall RPC received ORCA load report %+v; want %+v", orcaRes, want)
918 }
919}
920
921// DoORCAOOBTest performs a streaming RPC that enables ORCA OOB reporting and
922// verifies the load report sent to the LB policy's OOB listener.

Callers 2

mainFunction · 0.92
TestORCAPerRPCReportMethod · 0.85

Calls 4

contextWithORCAResultFunction · 0.85
UnaryCallMethod · 0.65
FatalfMethod · 0.65
EqualMethod · 0.65

Tested by 1

TestORCAPerRPCReportMethod · 0.68