@ -12216,6 +12216,74 @@ TEST_P(FaultInjectionTest, XdsFaultInjectionMaxFault) {
EXPECT_EQ ( kMaxFault , num_delayed ) ;
}
TEST_P ( FaultInjectionTest , XdsFaultInjectionBidiStreamDelayOk ) {
// kRpcTimeoutMilliseconds is 10s should never be reached.
const uint32_t kRpcTimeoutMilliseconds = grpc_test_slowdown_factor ( ) * 10000 ;
const uint32_t kFixedDelaySeconds = 1 ;
const uint32_t kDelayPercentagePerHundred = 100 ;
SetNextResolution ( { } ) ;
SetNextResolutionForLbChannelAllBalancers ( ) ;
// Create an EDS resource
AdsServiceImpl : : EdsResourceArgs args ( {
{ " locality0 " , CreateEndpointsForBackends ( ) } ,
} ) ;
balancers_ [ 0 ] - > ads_service ( ) - > SetEdsResource (
BuildEdsResource ( args , DefaultEdsServiceName ( ) ) ) ;
// Construct the fault injection filter config
HTTPFault http_fault ;
auto * delay_percentage = http_fault . mutable_delay ( ) - > mutable_percentage ( ) ;
delay_percentage - > set_numerator ( kDelayPercentagePerHundred ) ;
delay_percentage - > set_denominator ( FractionalPercent : : HUNDRED ) ;
auto * fixed_delay = http_fault . mutable_delay ( ) - > mutable_fixed_delay ( ) ;
fixed_delay - > set_seconds ( kFixedDelaySeconds ) ;
// Config fault injection via different setup
SetFilterConfig ( http_fault ) ;
ClientContext context ;
context . set_deadline (
grpc_timeout_milliseconds_to_deadline ( kRpcTimeoutMilliseconds ) ) ;
auto stream = stub_ - > BidiStream ( & context ) ;
stream - > WritesDone ( ) ;
auto status = stream - > Finish ( ) ;
EXPECT_TRUE ( status . ok ( ) ) < < status . error_message ( ) < < " , "
< < status . error_details ( ) < < " , "
< < context . debug_error_string ( ) ;
}
// This case catches a bug in the retry code that was triggered by a bad
// interaction with the FI code. See https://github.com/grpc/grpc/pull/27217
// for description.
TEST_P ( FaultInjectionTest , XdsFaultInjectionBidiStreamDelayError ) {
const uint32_t kRpcTimeoutMilliseconds = grpc_test_slowdown_factor ( ) * 500 ;
const uint32_t kFixedDelaySeconds = 100 ;
const uint32_t kDelayPercentagePerHundred = 100 ;
SetNextResolution ( { } ) ;
SetNextResolutionForLbChannelAllBalancers ( ) ;
// Create an EDS resource
AdsServiceImpl : : EdsResourceArgs args ( {
{ " locality0 " , CreateEndpointsForBackends ( ) } ,
} ) ;
balancers_ [ 0 ] - > ads_service ( ) - > SetEdsResource (
BuildEdsResource ( args , DefaultEdsServiceName ( ) ) ) ;
// Construct the fault injection filter config
HTTPFault http_fault ;
auto * delay_percentage = http_fault . mutable_delay ( ) - > mutable_percentage ( ) ;
delay_percentage - > set_numerator ( kDelayPercentagePerHundred ) ;
delay_percentage - > set_denominator ( FractionalPercent : : HUNDRED ) ;
auto * fixed_delay = http_fault . mutable_delay ( ) - > mutable_fixed_delay ( ) ;
fixed_delay - > set_seconds ( kFixedDelaySeconds ) ;
// Config fault injection via different setup
SetFilterConfig ( http_fault ) ;
ClientContext context ;
context . set_deadline (
grpc_timeout_milliseconds_to_deadline ( kRpcTimeoutMilliseconds ) ) ;
auto stream = stub_ - > BidiStream ( & context ) ;
stream - > WritesDone ( ) ;
auto status = stream - > Finish ( ) ;
EXPECT_EQ ( StatusCode : : DEADLINE_EXCEEDED , status . error_code ( ) )
< < status . error_message ( ) < < " , " < < status . error_details ( ) < < " , "
< < context . debug_error_string ( ) ;
}
class BootstrapSourceTest : public XdsEnd2endTest {
public :
BootstrapSourceTest ( ) : XdsEnd2endTest ( 4 , 1 ) { }