]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/c_write_operations: set RETURNVEC on expected cmpext failuer 50210/head
authorNitzan Mordechai <nmordech@redhat.com>
Wed, 22 Feb 2023 12:55:16 +0000 (12:55 +0000)
committerNitzan Mordechai <nmordech@redhat.com>
Mon, 24 Apr 2023 07:48:49 +0000 (07:48 +0000)
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 <nmordec@redhat.com>
src/test/librados/c_write_operations.cc

index 558d0942f93f12181a1a88de7ebcb8289535fe9a..ca29900114fa2e97a9846e36a9523484bbabd04e 100644 (file)
@@ -258,16 +258,30 @@ TEST(LibRadosCWriteOps, CmpExt) {
   ASSERT_EQ(sizeof(hi), static_cast<std::size_t>(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);