]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test_msgr: Random send different priority message to test sequence
authorHaomai Wang <haomaiwang@gmail.com>
Sun, 21 Jun 2015 16:15:22 +0000 (00:15 +0800)
committerHaomai Wang <haomaiwang@gmail.com>
Sun, 21 Jun 2015 16:31:50 +0000 (00:31 +0800)
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
src/test/msgr/test_msgr.cc

index a24e8b53aeaa50bd7f861853b14d61cbbd35566a..43d164d23c7b96efacd1a009d881b4daf7f2b9d4 100644 (file)
@@ -737,6 +737,12 @@ class SyntheticDispatcher : public Dispatcher {
     got_remote_reset = true;
   }
   void ms_fast_dispatch(Message *m) {
+    // MSG_COMMAND is used to disorganize regular message flow
+    if (m->get_type() == MSG_COMMAND) {
+      m->put();
+      return ;
+    }
+
     Mutex::Locker l(lock);
     uint64_t i;
     bool reply;
@@ -938,15 +944,28 @@ class SyntheticWorkload {
   }
 
   void send_message() {
-    Message *m = new MPing();
-    bufferlist bl;
-    boost::uniform_int<> u(0, rand_data.size()-1);
-    uint64_t index = u(rng);
-    bl = rand_data[index];
-    m->set_data(bl);
     Mutex::Locker l(lock);
     ConnectionRef conn = _get_random_connection();
-    dispatcher.send_message_wrap(conn, m);
+    boost::uniform_int<> true_false(0, 99);
+    int val = true_false(rng);
+    if (val >= 95) {
+      uuid_d uuid;
+      uuid.generate_random();
+      MCommand *m = new MCommand(uuid);
+      vector<string> cmds;
+      cmds.push_back("command");
+      m->cmd = cmds;
+      m->set_priority(200);
+      conn->send_message(m);
+    } else {
+      Message *m = new MPing();
+      bufferlist bl;
+      boost::uniform_int<> u(0, rand_data.size()-1);
+      uint64_t index = u(rng);
+      bl = rand_data[index];
+      m->set_data(bl);
+      dispatcher.send_message_wrap(conn, m);
+    }
   }
 
   void drop_connection() {