]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
src/test: add TierEvictOp to ceph_test_rados
authormyoungwon oh <ohmyoungwon@gmail.com>
Wed, 3 Feb 2021 13:34:49 +0000 (22:34 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Mon, 29 Mar 2021 08:07:09 +0000 (17:07 +0900)
Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
src/test/osd/RadosModel.h
src/test/osd/TestRados.cc

index 7f20d6ff07e2227a15cf302ae956a4dc4cd67096..063bd1a87420f9593268f600c9254cc5b32f4c82 100644 (file)
@@ -65,7 +65,8 @@ enum TestOpType {
   TEST_OP_CHUNK_READ,
   TEST_OP_TIER_PROMOTE,
   TEST_OP_TIER_FLUSH,
-  TEST_OP_SET_CHUNK
+  TEST_OP_SET_CHUNK,
+  TEST_OP_TIER_EVICT
 };
 
 class TestWatchContext : public librados::WatchCtx2 {
@@ -2747,6 +2748,72 @@ public:
   }
 };
 
+class TierEvictOp : public TestOp {
+public:
+  librados::AioCompletion *completion;
+  librados::ObjectReadOperation op;
+  string oid;
+  std::shared_ptr<int> in_use;
+
+  TierEvictOp(int n,
+              RadosTestContext *context,
+              const string &oid,
+              TestOpStat *stat)
+    : TestOp(n, context, stat),
+      completion(NULL),
+      oid(oid)
+  {}
+
+  void _begin() override
+  {
+    context->state_lock.lock();
+
+    pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+      new pair<TestOp*, TestOp::CallbackInfo*>(this,
+                                              new TestOp::CallbackInfo(0));
+    completion = context->rados.aio_create_completion((void *) cb_arg,
+                                                     &write_callback);
+    context->state_lock.unlock();
+
+    op.cache_evict();
+    int r = context->io_ctx.aio_operate(context->prefix+oid, completion,
+                                       &op, librados::OPERATION_IGNORE_CACHE,
+                                       NULL);
+    ceph_assert(!r);
+  }
+
+  void _finish(CallbackInfo *info) override
+  {
+    std::lock_guard state_locker{context->state_lock};
+    ceph_assert(!done);
+    ceph_assert(completion->is_complete());
+
+    int r = completion->get_return_value();
+    cout << num << ":  got " << cpp_strerror(r) << std::endl;
+    if (r == 0) {
+      // ok
+    } else if (r == -EINVAL) {
+      // probably this is not manifest object 
+    } else if (r == -ENOENT) {
+      // may have raced with a remove?
+    } else {
+      ceph_abort_msg("shouldn't happen");
+    }
+    context->kick();
+    done = true;
+  }
+
+  bool finished() override
+  {
+    return done;
+  }
+
+  string getType() override
+  {
+    return "TierEvictOp";
+  }
+};
+
 class HitSetListOp : public TestOp {
   librados::AioCompletion *comp1, *comp2;
   uint32_t hash;
index 53dca91d86c9b2b873f5605c45a9574debf5367d..d06bceafd822ca6b2c11a758856078edd4ef2204 100644 (file)
@@ -459,6 +459,11 @@ private:
        return new SetChunkOp(m_op, &context, oid, rand_offset, rand_length, oid2, rand_offset, m_stats);
       }
 
+    case TEST_OP_TIER_EVICT:
+      oid = *(rand_choose(context.oid_not_in_use));
+      cout << m_op << ": " << "tier_evict oid " << oid << std::endl;
+      return new TierEvictOp(m_op, &context, oid, m_stats);
+
     default:
       cerr << m_op << ": Invalid op type " << type << std::endl;
       ceph_abort();
@@ -525,6 +530,7 @@ int main(int argc, char **argv)
     { TEST_OP_TIER_PROMOTE, "tier_promote", true },
     { TEST_OP_TIER_FLUSH, "tier_flush", true },
     { TEST_OP_SET_CHUNK, "set_chunk", true },
+    { TEST_OP_TIER_EVICT, "tier_evict", true },
     { TEST_OP_READ /* grr */, NULL },
   };