]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add encoding tests for MonitorDBStore data types
authorSage Weil <sage@inktank.com>
Fri, 12 Jul 2013 02:06:47 +0000 (19:06 -0700)
committerSage Weil <sage@inktank.com>
Fri, 12 Jul 2013 16:48:39 +0000 (09:48 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/MonitorDBStore.h
src/test/encoding/types.h

index 60a648de19b1b9af40c40ed7e6cf8905264ecd7e..276620f75164d21b1f83484e69d73b95ce130ef7 100644 (file)
@@ -69,6 +69,19 @@ class MonitorDBStore
        ::decode(endkey, decode_bl);
       DECODE_FINISH(decode_bl);
     }
+
+    void dump(Formatter *f) const {
+      f->dump_int("type", type);
+      f->dump_string("prefix", prefix);
+      f->dump_string("key", key);
+      if (endkey.length())
+       f->dump_string("endkey", endkey);
+    }
+
+    static void generate_test_instances(list<Op*>& ls) {
+      ls.push_back(new Op);
+      // we get coverage here from the Transaction instances
+    }
   };
 
   struct Transaction {
@@ -126,6 +139,17 @@ class MonitorDBStore
       DECODE_FINISH(bl);
     }
 
+    static void generate_test_instances(list<Transaction*>& ls) {
+      ls.push_back(new Transaction);
+      ls.push_back(new Transaction);
+      bufferlist bl;
+      bl.append("value");
+      ls.back()->put("prefix", "key", bl);
+      ls.back()->erase("prefix2", "key2");
+      ls.back()->compact_prefix("prefix3");
+      ls.back()->compact_range("prefix4", "from", "to");
+    }
+
     void append(Transaction& other) {
       ops.splice(ops.end(), other.ops);
     }
index 142f732ab164154684e8930d8f787280be0f4b3a..7c927dc9734c9b631d1e5558af13a1acb2097329 100644 (file)
@@ -79,6 +79,10 @@ TYPE(AuthMonitor::Incremental)
 TYPE(PGMap::Incremental)
 TYPE(PGMap)
 
+#include "mon/MonitorDBStore.h"
+TYPE(MonitorDBStore::Transaction)
+TYPE(MonitorDBStore::Op)
+
 #include "mon/MonMap.h"
 TYPE_FEATUREFUL(MonMap)