@ -29,6 +29,7 @@
# include "absl/strings/match.h"
# include "absl/strings/match.h"
# include "absl/strings/str_format.h"
# include "absl/strings/str_format.h"
# include "absl/strings/str_join.h"
# include "absl/strings/str_join.h"
# include "absl/types/optional.h"
# include <grpc/grpc.h>
# include <grpc/grpc.h>
# include <grpc/support/alloc.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 ,
absl : : optional < std : : string > ValuesDiff ( absl : : string_view field , double expected ,
double actual ) {
double actual ) {
if ( expected ! = actual ) {
if ( expected ! = actual ) {
@ -160,44 +145,39 @@ absl::optional<std::string> OrcaLoadReportsDiff(const TestOrcaReport& expected,
InteropClient : : ServiceStub : : ServiceStub (
InteropClient : : ServiceStub : : ServiceStub (
ChannelCreationFunc channel_creation_func , bool new_stub_every_call )
ChannelCreationFunc channel_creation_func , bool new_stub_every_call )
: channel_creation_func_ ( std : : move ( channel_creation_func ) ) ,
: channel_creation_func_ ( std : : move ( channel_creation_func ) ) ,
channel_ ( channel_creation_func_ ( ) ) ,
new_stub_every_call_ ( new_stub_every_call ) { }
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_ ) ;
}
}
TestService : : Stub * InteropClient : : ServiceStub : : Get ( ) {
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_ ) ;
stub_ = TestService : : NewStub ( channel_ ) ;
}
}
return stub_ . get ( ) ;
return stub_ . get ( ) ;
}
}
UnimplementedService : : Stub *
UnimplementedService : : Stub *
InteropClient : : ServiceStub : : GetUnimplementedServiceStub ( ) {
InteropClient : : ServiceStub : : GetUnimplementedServiceStub ( ) {
if ( unimplemented_service_stub_ = = nullptr ) {
if ( unimplemented_service_stub_ = = nullptr ) {
if ( channel_ = = nullptr ) {
channel_ = channel_creation_func_ ( ) ;
}
unimplemented_service_stub_ = UnimplementedService : : NewStub ( channel_ ) ;
unimplemented_service_stub_ = UnimplementedService : : NewStub ( channel_ ) ;
}
}
return unimplemented_service_stub_ . get ( ) ;
return unimplemented_service_stub_ . get ( ) ;
}
}
void InteropClient : : ServiceStub : : ResetChannel ( ) {
void InteropClient : : ServiceStub : : ResetChannel ( ) {
channel_ = channel_creation_func_ ( ) ;
channel_ . reset ( ) ;
if ( ! new_stub_every_call_ ) {
stub_ . reset ( ) ;
stub_ = TestService : : NewStub ( channel_ ) ;
}
}
}
InteropClient : : InteropClient ( ChannelCreationFunc channel_creation_func ,
InteropClient : : InteropClient ( ChannelCreationFunc channel_creation_func ,
bool new_stub_every_test_case ,
bool new_stub_every_test_case ,
bool do_not_abort_on_transient_failures )
bool do_not_abort_on_transient_failures )
: serviceStub_ (
: serviceStub_ (
[ & ] ( ) {
[ channel_creation_func = std : : move ( channel_creation_func ) , this ] ( ) {
InitializeCustomLbPolicyIfNeeded ( ) ;
return channel_creation_func (
return channel_creation_func (
load_report_tracker_ . GetChannelArguments ( ) ) ;
load_report_tracker_ . GetChannelArguments ( ) ) ;
} ,
} ,
@ -1014,6 +994,7 @@ bool InteropClient::DoPickFirstUnary() {
bool InteropClient : : DoOrcaPerRpc ( ) {
bool InteropClient : : DoOrcaPerRpc ( ) {
load_report_tracker_ . ResetCollectedLoadReports ( ) ;
load_report_tracker_ . ResetCollectedLoadReports ( ) ;
grpc_core : : CoreConfiguration : : RegisterBuilder ( RegisterBackendMetricsLbPolicy ) ;
gpr_log ( GPR_DEBUG , " testing orca per rpc " ) ;
gpr_log ( GPR_DEBUG , " testing orca per rpc " ) ;
SimpleRequest request ;
SimpleRequest request ;
SimpleResponse response ;
SimpleResponse response ;
@ -1041,6 +1022,8 @@ bool InteropClient::DoOrcaPerRpc() {
bool InteropClient : : DoOrcaOob ( ) {
bool InteropClient : : DoOrcaOob ( ) {
gpr_log ( GPR_DEBUG , " testing orca oob " ) ;
gpr_log ( GPR_DEBUG , " testing orca oob " ) ;
load_report_tracker_ . ResetCollectedLoadReports ( ) ;
grpc_core : : CoreConfiguration : : RegisterBuilder ( RegisterBackendMetricsLbPolicy ) ;
ClientContext context ;
ClientContext context ;
std : : unique_ptr < ClientReaderWriter < StreamingOutputCallRequest ,
std : : unique_ptr < ClientReaderWriter < StreamingOutputCallRequest ,
StreamingOutputCallResponse > >
StreamingOutputCallResponse > >