[interop] fix C++ server to add mutex for orca_oob test (#33278)

Following improvements were made to `orca_oob` interop test to increase
compatibility and stability:

1. Timeout was increased to 10s (see #33098)
2. Server will block clients trying to run this test concurrently.
3. Data is cleared in the beginning of the call.
pull/33310/head
Eugene Ostroukhov 2 years ago committed by GitHub
parent 2892b24eab
commit 0980076bb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      test/cpp/interop/interop_client.cc
  2. 12
      test/cpp/interop/interop_server.cc

@ -1021,6 +1021,7 @@ bool InteropClient::DoOrcaPerRpc() {
}
bool InteropClient::DoOrcaOob() {
static constexpr auto kTimeout = absl::Seconds(10);
gpr_log(GPR_DEBUG, "testing orca oob");
load_report_tracker_.ResetCollectedLoadReports();
grpc_core::CoreConfiguration::RegisterBuilder(RegisterBackendMetricsLbPolicy);
@ -1059,7 +1060,7 @@ bool InteropClient::DoOrcaOob() {
}
return true;
},
absl::Seconds(5), 10)
kTimeout, 10)
.has_value());
}
{
@ -1084,7 +1085,7 @@ bool InteropClient::DoOrcaOob() {
[orca_report](const auto& report) {
return !OrcaLoadReportsDiff(*orca_report, report).has_value();
},
absl::Seconds(5), 10)
kTimeout, 10)
.has_value());
}
gpr_log(GPR_DEBUG, "orca oob successfully finished");

@ -296,6 +296,7 @@ class TestServiceImpl : public TestService::Service {
StreamingOutputCallRequest request;
StreamingOutputCallResponse response;
bool write_success = true;
std::unique_ptr<grpc_core::MutexLock> orca_oob_lock;
while (write_success && stream->Read(&request)) {
if (request.has_response_status()) {
return Status(
@ -317,6 +318,15 @@ class TestServiceImpl : public TestService::Service {
write_success = stream->Write(response);
}
if (request.has_orca_oob_report()) {
if (orca_oob_lock == nullptr) {
orca_oob_lock =
std::make_unique<grpc_core::MutexLock>(&orca_oob_server_mu_);
server_metric_recorder_->ClearCpuUtilization();
server_metric_recorder_->ClearEps();
server_metric_recorder_->ClearMemoryUtilization();
server_metric_recorder_->SetAllNamedUtilization({});
server_metric_recorder_->ClearQps();
}
RecordServerMetrics(request.orca_oob_report());
}
}
@ -381,6 +391,8 @@ class TestServiceImpl : public TestService::Service {
std::set<std::string> retained_utilization_names_
ABSL_GUARDED_BY(retained_utilization_names_mu_);
grpc_core::Mutex retained_utilization_names_mu_;
// Only a single client requesting Orca OOB reports is allowed at a time
grpc_core::Mutex orca_oob_server_mu_;
};
void grpc::testing::interop::RunServer(

Loading…
Cancel
Save