提交 c7037153 编写于 作者: L Lei Jin

attempt to fix auto_roll_logger_test

Summary:
auto_roll_logger_test fails from time to time. I wasn't able to repro
the issue but by looking at the code, it seems like the initial ctime_
value can be set to the boundary of the second so it may still have a
chance to get rolled when interval is set to 1 second.

```
util/auto_roll_logger_test.cc:120: failed: 118 > 708
==19470== Syscall param msync(start) points to unaddressable byte(s)
==19470==    at 0x4E46CE0: __msync_nocancel (in
/usr/local/fbcode/gcc-4.8.1-glibc-2.17/lib/libpthread-2.17.so)
==19470==    by 0x584EFB: access_mem (Ginit.c:137)
==19470==    by 0x5834E3: _ULx86_64_access_reg (libunwind_i.h:162)
==19470==    by 0x585601: apply_reg_state (Gparser.c:742)
==19470==    by 0x5866BE: _ULx86_64_dwarf_find_save_locs (Gparser.c:883)
==19470==    by 0x584550: _ULx86_64_dwarf_step (Gstep.c:34)
==19470==    by 0x583653: _ULx86_64_step (Gstep.c:71)
==19470==    by 0x583FD2: _ULx86_64_tdep_trace (Gtrace.c:217)
==19470==    by 0x5831C3: backtrace (backtrace.c:69)

Test Plan: ./auto_roll_logger_test

Reviewers: sdong, yhchiang, igor

Reviewed By: igor

Subscribers: leveldb

Differential Revision: https://reviews.facebook.net/D21951
上级 c8ecfaed
...@@ -145,13 +145,13 @@ TEST(AutoRollLoggerTest, RollLogFileBySize) { ...@@ -145,13 +145,13 @@ TEST(AutoRollLoggerTest, RollLogFileBySize) {
} }
TEST(AutoRollLoggerTest, RollLogFileByTime) { TEST(AutoRollLoggerTest, RollLogFileByTime) {
size_t time = 1; size_t time = 2;
size_t log_size = 1024 * 5; size_t log_size = 1024 * 5;
InitTestDb(); InitTestDb();
// -- Test the existence of file during the server restart. // -- Test the existence of file during the server restart.
ASSERT_TRUE(!env->FileExists(kLogFile)); ASSERT_TRUE(!env->FileExists(kLogFile));
AutoRollLogger logger(Env::Default(), kTestDir, "", log_size, 1); AutoRollLogger logger(Env::Default(), kTestDir, "", log_size, time);
ASSERT_TRUE(env->FileExists(kLogFile)); ASSERT_TRUE(env->FileExists(kLogFile));
RollLogFileByTimeTest(&logger, time, kSampleMessage + ":RollLogFileByTime"); RollLogFileByTimeTest(&logger, time, kSampleMessage + ":RollLogFileByTime");
...@@ -184,7 +184,7 @@ TEST(AutoRollLoggerTest, ...@@ -184,7 +184,7 @@ TEST(AutoRollLoggerTest,
} }
TEST(AutoRollLoggerTest, CompositeRollByTimeAndSizeLogger) { TEST(AutoRollLoggerTest, CompositeRollByTimeAndSizeLogger) {
size_t time = 1, log_max_size = 1024 * 5; size_t time = 2, log_max_size = 1024 * 5;
InitTestDb(); InitTestDb();
...@@ -222,7 +222,7 @@ TEST(AutoRollLoggerTest, CreateLoggerFromOptions) { ...@@ -222,7 +222,7 @@ TEST(AutoRollLoggerTest, CreateLoggerFromOptions) {
// Only roll by Time // Only roll by Time
InitTestDb(); InitTestDb();
options.max_log_file_size = 0; options.max_log_file_size = 0;
options.log_file_time_to_roll = 1; options.log_file_time_to_roll = 2;
ASSERT_OK(CreateLoggerFromOptions(kTestDir, "", env, options, &logger)); ASSERT_OK(CreateLoggerFromOptions(kTestDir, "", env, options, &logger));
auto_roll_logger = auto_roll_logger =
dynamic_cast<AutoRollLogger*>(logger.get()); dynamic_cast<AutoRollLogger*>(logger.get());
...@@ -233,7 +233,7 @@ TEST(AutoRollLoggerTest, CreateLoggerFromOptions) { ...@@ -233,7 +233,7 @@ TEST(AutoRollLoggerTest, CreateLoggerFromOptions) {
// roll by both Time and size // roll by both Time and size
InitTestDb(); InitTestDb();
options.max_log_file_size = 1024 * 5; options.max_log_file_size = 1024 * 5;
options.log_file_time_to_roll = 1; options.log_file_time_to_roll = 2;
ASSERT_OK(CreateLoggerFromOptions(kTestDir, "", env, options, &logger)); ASSERT_OK(CreateLoggerFromOptions(kTestDir, "", env, options, &logger));
auto_roll_logger = auto_roll_logger =
dynamic_cast<AutoRollLogger*>(logger.get()); dynamic_cast<AutoRollLogger*>(logger.get());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册