]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/librados: add test that requires correct dup error detection
authorJosh Durgin <jdurgin@redhat.com>
Thu, 19 May 2016 01:49:02 +0000 (18:49 -0700)
committerJosh Durgin <jdurgin@redhat.com>
Sat, 9 Jul 2016 01:33:14 +0000 (18:33 -0700)
This only works reliably with the
objecter_retry_writes_after_first_reply setting, so make it part of
the test setup.

Signed-off-by: Josh Durgin <jdurgin@redhat.com>
src/test/librados/aio.cc

index c196a81e55d9ce7c53a5078b904633cd8b6a5c33..550e350b2ef6c263930535dc0695a822a8bd5c0b 100644 (file)
@@ -96,8 +96,14 @@ public:
   }
 
   std::string init()
+  {
+      return init({});
+  }
+
+  std::string init(const std::map<std::string, std::string> &config)
   {
     int ret;
+
     if (SEM_FAILED == (m_sem = sem_open("/test_aio_sem", O_CREAT, 0644, 0))) {
       int err = errno;
       ostringstream oss;
@@ -105,7 +111,7 @@ public:
       return oss.str();
     }
     m_pool_name = get_temp_pool_name();
-    std::string err = create_one_pool_pp(m_pool_name, m_cluster);
+    std::string err = create_one_pool_pp(m_pool_name, m_cluster, config);
     if (!err.empty()) {
       sem_close(m_sem);
       ostringstream oss;
@@ -3389,3 +3395,33 @@ TEST(LibRadosAioEC, MultiWritePP) {
   delete my_completion2;
   delete my_completion3;
 }
+
+TEST(LibRadosAio, RacingRemovePP) {
+  AioTestDataPP test_data;
+  ASSERT_EQ("", test_data.init({{"objecter_retry_writes_after_first_reply", "true"}}));
+  AioCompletion *my_completion = test_data.m_cluster.aio_create_completion(
+        (void*)&test_data, set_completion_complete, set_completion_safe);
+  ASSERT_NE(my_completion, nullptr);
+  char buf[128];
+  memset(buf, 0xcc, sizeof(buf));
+  bufferlist bl;
+  bl.append(buf, sizeof(buf));
+  AioCompletion *my_completion2 = test_data.m_cluster.aio_create_completion(
+        (void*)&test_data, set_completion_complete, set_completion_safe);
+  ASSERT_NE(my_completion2, nullptr);
+  ASSERT_EQ(0, test_data.m_ioctx.aio_remove("foo", my_completion2));
+  ASSERT_EQ(0, test_data.m_ioctx.aio_write("foo", my_completion,
+                                         bl, sizeof(buf), 0));
+  {
+    TestAlarm alarm;
+    sem_wait(test_data.m_sem);
+    sem_wait(test_data.m_sem);
+    my_completion2->wait_for_complete();
+    my_completion->wait_for_complete();
+  }
+  ASSERT_EQ(-ENOENT, my_completion2->get_return_value());
+  ASSERT_EQ(0, my_completion->get_return_value());
+  ASSERT_EQ(0, test_data.m_ioctx.stat("foo", nullptr, nullptr));
+  delete my_completion;
+  delete my_completion2;
+}