proxygen
HTTPParallelCodecTest Class Reference

#include <HTTPParallelCodecTest.h>

Inheritance diagram for HTTPParallelCodecTest:
testing::Test HTTP2CodecTest SPDYCodecTestF

Public Member Functions

 HTTPParallelCodecTest (proxygen::HTTPParallelCodec &upstreamCodec, proxygen::HTTPParallelCodec &downstreamCodec)
 
void SetUp () override
 
void SetUpUpstreamTest ()
 
bool parse (std::function< void(folly::IOBuf *)> hackIngress=std::function< void(folly::IOBuf *)>())
 
bool parseUpstream (std::function< void(folly::IOBuf *)> hackIngress=std::function< void(folly::IOBuf *)>())
 
bool parseImpl (proxygen::HTTPParallelCodec &codec, std::function< void(folly::IOBuf *)> hackIngress)
 
void dumpToFile (bool isUpstream=false)
 
- Public Member Functions inherited from testing::Test
virtual ~Test ()
 
virtual ~Test ()
 
virtual ~Test ()
 

Protected Attributes

proxygen::FakeHTTPCodecCallback callbacks_
 
proxygen::HTTPParallelCodecupstreamCodec_
 
proxygen::HTTPParallelCodecdownstreamCodec_
 
folly::IOBufQueue output_ {folly::IOBufQueue::cacheChainLength()}
 
const testing::TestInfotestInfo_ {testing::UnitTest::GetInstance()->current_test_info()}
 
bool dump_ {false}
 

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 16 of file HTTPParallelCodecTest.h.

Constructor & Destructor Documentation

HTTPParallelCodecTest::HTTPParallelCodecTest ( proxygen::HTTPParallelCodec upstreamCodec,
proxygen::HTTPParallelCodec downstreamCodec 
)
inline

Definition at line 18 of file HTTPParallelCodecTest.h.

20  : upstreamCodec_(upstreamCodec),
21  downstreamCodec_(downstreamCodec) {}
proxygen::HTTPParallelCodec & downstreamCodec_
proxygen::HTTPParallelCodec & upstreamCodec_

Member Function Documentation

void HTTPParallelCodecTest::dumpToFile ( bool  isUpstream = false)
inline

Definition at line 68 of file HTTPParallelCodecTest.h.

References dump_, proxygen::dumpBinToFile(), folly::IOBufQueue::front(), testing::TestInfo::name(), output_, and testInfo_.

Referenced by parseImpl().

68  {
69  if (!dump_) {
70  return;
71  }
72  auto endpoint = isUpstream ? "client" : "server";
73  auto filename = folly::to<std::string>(
74  "/tmp/parallel_", endpoint, "_", testInfo_->name(), ".bin");
76  }
const folly::IOBuf * front() const
Definition: IOBufQueue.h:476
void dumpBinToFile(const string &filename, const IOBuf *buf)
Definition: Logging.cpp:132
const char * name() const
Definition: gtest.h:654
const testing::TestInfo * testInfo_
bool HTTPParallelCodecTest::parse ( std::function< void(folly::IOBuf *)>  hackIngress = std::function<void(folly::IOBuf*)>())
inline

Definition at line 37 of file HTTPParallelCodecTest.h.

References downstreamCodec_, and parseImpl().

38  {
39  return parseImpl(downstreamCodec_, hackIngress);
40  }
proxygen::HTTPParallelCodec & downstreamCodec_
bool parseImpl(proxygen::HTTPParallelCodec &codec, std::function< void(folly::IOBuf *)> hackIngress)
bool HTTPParallelCodecTest::parseImpl ( proxygen::HTTPParallelCodec codec,
std::function< void(folly::IOBuf *)>  hackIngress 
)
inline

Definition at line 51 of file HTTPParallelCodecTest.h.

References dumpToFile(), proxygen::HTTPParallelCodec::getTransportDirection(), folly::IOBufQueue::move(), proxygen::HTTPCodec::onIngress(), output_, and proxygen::UPSTREAM.

Referenced by parse(), and parseUpstream().

