@ -29,6 +29,7 @@
# include "absl/strings/match.h"
# include "absl/strings/str_format.h"
# include "absl/strings/str_join.h"
# include "absl/types/optional.h"
# include <grpc/grpc.h>
# include <grpc/support/alloc.h>
@ -84,22 +85,6 @@ void UnaryCompressionChecks(const InteropClientContextInspector& inspector,
}
}
void InitializeCustomLbPolicyIfNeeded ( ) {
// Load balancing policy builder is global. For now, all instances of the
// LB policy will store data in the same collection. All interop_clients in
// the same process will also share the collection
// Realistically, we do not yet need synchronization as only a single test is
// running at a time.
static bool initialized = false ;
if ( ! initialized ) {
grpc_core : : CoreConfiguration : : RegisterBuilder (
[ ] ( grpc_core : : CoreConfiguration : : Builder * builder ) {
RegisterBackendMetricsLbPolicy ( builder ) ;
} ) ;
initialized = true ;
}
}
absl : : optional < std : : string > ValuesDiff ( absl : : string_view field , double expected ,
double actual ) {
if ( expected ! = actual ) {
@ -160,44 +145,39 @@ absl::optional<std::string> OrcaLoadReportsDiff(const TestOrcaReport& expected,
InteropClient : : ServiceStub : : ServiceStub (
ChannelCreationFunc channel_creation_func , bool new_stub_every_call )
: channel_creation_func_ ( std : : move ( channel_creation_func ) ) ,
channel_ ( channel_creation_func_ ( ) ) ,
new_stub_every_call_ ( new_stub_every_call ) {
// If new_stub_every_call is false, then this is our chance to initialize
// stub_. (see Get())
if ( ! new_stub_every_call ) {
stub_ = TestService : : NewStub ( channel_ ) ;
}
}
new_stub_every_call_ ( new_stub_every_call ) { }
TestService : : Stub * InteropClient : : ServiceStub : : Get ( ) {
if ( new_stub_every_call_ ) {
if ( new_stub_every_call_ | | stub_ = = nullptr ) {
if ( channel_ = = nullptr ) {
channel_ = channel_creation_func_ ( ) ;
}
stub_ = TestService : : NewStub ( channel_ ) ;
}
return stub_ . get ( ) ;
}
UnimplementedService : : Stub *
InteropClient : : ServiceStub : : GetUnimplementedServiceStub ( ) {
if ( unimplemented_service_stub_ = = nullptr ) {
if ( channel_ = = nullptr ) {
channel_ = channel_creation_func_ ( ) ;
}
unimplemented_service_stub_ = UnimplementedService : : NewStub ( channel_ ) ;
}
return unimplemented_service_stub_ . get ( ) ;
}
void InteropClient : : ServiceStub : : ResetChannel ( ) {
channel_ = channel_creation_func_ ( ) ;
if ( ! new_stub_every_call_ ) {
stub_ = TestService : : NewStub ( channel_ ) ;
}
channel_ . reset ( ) ;
stub_ . reset ( ) ;
}
InteropClient : : InteropClient ( ChannelCreationFunc channel_creation_func ,
bool new_stub_every_test_case ,
bool do_not_abort_on_transient_failures )
: serviceStub_ (
[ & ] ( ) {
InitializeCustomLbPolicyIfNeeded ( ) ;
[ channel_creation_func = std : : move ( channel_creation_func ) , this ] ( ) {
return channel_creation_func (
load_report_tracker_ . GetChannelArguments ( ) ) ;
} ,
@ -1014,6 +994,7 @@ bool InteropClient::DoPickFirstUnary() {
bool InteropClient : : DoOrcaPerRpc ( ) {
load_report_tracker_ . ResetCollectedLoadReports ( ) ;
grpc_core : : CoreConfiguration : : RegisterBuilder ( RegisterBackendMetricsLbPolicy ) ;
gpr_log ( GPR_DEBUG , " testing orca per rpc " ) ;
SimpleRequest request ;
SimpleResponse response ;
@ -1041,6 +1022,8 @@ bool InteropClient::DoOrcaPerRpc() {
bool InteropClient : : DoOrcaOob ( ) {
gpr_log ( GPR_DEBUG , " testing orca oob " ) ;
load_report_tracker_ . ResetCollectedLoadReports ( ) ;
grpc_core : : CoreConfiguration : : RegisterBuilder ( RegisterBackendMetricsLbPolicy ) ;
ClientContext context ;
std : : unique_ptr < ClientReaderWriter < StreamingOutputCallRequest ,
StreamingOutputCallResponse > >