From: Nitzan Mordechai Date: Wed, 22 Feb 2023 12:55:16 +0000 (+0000) Subject: test/c_write_operations: set RETURNVEC on expected cmpext failuer X-Git-Tag: v19.0.0~1188^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7fa4f28434ceb2cb8d78aa17de800eb4c589abd5;p=ceph.git test/c_write_operations: set RETURNVEC on expected cmpext failuer We are sending cmpext request that return error and rval error. In order to get reliably rval return for cmpext, we need to set RETURNVEC flag so we record in pg log in case of reconnect during socket injection. without that flag the re-request of the op won't have the rval set and we will end with unmatch error. Fixes: https://tracker.ceph.com/issues/21592 Signed-off-by: Nitzan Mordechai --- diff --git a/src/test/librados/c_write_operations.cc b/src/test/librados/c_write_operations.cc index 558d0942f93f..ca29900114fa 100644 --- a/src/test/librados/c_write_operations.cc +++ b/src/test/librados/c_write_operations.cc @@ -258,16 +258,30 @@ TEST(LibRadosCWriteOps, CmpExt) { ASSERT_EQ(sizeof(hi), static_cast(rados_read(ioctx, "test", hi, sizeof(hi), 0))); ASSERT_EQ(0, memcmp("five", hi, sizeof(hi))); - // compare and bail before write due to mismatch - val = 0; + // Check offset return error value op = rados_create_write_op(); ASSERT_TRUE(op); rados_write_op_cmpext(op, "four", 4, 0, &val); rados_write_op_write(op, "six ", 4, 0); - ASSERT_EQ(-MAX_ERRNO - 1, rados_write_op_operate(op, ioctx, "test", NULL, 0)); + ASSERT_EQ(-MAX_ERRNO - 1, rados_write_op_operate(op, ioctx, "test", NULL, + LIBRADOS_OPERATION_RETURNVEC)); ASSERT_EQ(-MAX_ERRNO - 1, val); - + + // compare and bail before write due to mismatch + // do it 1000 times to make sure we are hitting + // some socket injection + for (auto i = 0; i < 1000; ++i) { + val = 0; + op = rados_create_write_op(); + ASSERT_TRUE(op); + rados_write_op_cmpext(op, "four", 4, 0, &val); + rados_write_op_write(op, "six ", 4, 0); + std::string const s = "test_" + std::to_string(i); + ASSERT_EQ(-MAX_ERRNO , rados_write_op_operate(op, ioctx, s.c_str(), NULL, + LIBRADOS_OPERATION_RETURNVEC)); + ASSERT_EQ(-MAX_ERRNO , val); + } // cleanup op = rados_create_write_op(); ASSERT_TRUE(op);