52  {
55  auto ingress = output_.move();
56  if (hackIngress) {
57  hackIngress(ingress.get());
58  }
59  size_t parsed = codec.onIngress(*ingress);
60  return (parsed == ingress->computeChainDataLength());
61  }
virtual size_t onIngress(const folly::IOBuf &buf)=0
std::unique_ptr< folly::IOBuf > move()
Definition: IOBufQueue.h:459
void dumpToFile(bool isUpstream=false)
TransportDirection getTransportDirection() const override
bool HTTPParallelCodecTest::parseUpstream ( std::function< void(folly::IOBuf *)>  hackIngress = std::function<void(folly::IOBuf*)>())
inline

Definition at line 42 of file HTTPParallelCodecTest.h.

References parseImpl(), and upstreamCodec_.

43  {
44  return parseImpl(upstreamCodec_, hackIngress);
45  }
bool parseImpl(proxygen::HTTPParallelCodec &codec, std::function< void(folly::IOBuf *)> hackIngress)
proxygen::HTTPParallelCodec & upstreamCodec_
void HTTPParallelCodecTest::SetUp ( )
inlineoverridevirtual

Reimplemented from testing::Test.

Definition at line 23 of file HTTPParallelCodecTest.h.

References callbacks_, downstreamCodec_, proxygen::HTTPCodec::generateConnectionPreface(), output_, proxygen::HTTPParallelCodec::setCallback(), and upstreamCodec_.

Referenced by HTTP2CodecTest::SetUp().

23  {
26  // Most tests are downstream tests, so generate the upstream conn preface
27  // by default
29  }
void setCallback(Callback *callback) override
proxygen::HTTPParallelCodec & downstreamCodec_
proxygen::FakeHTTPCodecCallback callbacks_
virtual size_t generateConnectionPreface(folly::IOBufQueue &)
Definition: HTTPCodec.h:475
proxygen::HTTPParallelCodec & upstreamCodec_
void HTTPParallelCodecTest::SetUpUpstreamTest ( )
inline

Definition at line 31 of file HTTPParallelCodecTest.h.

References downstreamCodec_, proxygen::HTTPCodec::generateConnectionPreface(), proxygen::HTTPCodec::generateSettings(), folly::IOBufQueue::move(), and output_.

31  {
32  output_.move();
35  }
proxygen::HTTPParallelCodec & downstreamCodec_
std::unique_ptr< folly::IOBuf > move()
Definition: IOBufQueue.h:459
virtual size_t generateConnectionPreface(folly::IOBufQueue &)
Definition: HTTPCodec.h:475
virtual size_t generateSettings(folly::IOBufQueue &)
Definition: HTTPCodec.h:592

Member Data Documentation

proxygen::FakeHTTPCodecCallback HTTPParallelCodecTest::callbacks_
protected

Definition at line 79 of file HTTPParallelCodecTest.h.

Referenced by SetUp().

proxygen::HTTPParallelCodec& HTTPParallelCodecTest::downstreamCodec_
protected

Definition at line 81 of file HTTPParallelCodecTest.h.

Referenced by parse(), SetUp(), and SetUpUpstreamTest().

bool HTTPParallelCodecTest::dump_ {false}
protected

Definition at line 85 of file HTTPParallelCodecTest.h.

Referenced by dumpToFile().

folly::IOBufQueue HTTPParallelCodecTest::output_ {folly::IOBufQueue::cacheChainLength()}
protected

Definition at line 82 of file HTTPParallelCodecTest.h.

Referenced by dumpToFile(), parseImpl(), SetUp(), and SetUpUpstreamTest().

const testing::TestInfo* HTTPParallelCodecTest::testInfo_ {testing::UnitTest::GetInstance()->current_test_info()}
protected

Definition at line 84 of file HTTPParallelCodecTest.h.

Referenced by dumpToFile().

proxygen::HTTPParallelCodec& HTTPParallelCodecTest::upstreamCodec_
protected

Definition at line 80 of file HTTPParallelCodecTest.h.

Referenced by parseUpstream(), and SetUp().


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