From fbf3b79cae433a5091ecfa1c6bc2a283e75ec9f9 Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Wed, 18 May 2016 18:49:02 -0700 Subject: [PATCH] test/librados: add test that requires correct dup error detection 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 --- src/test/librados/aio.cc | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/test/librados/aio.cc b/src/test/librados/aio.cc index c196a81e55d9..550e350b2ef6 100644 --- a/src/test/librados/aio.cc +++ b/src/test/librados/aio.cc @@ -96,8 +96,14 @@ public: } std::string init() + { + return init({}); + } + + std::string init(const std::map &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; +} -- 2.47.3