]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Common, log: Added functionality test for recovery after silenced (#20174) 20185/head
authorAdam Kupczyk <akupczyk@redhat.com>
Tue, 30 Jan 2018 14:37:46 +0000 (15:37 +0100)
committerAdam Kupczyk <akupczyk@redhat.com>
Fri, 2 Feb 2018 12:48:52 +0000 (13:48 +0100)
Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
src/log/test.cc

index 73f037191bab610a9cda91aca66a0fae154bddb0..18f3fbdbeda2cec234728e4be170c2bdbbdfe379 100644 (file)
@@ -370,6 +370,30 @@ TEST(Log, Speed_nogather)
   }
 }
 
+TEST(Log, GarbleRecovery)
+{
+  static const char* test_file="/tmp/log_for_moment";
+
+  Log* saved = g_ceph_context->_log;
+  Log log(&g_ceph_context->_conf->subsys);
+  log.start();
+  unlink(test_file);
+  log.set_log_file(test_file);
+  log.reopen_log_file();
+  g_ceph_context->_log = &log;
+
+  std::string long_message(1000,'c');
+  ldout(g_ceph_context, 0) << long_message << dendl;
+  ldout(g_ceph_context, 0) << "Prologue" << (char*)nullptr << long_message << dendl;
+  ldout(g_ceph_context, 0) << "Epitaph" << long_message << dendl;
+
+  g_ceph_context->_log = saved;
+  log.flush();
+  log.stop();
+  struct stat file_status;
+  ASSERT_EQ(lstat(test_file, &file_status), 0);
+  ASSERT_GT(file_status.st_size, 2000);
+}
 
 int main(int argc, char **argv)
 {