]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
TestMsgr: Add inject error tests for lossless_peer_reuse policy
authorHaomai Wang <haomaiwang@gmail.com>
Wed, 25 Feb 2015 07:16:27 +0000 (15:16 +0800)
committerHaomai Wang <haomaiwang@gmail.com>
Wed, 25 Feb 2015 15:43:43 +0000 (23:43 +0800)
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
src/test/msgr/test_msgr.cc

index 68ef3f4c826e2c256490cc4e637a510d5955a834..2f7b9a142578d78a1853a65cdd8ef7b595d24961 100644 (file)
@@ -1032,6 +1032,39 @@ TEST_P(MessengerTest, SyntheticInjectTest) {
   g_ceph_context->_conf->set_val("ms_inject_internal_delays", "0");
 }
 
+TEST_P(MessengerTest, SyntheticInjectTest2) {
+  g_ceph_context->_conf->set_val("ms_inject_socket_failures", "30");
+  g_ceph_context->_conf->set_val("ms_inject_internal_delays", "0.1");
+  SyntheticWorkload test_msg(4, 16, GetParam(), 100,
+                             Messenger::Policy::lossless_peer_reuse(0, 0),
+                             Messenger::Policy::lossless_peer_reuse(0, 0));
+  for (int i = 0; i < 100; ++i) {
+    if (!(i % 10)) cerr << "seeding connection " << i << std::endl;
+    test_msg.generate_connection();
+  }
+  gen_type rng(time(NULL));
+  for (int i = 0; i < 1000; ++i) {
+    if (!(i % 10)) {
+      cerr << "Op " << i << ": ";
+      test_msg.print_internal_state();
+    }
+    boost::uniform_int<> true_false(0, 99);
+    int val = true_false(rng);
+    if (val > 90) {
+      test_msg.generate_connection();
+    } else if (val > 80) {
+      test_msg.drop_connection();
+    } else if (val > 10) {
+      test_msg.send_message();
+    } else {
+      usleep(rand() % 500 + 100);
+    }
+  }
+  test_msg.wait_for_done();
+  g_ceph_context->_conf->set_val("ms_inject_socket_failures", "0");
+  g_ceph_context->_conf->set_val("ms_inject_internal_delays", "0");
+}
+
 
 class MarkdownDispatcher : public Dispatcher {
   Mutex lock;