proxygen
TestAbortPost< stage > Class Template Reference
Inheritance diagram for TestAbortPost< stage >:
MockHTTPUpstreamTest HTTPUpstreamTest< MockHTTPCodecPair > testing::Test

Public Member Functions

void doAbortTest ()
 
- Public Member Functions inherited from MockHTTPUpstreamTest
void SetUp () override
 
void TearDown () override
 
std::unique_ptr< StrictMock< MockHTTPHandler > > openTransaction ()
 
- Public Member Functions inherited from HTTPUpstreamTest< MockHTTPCodecPair >
 HTTPUpstreamTest (std::vector< int64_t > flowControl={-1,-1,-1})
 
void resumeWrites ()
 
virtual void onWriteChain (folly::AsyncTransportWrapper::WriteCallback *callback, std::shared_ptr< IOBuf > iob, WriteFlags)
 
void handleWrite (folly::AsyncTransportWrapper::WriteCallback *callback)
 
void SetUp () override
 
void commonSetUp (unique_ptr< HTTPCodec > codec)
 
unique_ptr< typename MockHTTPCodecPair::CodecmakeServerCodec ()
 
void enableExHeader (typename MockHTTPCodecPair::Codec *serverCodec)
 
void parseOutput (HTTPCodec &serverCodec)
 
void readAndLoop (const std::string &input)
 
void readAndLoop (IOBuf *buf)
 
void readAndLoop (const uint8_t *input, size_t length)
 
void testBasicRequest ()
 
void testBasicRequestHttp10 (bool keepalive)
 
void onCreate (const HTTPSessionBase &) override
 
void onDestroy (const HTTPSessionBase &) override
 
void onSettingsOutgoingStreamsFull (const HTTPSessionBase &) override
 
void onSettingsOutgoingStreamsNotFull (const HTTPSessionBase &) override
 
void TearDown () override
 
std::unique_ptr< StrictMock< MockHTTPHandler > > openTransaction (bool expectStartPaused=false)
 
std::unique_ptr< NiceMock< MockHTTPHandler > > openNiceTransaction (bool expectStartPaused=false)
 
void testSimpleUpgrade (const std::string &upgradeReqHeader, const std::string &upgradeRespHeader, CodecProtocol respCodecVersion)
 
MockByteEventTrackersetMockByteEventTracker ()
 
- Public Member Functions inherited from testing::Test
virtual ~Test ()
 
virtual ~Test ()
 
virtual ~Test ()
 

Additional Inherited Members

- Public Types inherited from testing::Test
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
- Static Public Member Functions inherited from testing::Test
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
- Public Attributes inherited from MockHTTPUpstreamTest
MockHTTPCodeccodecPtr_ {nullptr}
 
HTTPCodec::CallbackcodecCb_ {nullptr}
 
bool reusable_ {true}
 
uint32_t nextOutgoingTxn_ {1}
 
- Protected Member Functions inherited from testing::Test
 Test ()
 
 Test ()
 
 Test ()
 
- Protected Attributes inherited from HTTPUpstreamTest< MockHTTPCodecPair >
bool sessionCreated_
 
bool sessionDestroyed_
 
bool transactionsFull_
 
bool transportGood_
 
EventBase eventBase_
 
EventBaseeventBasePtr_
 
MockAsyncTransporttransport_
 
folly::AsyncTransportWrapper::ReadCallbackreadCallback_
 
folly::AsyncTransport::ReplaySafetyCallbackreplaySafetyCallback_
 
folly::HHWheelTimer::UniquePtr transactionTimeouts_
 
std::vector< int64_tflowControl_
 
wangle::TransportInfo mockTransportInfo_
 
SocketAddress localAddr_
 
SocketAddress peerAddr_
 
HTTPUpstreamSessionhttpSession_
 
IOBufQueue writes_
 
std::vector< folly::AsyncTransportWrapper::WriteCallback * > cbs_
 
bool failWrites_
 
bool pauseWrites_
 
bool writeInLoop_
 

Detailed Description

template<int stage>
class TestAbortPost< stage >

Definition at line 2170 of file HTTPUpstreamSessionTest.cpp.

Member Function Documentation

template<int stage>
void TestAbortPost< stage >::doAbortTest ( )
inline

Definition at line 2172 of file HTTPUpstreamSessionTest.cpp.

