proxygen
TraceEventTest.cpp File Reference

Go to the source code of this file.

Functions

 TEST (TraceEventTest, IntegralDataIntegralValue)
 
 TEST (TraceEventTest, IntegralDataStringValue)
 
 TEST (TraceEventTest, IntegralDataVectorValue)
 
 TEST (TraceEventTest, StringDataIntegralValueConvertible)
 
 TEST (TraceEventTest, StringDataIntegralValueNonConvertible)
 
 TEST (TraceEventTest, StringDataStringValue)
 
 TEST (TraceEventTest, StringDataVectorValue)
 
 TEST (TraceEventTest, VectorDataIntegralValue)
 
 TEST (TraceEventTest, VectorDataStringValue)
 
 TEST (TraceEventTest, VectorDataVectorValue)
 
 TEST (TraceEventTest, IteratorValueTypeCheckInteger)
 
 TEST (TraceEventTest, IteratorValueTypeCheckString)
 
 TEST (TraceEventTest, IteratorValueTypeCheckStringArray)
 
 TEST (TraceEventTest, IntegerValueToString)
 
 TEST (TraceEventTest, StringValueToString)
 
 TEST (TraceEventTest, StringArrayValueToString)
 

Function Documentation

TEST ( TraceEventTest  ,
IntegralDataIntegralValue   
)

Definition at line 23 of file TraceEventTest.cpp.

References proxygen::TraceEvent::addMeta(), ASSERT_EQ, data, proxygen::TraceEvent::getTraceFieldDataAs(), int64_t, proxygen::Protocol, and proxygen::TotalRequest.

23  {
25 
26  int64_t data(13);
27  traceEvent.addMeta(TraceFieldType::Protocol, data);
28 
30  traceEvent.getTraceFieldDataAs<int64_t>(TraceFieldType::Protocol));
31 }
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
HTTPServer::Protocol Protocol
Definition: EchoServer.cpp:27
TotalRequest
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
TEST ( TraceEventTest  ,
IntegralDataStringValue   
)

Definition at line 33 of file TraceEventTest.cpp.

References proxygen::TraceEvent::addMeta(), ASSERT_EQ, proxygen::TraceEvent::getTraceFieldDataAs(), int64_t, proxygen::Protocol, string, and proxygen::TotalRequest.

33  {
35 
36  int64_t intData(13);
37  traceEvent.addMeta(TraceFieldType::Protocol, intData);
38 
39  std::string strData(std::to_string(intData));
40 
41  ASSERT_EQ(strData,
42  traceEvent.getTraceFieldDataAs<std::string>(TraceFieldType::Protocol));
43 }
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
HTTPServer::Protocol Protocol
Definition: EchoServer.cpp:27
const char * string
Definition: Conv.cpp:212
TotalRequest
TEST ( TraceEventTest  ,
IntegralDataVectorValue   
)

Definition at line 45 of file TraceEventTest.cpp.

References proxygen::TraceEvent::addMeta(), ASSERT_THROW, data, proxygen::TraceEvent::getTraceFieldDataAs(), int64_t, proxygen::Protocol, and proxygen::TotalRequest.

45  {
47 
48  int64_t data(13);
49  traceEvent.addMeta(TraceFieldType::Protocol, data);
50 
52  traceEvent.getTraceFieldDataAs<std::vector<std::string>>(
54  Exception);
55 }
#define ASSERT_THROW(statement, expected_exception)
Definition: gtest.h:1849
HTTPServer::Protocol Protocol
Definition: EchoServer.cpp:27
TotalRequest
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
TEST ( TraceEventTest  ,
StringDataIntegralValueConvertible   
)

Definition at line 57 of file TraceEventTest.cpp.

References proxygen::TraceEvent::addMeta(), ASSERT_EQ, proxygen::TraceEvent::getTraceFieldDataAs(), int64_t, proxygen::Protocol, string, and proxygen::TotalRequest.

