test/extensions/filters/http/ext_proc/filter_test.cc
// Using the default configuration, test the filter with a processor that
// returns an error from from the gRPC stream.
Using the default configuration, test the filter with a processor that
returns an error from from the gRPC stream.
Using the default configuration test the filter with a processor that returns an error from from the gRPC stream .
TEST_F(HttpFilterTest, PostAndFail) {
  initialize(R"EOF(
  grpc_service:
    envoy_grpc:
      cluster_name: "ext_proc_server"
  )EOF");
  EXPECT_FALSE(config_->failureModeAllow());
  HttpTestUtility::addDefaultHeaders(request_headers_, "POST");
  EXPECT_EQ(FilterHeadersStatus::StopAllIterationAndWatermark,
            filter_->decodeHeaders(request_headers_, false));
  EXPECT_FALSE(stream_close_sent_);
  EXPECT_CALL(decoder_callbacks_,
              sendLocalReply(Http::Code::InternalServerError, "", Eq(nullptr), Eq(absl::nullopt),
                             "ext_proc error: gRPC error 13"));
  EXPECT_CALL(decoder_callbacks_, encodeHeaders_(_, _));
  stream_callbacks_->onGrpcError(Grpc::Status::Internal);
  data_.add("foo");
  EXPECT_EQ(FilterDataStatus::Continue, filter_->decodeData(data_, true));
  EXPECT_EQ(FilterTrailersStatus::Continue, filter_->decodeTrailers(request_trailers_));
  EXPECT_EQ(FilterHeadersStatus::Continue, filter_->encode100ContinueHeaders(response_headers_));
  EXPECT_EQ(FilterHeadersStatus::Continue, filter_->encodeHeaders(response_headers_, true));
  data_.add("bar");
  EXPECT_EQ(FilterDataStatus::Continue, filter_->encodeData(data_, false));
  EXPECT_EQ(FilterDataStatus::Continue, filter_->encodeData(data_, true));
  EXPECT_EQ(FilterTrailersStatus::Continue, filter_->encodeTrailers(response_trailers_));
  filter_->onDestroy();
  EXPECT_FALSE(stream_close_sent_);
  EXPECT_EQ(1, config_->stats().streams_started_.value());
  EXPECT_EQ(1, config_->stats().stream_msgs_sent_.value());
  EXPECT_EQ(1, config_->stats().streams_failed_.value());
}
TEST_F ( HttpFilterTest , PostAndFail ) { initialize ( R" EOF ( 
  grpc_service:
    envoy_grpc:
      cluster_name: "ext_proc_server"
   ) EOF " ) ; EXPECT_FALSE ( config_ -> failureModeAllow ( ) ) ; HttpTestUtility :: addDefaultHeaders ( request_headers_ , " " ) ; EXPECT_EQ ( FilterHeadersStatus :: StopAllIterationAndWatermark , filter_ -> decodeHeaders ( request_headers_ , false ) ) ; EXPECT_FALSE ( stream_close_sent_ ) ; EXPECT_CALL ( decoder_callbacks_ , sendLocalReply ( Http :: Code :: InternalServerError , " " , Eq ( nullptr ) , Eq ( absl :: nullopt ) , " " ) ) ; EXPECT_CALL ( decoder_callbacks_ , encodeHeaders_ ( _ , _ ) ) ; stream_callbacks_ -> onGrpcError ( Grpc :: Status :: Internal ) ; data_ . add ( " " ) ; EXPECT_EQ ( FilterDataStatus :: Continue , filter_ -> decodeData ( data_ , true ) ) ; EXPECT_EQ ( FilterTrailersStatus :: Continue , filter_ -> decodeTrailers ( request_trailers_ ) ) ; EXPECT_EQ ( FilterHeadersStatus :: Continue , filter_ -> encode100ContinueHeaders ( response_headers_ ) ) ; EXPECT_EQ ( FilterHeadersStatus :: Continue , filter_ -> encodeHeaders ( response_headers_ , true ) ) ; data_ . add ( " " ) ; EXPECT_EQ ( FilterDataStatus :: Continue , filter_ -> encodeData ( data_ , false ) ) ; EXPECT_EQ ( FilterDataStatus :: Continue , filter_ -> encodeData ( data_ , true ) ) ; EXPECT_EQ ( FilterTrailersStatus :: Continue , filter_ -> encodeTrailers ( response_trailers_ ) ) ; filter_ -> onDestroy ( ) ; EXPECT_FALSE ( stream_close_sent_ ) ; EXPECT_EQ ( 1 , config_ -> stats ( ) . streams_started_ . value ( ) ) ; EXPECT_EQ ( 1 , config_ -> stats ( ) . stream_msgs_sent_ . value ( ) ) ; EXPECT_EQ ( 1 , config_ -> stats ( ) . streams_failed_ . value ( ) ) ; }
Using the default configuration, test the filter with a processor that
returns an error from from the gRPC stream.
Using the default configuration test the filter with a processor that returns an error from from the gRPC stream .
// Create synthetic HTTP request // Oh no! The remote server had a failure! // In this case, this call includes header encoding // The other side closed the stream