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

Function DoORCAOOBTest

interop/test_utils.go:923–975  ·  view source on GitHub ↗

DoORCAOOBTest performs a streaming RPC that enables ORCA OOB reporting and verifies the load report sent to the LB policy's OOB listener.

(ctx context.Context, tc testgrpc.TestServiceClient)

Source from the content-addressed store, hash-verified

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.
923func DoORCAOOBTest(ctx context.Context, tc testgrpc.TestServiceClient) {
924 ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
925 defer cancel()
926 stream, err := tc.FullDuplexCall(ctx)
927 if err != nil {
928 logger.Fatalf("/TestService/FullDuplexCall received error starting stream: %v", err)
929 }
930 err = stream.Send(&testpb.StreamingOutputCallRequest{
931 OrcaOobReport: &testpb.TestOrcaReport{
932 CpuUtilization: 0.8210,
933 MemoryUtilization: 0.5847,
934 Utilization: map[string]float64{"util": 0.30499},
935 },
936 ResponseParameters: []*testpb.ResponseParameters{{Size: 1}},
937 })
938 if err != nil {
939 logger.Fatalf("/TestService/FullDuplexCall received error sending: %v", err)
940 }
941 _, err = stream.Recv()
942 if err != nil {
943 logger.Fatalf("/TestService/FullDuplexCall received error receiving: %v", err)
944 }
945
946 want := &v3orcapb.OrcaLoadReport{
947 CpuUtilization: 0.8210,
948 MemUtilization: 0.5847,
949 Utilization: map[string]float64{"util": 0.30499},
950 }
951 checkORCAMetrics(ctx, tc, want)
952
953 err = stream.Send(&testpb.StreamingOutputCallRequest{
954 OrcaOobReport: &testpb.TestOrcaReport{
955 CpuUtilization: 0.29309,
956 MemoryUtilization: 0.2,
957 Utilization: map[string]float64{"util": 0.2039},
958 },
959 ResponseParameters: []*testpb.ResponseParameters{{Size: 1}},
960 })
961 if err != nil {
962 logger.Fatalf("/TestService/FullDuplexCall received error sending: %v", err)
963 }
964 _, err = stream.Recv()
965 if err != nil {
966 logger.Fatalf("/TestService/FullDuplexCall received error receiving: %v", err)
967 }
968
969 want = &v3orcapb.OrcaLoadReport{
970 CpuUtilization: 0.29309,
971 MemUtilization: 0.2,
972 Utilization: map[string]float64{"util": 0.2039},
973 }
974 checkORCAMetrics(ctx, tc, want)
975}
976
977func checkORCAMetrics(ctx context.Context, tc testgrpc.TestServiceClient, want *v3orcapb.OrcaLoadReport) {
978 for ctx.Err() == nil {

Callers 2

mainFunction · 0.92
TestORCAOOBReportMethod · 0.85

Calls 5

checkORCAMetricsFunction · 0.85
FullDuplexCallMethod · 0.65
FatalfMethod · 0.65
SendMethod · 0.65
RecvMethod · 0.65

Tested by 1

TestORCAOOBReportMethod · 0.68