57  {
59 
60  int64_t intData(13);
61  std::string strData(std::to_string(intData));
62  traceEvent.addMeta(TraceFieldType::Protocol, strData);
63 
64  ASSERT_EQ(intData,
65  traceEvent.getTraceFieldDataAs<int64_t>(TraceFieldType::Protocol));
66 }
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
HTTPServer::Protocol Protocol
Definition: EchoServer.cpp:27
const char * string
Definition: Conv.cpp:212
TotalRequest
TEST ( TraceEventTest  ,
StringDataIntegralValueNonConvertible   
)

Definition at line 68 of file TraceEventTest.cpp.

References proxygen::TraceEvent::addMeta(), ASSERT_ANY_THROW, data, proxygen::TraceEvent::getTraceFieldDataAs(), int64_t, proxygen::Protocol, string, and proxygen::TotalRequest.

68  {
70 
71  std::string data("Abc");
72  traceEvent.addMeta(TraceFieldType::Protocol, data);
73 
75  traceEvent.getTraceFieldDataAs<int64_t>(TraceFieldType::Protocol));
76 }
#define ASSERT_ANY_THROW(statement)
Definition: gtest.h:1853
HTTPServer::Protocol Protocol
Definition: EchoServer.cpp:27
const char * string
Definition: Conv.cpp:212
TotalRequest
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
TEST ( TraceEventTest  ,
StringDataStringValue   
)

Definition at line 78 of file TraceEventTest.cpp.

References proxygen::TraceEvent::addMeta(), ASSERT_EQ, data, proxygen::TraceEvent::getTraceFieldDataAs(), proxygen::Protocol, string, and proxygen::TotalRequest.

78  {
80 
81  std::string data("Abc");
82  traceEvent.addMeta(TraceFieldType::Protocol, data);
83 
85  traceEvent.getTraceFieldDataAs<std::string>(TraceFieldType::Protocol));
86 }
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
HTTPServer::Protocol Protocol
Definition: EchoServer.cpp:27
const char * string
Definition: Conv.cpp:212
TotalRequest
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
TEST ( TraceEventTest  ,
StringDataVectorValue   
)

Definition at line 89 of file TraceEventTest.cpp.

References proxygen::TraceEvent::addMeta(), ASSERT_THROW, data, proxygen::TraceEvent::getTraceFieldDataAs(), proxygen::Protocol, string, and proxygen::TotalRequest.

89  {
91 
92  std::string data("Abc");
93  traceEvent.addMeta(TraceFieldType::Protocol, data);
94 
96  traceEvent.getTraceFieldDataAs<std::vector<std::string>>(
98  Exception);
99 }
#define ASSERT_THROW(statement, expected_exception)
Definition: gtest.h:1849
HTTPServer::Protocol Protocol
Definition: EchoServer.cpp:27
const char * string
Definition: Conv.cpp:212
TotalRequest
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
TEST ( TraceEventTest  ,
VectorDataIntegralValue   
)

Definition at line 101 of file TraceEventTest.cpp.

References proxygen::TraceEvent::addMeta(), ASSERT_THROW, data, proxygen::TraceEvent::getTraceFieldDataAs(), int64_t, proxygen::Protocol, and proxygen::TotalRequest.

101  {
103 
104  std::vector<std::string> data;
105  data.push_back("Abc");
106  data.push_back("Hij");
107  data.push_back("Xyz");
108  traceEvent.addMeta(TraceFieldType::Protocol, data);
109 
110  ASSERT_THROW(
111  traceEvent.getTraceFieldDataAs<int64_t>(TraceFieldType::Protocol),
112  Exception);
113 }
#define ASSERT_THROW(statement, expected_exception)
Definition: gtest.h:1849
HTTPServer::Protocol Protocol
Definition: EchoServer.cpp:27
TotalRequest
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
TEST ( TraceEventTest  ,
VectorDataStringValue   
)

Definition at line 115 of file TraceEventTest.cpp.

References proxygen::TraceEvent::addMeta(), ASSERT_EQ, data, proxygen::TraceEvent::getTraceFieldDataAs(), proxygen::Protocol, string, and proxygen::TotalRequest.

115  {
117 
118  std::vector<std::string> data;
119  data.push_back("A");
120  data.push_back("B");
121  data.push_back("C");
122  traceEvent.addMeta(TraceFieldType::Protocol, data);
123 
124  ASSERT_EQ(
125  "[\"A\",\"B\",\"C\"]",
126  traceEvent.getTraceFieldDataAs<std::string>(TraceFieldType::Protocol));
127 }
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
HTTPServer::Protocol Protocol
Definition: EchoServer.cpp:27
const char * string
Definition: Conv.cpp:212
TotalRequest
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
TEST ( TraceEventTest  ,
VectorDataVectorValue   
)

Definition at line 129 of file TraceEventTest.cpp.

References proxygen::TraceEvent::addMeta(), testing::ContainerEq(), data, EXPECT_THAT, proxygen::TraceEvent::getTraceFieldDataAs(), proxygen::Protocol, and proxygen::TotalRequest.

129  {
131 
132  std::vector<std::string> data;
133  data.push_back("A");
134  data.push_back("B");
135  data.push_back("C");
136  traceEvent.addMeta(TraceFieldType::Protocol, data);
137 
138  std::vector<std::string> extractedData(
139  traceEvent.getTraceFieldDataAs<std::vector<std::string>>(
141 
142  EXPECT_THAT(extractedData, testing::ContainerEq(data));
143 }
PolymorphicMatcher< internal::ContainerEqMatcher< GTEST_REMOVE_CONST_(Container)> > ContainerEq(const Container &rhs)
HTTPServer::Protocol Protocol
Definition: EchoServer.cpp:27
#define EXPECT_THAT(value, matcher)
TotalRequest
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
TEST ( TraceEventTest  ,
IteratorValueTypeCheckInteger   
)

Definition at line 145 of file TraceEventTest.cpp.

References proxygen::TraceEvent::addMeta(), ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, proxygen::TraceEvent::getMetaDataItr(), int64_t, proxygen::Protocol, and proxygen::TotalRequest.

145  {
147  int64_t intData(13);
148  traceEvent.addMeta(TraceFieldType::Protocol, intData);
149 
150  auto itr = traceEvent.getMetaDataItr();
151  ASSERT_TRUE(itr.isValid());
152  ASSERT_EQ(TraceFieldType::Protocol, itr.getKey());
153  ASSERT_EQ(typeid(int64_t), itr.type());
154 
155  itr.next();
156  ASSERT_FALSE(itr.isValid());
157 }
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
HTTPServer::Protocol Protocol
Definition: EchoServer.cpp:27
TotalRequest
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
TEST ( TraceEventTest  ,
IteratorValueTypeCheckString   
)

Definition at line 159 of file TraceEventTest.cpp.

References proxygen::TraceEvent::addMeta(), ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, proxygen::TraceEvent::getMetaDataItr(), proxygen::Protocol, string, and proxygen::TotalRequest.

159  {
161  std::string strData("abc");
162  traceEvent.addMeta(TraceFieldType::Protocol, strData);
163 
164  auto itr = traceEvent.getMetaDataItr();
165  ASSERT_TRUE(itr.isValid());
166  ASSERT_EQ(TraceFieldType::Protocol, itr.getKey());
167  ASSERT_EQ(typeid(std::string), itr.type());
168 
169  itr.next();
170  ASSERT_FALSE(itr.isValid());
171 }
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
HTTPServer::Protocol Protocol
Definition: EchoServer.cpp:27
const char * string
Definition: Conv.cpp:212
TotalRequest
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
TEST ( TraceEventTest  ,
IteratorValueTypeCheckStringArray   
)

Definition at line 173 of file TraceEventTest.cpp.

References proxygen::TraceEvent::addMeta(), ASSERT_EQ, ASSERT_FALSE, ASSERT_TRUE, proxygen::TraceEvent::getMetaDataItr(), proxygen::Protocol, and proxygen::TotalRequest.

173  {
175  std::vector<std::string> arrData;
176  arrData.push_back("A");
177  arrData.push_back("B");
178  arrData.push_back("C");
179  traceEvent.addMeta(TraceFieldType::Protocol, arrData);
180 
181  auto itr = traceEvent.getMetaDataItr();
182  ASSERT_TRUE(itr.isValid());
183  ASSERT_EQ(TraceFieldType::Protocol, itr.getKey());
184  ASSERT_EQ(typeid(std::vector<std::string>), itr.type());
185 
186  itr.next();
187  ASSERT_FALSE(itr.isValid());
188 }
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
HTTPServer::Protocol Protocol
Definition: EchoServer.cpp:27
TotalRequest
#define ASSERT_FALSE(condition)
Definition: gtest.h:1868
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865
TEST ( TraceEventTest  ,
IntegerValueToString   
)

Definition at line 191 of file TraceEventTest.cpp.

References proxygen::TraceEvent::addMeta(), ASSERT_EQ, proxygen::TraceEvent::end(), proxygen::TraceEvent::getID(), int64_t, proxygen::Protocol, proxygen::TraceEvent::start(), proxygen::TraceEvent::toString(), and proxygen::TotalRequest.

191  {
193  traceEvent.start(TimePoint(std::chrono::milliseconds(100)));
194  traceEvent.end(TimePoint(std::chrono::milliseconds(200)));
195  int64_t intData(13);
196  traceEvent.addMeta(TraceFieldType::Protocol, intData);
197 
198  std::ostringstream out;
199  out << "TraceEvent(";
200  out << "type='TotalRequest', ";
201  out << "id='" << traceEvent.getID() << "', ";
202  out << "parentID='1', ";
203  out << "start='100', ";
204  out << "end='200', ";
205  out << "metaData='{protocol: 13, }')";
206 
207  ASSERT_EQ(out.str(), traceEvent.toString());
208 }
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
HTTPServer::Protocol Protocol
Definition: EchoServer.cpp:27
TotalRequest
StatsClock::time_point TimePoint
TEST ( TraceEventTest  ,
StringValueToString   
)

Definition at line 210 of file TraceEventTest.cpp.

References proxygen::TraceEvent::addMeta(), ASSERT_EQ, proxygen::TraceEvent::end(), proxygen::TraceEvent::getID(), proxygen::Protocol, proxygen::TraceEvent::start(), string, proxygen::TraceEvent::toString(), and proxygen::TotalRequest.

210  {
212  traceEvent.start(TimePoint(std::chrono::milliseconds(100)));
213  traceEvent.end(TimePoint(std::chrono::milliseconds(200)));
214  std::string strData("abc");
215  traceEvent.addMeta(TraceFieldType::Protocol, strData);
216 
217  std::ostringstream out;
218  out << "TraceEvent(";
219  out << "type='TotalRequest', ";
220  out << "id='" << traceEvent.getID() << "', ";
221  out << "parentID='1', ";
222  out << "start='100', ";
223  out << "end='200', ";
224  out << "metaData='{protocol: abc, }')";
225 
226  ASSERT_EQ(out.str(), traceEvent.toString());
227 }
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
HTTPServer::Protocol Protocol
Definition: EchoServer.cpp:27
const char * string
Definition: Conv.cpp:212
TotalRequest
StatsClock::time_point TimePoint
TEST ( TraceEventTest  ,
StringArrayValueToString   
)

Definition at line 229 of file TraceEventTest.cpp.

References proxygen::TraceEvent::addMeta(), ASSERT_EQ, proxygen::TraceEvent::end(), proxygen::TraceEvent::getID(), proxygen::Protocol, proxygen::TraceEvent::start(), proxygen::TraceEvent::toString(), and proxygen::TotalRequest.

229  {
231  traceEvent.start(TimePoint(std::chrono::milliseconds(100)));
232  traceEvent.end(TimePoint(std::chrono::milliseconds(200)));
233  std::vector<std::string> arrData;
234  arrData.push_back("A");
235  arrData.push_back("B");
236  arrData.push_back("C");
237  traceEvent.addMeta(TraceFieldType::Protocol, arrData);
238 
239  std::ostringstream out;
240  out << "TraceEvent(";
241  out << "type='TotalRequest', ";
242  out << "id='" << traceEvent.getID() << "', ";
243  out << "parentID='1', ";
244  out << "start='100', ";
245  out << "end='200', ";
246  out << "metaData='{protocol: [\"A\",\"B\",\"C\"], }')";
247 
248  ASSERT_EQ(out.str(), traceEvent.toString());
249 }
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
HTTPServer::Protocol Protocol
Definition: EchoServer.cpp:27
TotalRequest
StatsClock::time_point TimePoint