]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: add tests to (un)register and update journal client 7832/head
authorMykola Golub <mgolub@mirantis.com>
Sat, 27 Feb 2016 12:55:44 +0000 (14:55 +0200)
committerMykola Golub <mgolub@mirantis.com>
Sat, 27 Feb 2016 12:59:11 +0000 (14:59 +0200)
Signed-off-by: Mykola Golub <mgolub@mirantis.com>
src/test/journal/test_Journaler.cc

index 1d45bdcc6dfc966d6ab1763b7d2616f365625564..2c33f052ddedc1c75f871f75697ed4f3c313f242 100644 (file)
@@ -42,7 +42,25 @@ public:
     journal::Journaler journaler(m_ioctx, m_journal_id, client_id, 5);
     bufferlist data;
     data.append(desc);
-    return journaler.register_client(data);
+    C_SaferCond cond;
+    journaler.register_client(data, &cond);
+    return cond.wait();
+  }
+
+  int update_client(const std::string &client_id, const std::string &desc) {
+    journal::Journaler journaler(m_ioctx, m_journal_id, client_id, 5);
+    bufferlist data;
+    data.append(desc);
+    C_SaferCond cond;
+    journaler.update_client(data, &cond);
+    return cond.wait();
+  }
+
+  int unregister_client(const std::string &client_id) {
+    journal::Journaler journaler(m_ioctx, m_journal_id, client_id, 5);
+    C_SaferCond cond;
+    journaler.unregister_client(&cond);
+    return cond.wait();
   }
 
   static uint64_t _journal_id;
@@ -80,10 +98,36 @@ TEST_F(TestJournaler, InitDNE) {
 }
 
 TEST_F(TestJournaler, RegisterClientDuplicate) {
+  ASSERT_EQ(0, create_journal(12, 8));
   ASSERT_EQ(0, register_client(CLIENT_ID, "foo"));
   ASSERT_EQ(-EEXIST, register_client(CLIENT_ID, "foo2"));
 }
 
+TEST_F(TestJournaler, UpdateClient) {
+  ASSERT_EQ(0, create_journal(12, 8));
+  ASSERT_EQ(0, register_client(CLIENT_ID, "foo"));
+  ASSERT_EQ(0, update_client(CLIENT_ID, "foo2"));
+}
+
+TEST_F(TestJournaler, UpdateClientDNE) {
+  ASSERT_EQ(0, create_journal(12, 8));
+  ASSERT_EQ(-ENOENT, update_client(CLIENT_ID, "foo"));
+}
+
+TEST_F(TestJournaler, UnregisterClient) {
+  ASSERT_EQ(0, create_journal(12, 8));
+  ASSERT_EQ(0, register_client(CLIENT_ID, "foo"));
+  ASSERT_EQ(0, unregister_client(CLIENT_ID));
+  // Test it does not exist and can be registered again
+  ASSERT_EQ(-ENOENT, update_client(CLIENT_ID, "foo"));
+  ASSERT_EQ(0, register_client(CLIENT_ID, "foo"));
+}
+
+TEST_F(TestJournaler, UnregisterClientDNE) {
+  ASSERT_EQ(0, create_journal(12, 8));
+  ASSERT_EQ(-ENOENT, unregister_client(CLIENT_ID));
+}
+
 TEST_F(TestJournaler, AllocateTag) {
   ASSERT_EQ(0, create_journal(12, 8));