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)
| 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. |
| 923 | func 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 | |
| 977 | func checkORCAMetrics(ctx context.Context, tc testgrpc.TestServiceClient, want *v3orcapb.OrcaLoadReport) { |
| 978 | for ctx.Err() == nil { |