References testing::_, testing::AtLeast(), folly::IOBuf::computeChainDataLength(), EXPECT_CALL, proxygen::getPostRequest(), handler(), makeBuf(), proxygen::makeResponse(), folly::gen::move, and streamID.

2172  {
2173  // Send an abort at various points while receiving the response to a GET
2174  // The test is broken into "stages"
2175  // Stage 0) headers received
2176  // Stage 1) chunk header received
2177  // Stage 2) body received
2178  // Stage 3) chunk complete received
2179  // Stage 4) trailers received
2180  // Stage 5) eom received
2181  // This test makes sure expected callbacks are received if an abort is
2182  // sent before any of these stages.
2183  InSequence enforceOrder;
2185  HTTPMessage req = getPostRequest(10);
2186 
2187  std::unique_ptr<HTTPMessage> resp;
2188  std::unique_ptr<folly::IOBuf> respBody;
2189  std::tie(resp, respBody) = makeResponse(200, 50);
2190 
2191  handler.expectTransaction();
2192  EXPECT_CALL(*codecPtr_, generateHeader(_, _, _, _, _));
2193 
2194  if (stage > 0) {
2195  handler.expectHeaders();
2196  }
2197  if (stage > 1) {
2198  EXPECT_CALL(handler, onChunkHeader(_));
2199  }
2200  if (stage > 2) {
2201  EXPECT_CALL(handler, onBody(_));
2202  }
2203  if (stage > 3) {
2204  EXPECT_CALL(handler, onChunkComplete());
2205  }
2206  if (stage > 4) {
2207  EXPECT_CALL(handler, onTrailers(_));
2208  }
2209  if (stage > 5) {
2210  handler.expectEOM();
2211  }
2212 
2213  auto txn = httpSession_->newTransaction(&handler);
2214  auto streamID = txn->getID();
2215  txn->sendHeaders(req);
2216  txn->sendBody(makeBuf(5)); // only send half the body
2217 
2218  auto doAbort = [&] {
2219  EXPECT_CALL(*codecPtr_, generateRstStream(_, txn->getID(), _));
2220  handler.expectDetachTransaction();
2221  const auto id = txn->getID();
2222  txn->sendAbort();
2224  generateRstStream(_, id, ErrorCode::_SPDY_INVALID_STREAM))
2225  .Times(AtLeast(0));
2226  };
2227 
2228  if (stage == 0) {
2229  doAbort();
2230  }
2232  if (stage == 1) {
2233  doAbort();
2234  }
2236  if (stage == 2) {
2237  doAbort();
2238  }
2239  codecCb_->onBody(streamID, std::move(respBody), 0);
2240  if (stage == 3) {
2241  doAbort();
2242  }
2244  if (stage == 4) {
2245  doAbort();
2246  }
2248  std::make_unique<HTTPHeaders>());
2249  if (stage == 5) {
2250  doAbort();
2251  }
2253 
2254  eventBase_.loop();
2255  }
HTTPTransaction * newTransaction(HTTPTransaction::Handler *handler) override
GTEST_API_ Cardinality AtLeast(int n)
virtual void onChunkHeader(StreamID, size_t)
Definition: HTTPCodec.h:148
virtual void onMessageComplete(StreamID stream, bool upgrade)=0
virtual void onTrailersComplete(StreamID stream, std::unique_ptr< HTTPHeaders > trailers)=0
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void handler(int, siginfo_t *, void *)
std::unique_ptr< folly::IOBuf > makeBuf(uint32_t size)
Definition: ZlibTests.cpp:26
std::unique_ptr< HTTPMessage > makeResponse(uint16_t statusCode)
Definition: TestUtils.cpp:147
std::size_t computeChainDataLength() const
Definition: IOBuf.cpp:501
virtual void onHeadersComplete(StreamID stream, std::unique_ptr< HTTPMessage > msg)=0
HTTPCodec::Callback * codecCb_
HTTPMessage getPostRequest(uint32_t contentLength)
Definition: TestUtils.cpp:102
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
virtual void onChunkComplete(StreamID)
Definition: HTTPCodec.h:156
virtual void onBody(StreamID stream, std::unique_ptr< folly::IOBuf > chain, uint16_t padding)=0
uint32_t streamID
Definition: SPDYCodec.cpp:131

The documentation for this class was generated from the following file: