proxygen
|
#include <thread>
#include <folly/Conv.h>
#include <folly/Exception.h>
#include <folly/File.h>
#include <folly/FileUtil.h>
#include <folly/String.h>
#include <folly/Synchronized.h>
#include <folly/experimental/TestUtil.h>
#include <folly/futures/Future.h>
#include <folly/futures/Promise.h>
#include <folly/init/Init.h>
#include <folly/lang/SafeAssert.h>
#include <folly/logging/AsyncFileWriter.h>
#include <folly/logging/Init.h>
#include <folly/logging/LoggerDB.h>
#include <folly/logging/xlog.h>
#include <folly/portability/Config.h>
#include <folly/portability/GFlags.h>
#include <folly/portability/GMock.h>
#include <folly/portability/GTest.h>
#include <folly/portability/Unistd.h>
#include <folly/system/ThreadId.h>
#include <folly/system/ThreadName.h>
#include <folly/test/TestUtils.h>
Go to the source code of this file.
Classes | |
class | ReadStats |
struct | ReadStats::ReaderData |
struct | ReadStats::WriterData |
Functions | |
DEFINE_int64 (async_discard_num_normal_writers, 30,"number of threads to use to generate normal log messages during ""the AsyncFileWriter.discard test") | |
DEFINE_int64 (async_discard_num_nodiscard_writers, 2,"number of threads to use to generate non-discardable log messages during ""the AsyncFileWriter.discard test") | |
DEFINE_int64 (async_discard_read_sleep_usec, 500,"how long the read thread should sleep between reads in ""the AsyncFileWriter.discard test") | |
DEFINE_int64 (async_discard_timeout_msec, 10000,"A timeout for the AsyncFileWriter.discard test if it cannot generate ""enough discards") | |
DEFINE_int64 (async_discard_num_events, 10,"The number of discard events to wait for in the AsyncFileWriter.discard ""test") | |
TEST (AsyncFileWriter, noMessages) | |
TEST (AsyncFileWriter, simpleMessages) | |
TEST (AsyncFileWriter, ioError) | |
TEST (AsyncFileWriter, flush) | |
void | readThread (folly::File &&file, ReadStats *stats) |
void | writeThread (AsyncFileWriter *writer, size_t id, uint32_t flags, ReadStats *readStats) |
TEST (AsyncFileWriter, discard) | |
TEST (AsyncFileWriter, fork) | |
TEST (AsyncFileWriter, crazyForks) | |
Variables | |
static constexpr StringPiece | kMsgSuffix |
DEFINE_int64 | ( | async_discard_num_normal_writers | , |
30 | , | ||
"number of threads to use to generate normal log messages during ""the AsyncFileWriter.discard test" | |||
) |
DEFINE_int64 | ( | async_discard_num_nodiscard_writers | , |
2 | , | ||
"number of threads to use to generate non-discardable log messages during ""the AsyncFileWriter.discard test" | |||
) |
DEFINE_int64 | ( | async_discard_read_sleep_usec | , |
500 | , | ||
"how long the read thread should sleep between reads in ""the AsyncFileWriter.discard test" | |||
) |
DEFINE_int64 | ( | async_discard_timeout_msec | , |
10000 | , | ||
"A timeout for the AsyncFileWriter.discard test if it cannot generate ""enough discards" | |||
) |
DEFINE_int64 | ( | async_discard_num_events | , |
10 | , | ||
"The number of discard events to wait for in the AsyncFileWriter.discard ""test" | |||
) |
void readThread | ( | folly::File && | file, |
ReadStats * | stats | ||
) |
readThread() reads messages slowly from a pipe. This helps test the AsyncFileWriter behavior when I/O is slow.
Definition at line 506 of file AsyncFileWriterTest.cpp.
References buffer(), folly::Range< Iter >::data(), folly::DBG2, folly::test::end(), folly::ERR, ReadStats::getSleepUS(), ReadStats::messageReceived(), folly::Range< const char * >::npos, folly::readNoInt(), ReadStats::trailingData(), and XLOG.
Referenced by TEST().
TEST | ( | AsyncFileWriter | , |
noMessages | |||
) |
Definition at line 75 of file AsyncFileWriterTest.cpp.
References folly::File::fd().
TEST | ( | AsyncFileWriter | , |
simpleMessages | |||
) |
Definition at line 84 of file AsyncFileWriterTest.cpp.
References ASSERT_TRUE, folly::data(), EXPECT_EQ, folly::File::fd(), folly::gen::move, folly::readFile(), string, and folly::fibers::yield().
TEST | ( | AsyncFileWriter | , |
ioError | |||
) |
Definition at line 125 of file AsyncFileWriterTest.cpp.
References folly::checkUnixError(), folly::netops::close(), testing::ContainsRegex(), folly::data(), folly::DBG1, EXPECT_GT, EXPECT_LE, EXPECT_THAT, pipe(), folly::LoggerDB::setInternalWarningHandler(), string, folly::throwSystemError(), folly::writeNoInt(), XLOG, and folly::fibers::yield().
TEST | ( | AsyncFileWriter | , |
flush | |||
) |
Definition at line 215 of file AsyncFileWriterTest.cpp.
References folly::checkUnixError(), EXPECT_EQ, EXPECT_FALSE, folly::Promise< T >::getFuture(), folly::makeTryWith(), folly::gen::move, pipe(), folly::readFull(), folly::Promise< T >::setTry(), and string.
TEST | ( | AsyncFileWriter | , |
discard | |||
) |
Definition at line 583 of file AsyncFileWriterTest.cpp.
References ReadStats::check(), folly::checkUnixError(), ReadStats::clearSleepDuration(), folly::DBG2, folly::DBG4, folly::gen::move, folly::LogWriter::NEVER_DISCARD, pipe(), readThread(), folly::pushmi::detail::t, uint32_t, writeThread(), XLOG, and XLOGF.
TEST | ( | AsyncFileWriter | , |
fork | |||
) |
Test that AsyncFileWriter operates correctly after a fork() in both the parent and child processes.
Definition at line 624 of file AsyncFileWriterTest.cpp.
References ASSERT_EQ, ASSERT_TRUE, folly::checkUnixError(), testing::ContainsRegex(), folly::data(), folly::DBG1, EXPECT_THAT, folly::File::fd(), folly::readFile(), SKIP, stop(), string, folly::pushmi::detail::t, and XLOG.
TEST | ( | AsyncFileWriter | , |
crazyForks | |||
) |
Have several threads concurrently performing fork() calls while several other threads continuously create and destroy AsyncFileWriter objects.
This exercises the synchronization around registration of the AtFork handlers and the creation/destruction of the AsyncFileWriter I/O thread.
Definition at line 726 of file AsyncFileWriterTest.cpp.
References folly::checkUnixError(), folly::DBG3, EXPECT_EQ, folly::File::fd(), folly::getOSThreadID(), i, mutex, folly::setThreadName(), SKIP, stop(), folly::pushmi::detail::t, and XLOG.
void writeThread | ( | AsyncFileWriter * | writer, |
size_t | id, | ||
uint32_t | flags, | ||
ReadStats * | readStats | ||
) |
writeThread() writes a series of messages to the AsyncFileWriter
Definition at line 551 of file AsyncFileWriterTest.cpp.
References kMsgSuffix, ReadStats::shouldWriterStop(), folly::AsyncFileWriter::writeMessage(), and ReadStats::writerFinished().
Referenced by TEST().
|
static |
Definition at line 265 of file AsyncFileWriterTest.cpp.
Referenced by ReadStats::parseMessage(), and writeThread().