proxygen
DownstreamTransactionTest Class Reference
Inheritance diagram for DownstreamTransactionTest:
testing::Test

Public Member Functions

 DownstreamTransactionTest ()
 
void SetUp () override
 
void setupRequestResponseFlow (HTTPTransaction *txn, uint32_t size, bool delayResponse=false)
 
- Public Member Functions inherited from testing::Test
virtual ~Test ()
 
virtual ~Test ()
 
virtual ~Test ()
 

Protected Attributes

folly::EventBase eventBase_
 
folly::HHWheelTimer::UniquePtr transactionTimeouts_
 
MockHTTPTransactionTransport transport_
 
StrictMock< MockHTTPHandlerhandler_
 
HTTP2PriorityQueue txnEgressQueue_
 
uint32_t received_ {0}
 
uint32_t sent_ {0}
 

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)
 
- Protected Member Functions inherited from testing::Test
 Test ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void TearDown ()
 

Detailed Description

Definition at line 30 of file DownstreamTransactionTest.cpp.

Constructor & Destructor Documentation

DownstreamTransactionTest::DownstreamTransactionTest ( )
inline

Definition at line 32 of file DownstreamTransactionTest.cpp.

32 {}

Member Function Documentation

void DownstreamTransactionTest::SetUp ( )
inlineoverridevirtual

Reimplemented from testing::Test.

Definition at line 34 of file DownstreamTransactionTest.cpp.

References testing::_, EXPECT_CALL, testing::Return(), and transport_.

34  {
35  EXPECT_CALL(transport_, describe(_))
36  .WillRepeatedly(Return());
37  }
MockHTTPTransactionTransport transport_
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
internal::ReturnAction< R > Return(R value)
void DownstreamTransactionTest::setupRequestResponseFlow ( HTTPTransaction txn,
uint32_t  size,
bool  delayResponse = false 
)
inline

Definition at line 39 of file DownstreamTransactionTest.cpp.

References testing::_, testing::DoDefault(), EXPECT_CALL, EXPECT_EQ, proxygen::HTTPMessage::getStatusCode(), testing::Invoke(), testing::InvokeWithoutArgs(), proxygen::makeBuf(), proxygen::makeResponse(), proxygen::HTTPTransaction::onIngressBody(), proxygen::HTTPTransaction::onIngressEOM(), proxygen::HTTPTransaction::onWriteReady(), proxygen::HTTPTransaction::sendBody(), proxygen::HTTPTransaction::sendEOM(), proxygen::HTTPTransaction::sendHeaders(), proxygen::HTTPTransaction::setHandler(), and transport_.

40  {
41  EXPECT_CALL(handler_, setTransaction(txn));
42  EXPECT_CALL(handler_, detachTransaction());
43  EXPECT_CALL(transport_, detach(txn));
44  if (delayResponse) {
45  EXPECT_CALL(handler_, onHeadersComplete(_));
46  } else {
47  EXPECT_CALL(handler_, onHeadersComplete(_))
48  .WillOnce(Invoke([=](std::shared_ptr<HTTPMessage> /*msg*/) {
49  auto response = makeResponse(200);
50  txn->sendHeaders(*response.get());
51  txn->sendBody(makeBuf(size));
52  txn->sendEOM();
53  }));
54  }
55  EXPECT_CALL(transport_, sendHeaders(txn, _, _, _))
56  .WillOnce(Invoke([=](Unused, const HTTPMessage& headers, Unused, Unused) {
57  EXPECT_EQ(headers.getStatusCode(), 200);
58  }));
59  EXPECT_CALL(transport_, sendBody(txn, _, false, false))
60  .WillRepeatedly(Invoke([=](Unused, std::shared_ptr<folly::IOBuf> body,
61  Unused, Unused) {
62  auto cur = body->computeChainDataLength();
63  sent_ += cur;
64  return cur;
65  }));
66  if (delayResponse) {
67  EXPECT_CALL(transport_, sendEOM(txn, _));
68  } else {
69  EXPECT_CALL(transport_, sendEOM(txn, _))
70  .WillOnce(InvokeWithoutArgs([=]() {
71  CHECK_EQ(sent_, size);
72  txn->onIngressBody(makeBuf(size), 0);
73  txn->onIngressEOM();
74  return 5;
75  }));
76  }
77  EXPECT_CALL(handler_, onBody(_))
78  .WillRepeatedly(Invoke([=](std::shared_ptr<folly::IOBuf> body) {
79  received_ += body->computeChainDataLength();
80  }));
81  EXPECT_CALL(handler_, onEOM())
82  .WillOnce(InvokeWithoutArgs([=] {
83  CHECK_EQ(received_, size);
84  }));
85  EXPECT_CALL(transport_, notifyPendingEgress())
86  .WillOnce(InvokeWithoutArgs([=] {
87  txn->onWriteReady(size, 1);
88  }))
89  .WillOnce(DoDefault()); // The second call is for sending the eom
90 
91  txn->setHandler(&handler_);
92  }
virtual void setHandler(Handler *handler)
MockHTTPTransactionTransport transport_
bool onWriteReady(uint32_t maxEgress, double ratio)
uint16_t getStatusCode() const
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void onIngressBody(std::unique_ptr< folly::IOBuf > chain, uint16_t padding)
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
std::unique_ptr< folly::IOBuf > makeBuf(uint32_t size)
Definition: ZlibTests.cpp:26
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
virtual void sendBody(std::unique_ptr< folly::IOBuf > body)
virtual void sendHeaders(const HTTPMessage &headers)
std::unique_ptr< HTTPMessage > makeResponse(uint16_t statusCode)
Definition: TestUtils.cpp:147
internal::DoDefaultAction DoDefault()
StrictMock< MockHTTPHandler > handler_
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _

Member Data Documentation

folly::EventBase DownstreamTransactionTest::eventBase_
protected

Definition at line 95 of file DownstreamTransactionTest.cpp.

StrictMock<MockHTTPHandler> DownstreamTransactionTest::handler_
protected

Definition at line 103 of file DownstreamTransactionTest.cpp.

uint32_t DownstreamTransactionTest::received_ {0}
protected

Definition at line 105 of file DownstreamTransactionTest.cpp.

uint32_t DownstreamTransactionTest::sent_ {0}
protected

Definition at line 106 of file DownstreamTransactionTest.cpp.

folly::HHWheelTimer::UniquePtr DownstreamTransactionTest::transactionTimeouts_
protected
Initial value:

Definition at line 96 of file DownstreamTransactionTest.cpp.

MockHTTPTransactionTransport DownstreamTransactionTest::transport_
protected

Definition at line 102 of file DownstreamTransactionTest.cpp.

HTTP2PriorityQueue DownstreamTransactionTest::txnEgressQueue_
protected

Definition at line 104 of file DownstreamTransactionTest.cpp.


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