mirror of
https://github.com/ceph/ceph
synced 2025-01-19 17:41:39 +00:00
src/test: add a test op (TierPromoteOp)
Signed-off-by: Myoungwon Oh <omwmw@sk.com>
This commit is contained in:
parent
fae84218a0
commit
14765eace9
@ -67,7 +67,8 @@ enum TestOpType {
|
||||
TEST_OP_APPEND_EXCL,
|
||||
TEST_OP_SET_REDIRECT,
|
||||
TEST_OP_UNSET_REDIRECT,
|
||||
TEST_OP_CHUNK_READ
|
||||
TEST_OP_CHUNK_READ,
|
||||
TEST_OP_TIER_PROMOTE
|
||||
};
|
||||
|
||||
class TestWatchContext : public librados::WatchCtx2 {
|
||||
@ -2533,6 +2534,77 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class TierPromoteOp : public TestOp {
|
||||
public:
|
||||
librados::AioCompletion *completion;
|
||||
librados::ObjectWriteOperation op;
|
||||
string oid;
|
||||
ceph::shared_ptr<int> in_use;
|
||||
|
||||
TierPromoteOp(int n,
|
||||
RadosTestContext *context,
|
||||
const string &oid,
|
||||
TestOpStat *stat)
|
||||
: TestOp(n, context, stat),
|
||||
completion(NULL),
|
||||
oid(oid)
|
||||
{}
|
||||
|
||||
void _begin() override
|
||||
{
|
||||
context->state_lock.Lock();
|
||||
|
||||
context->oid_in_use.insert(oid);
|
||||
context->oid_not_in_use.erase(oid);
|
||||
|
||||
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, NULL,
|
||||
&write_callback);
|
||||
context->state_lock.Unlock();
|
||||
|
||||
op.tier_promote();
|
||||
int r = context->io_ctx.aio_operate(context->prefix+oid, completion,
|
||||
&op);
|
||||
assert(!r);
|
||||
}
|
||||
|
||||
void _finish(CallbackInfo *info) override
|
||||
{
|
||||
context->state_lock.Lock();
|
||||
assert(!done);
|
||||
assert(completion->is_complete());
|
||||
|
||||
ObjectDesc oid_value;
|
||||
context->find_object(oid, &oid_value);
|
||||
int r = completion->get_return_value();
|
||||
cout << num << ": got " << cpp_strerror(r) << std::endl;
|
||||
if (r == 0) {
|
||||
// sucess
|
||||
} else {
|
||||
assert(0 == "shouldn't happen");
|
||||
}
|
||||
context->update_object_version(oid, completion->get_version64());
|
||||
context->find_object(oid, &oid_value);
|
||||
context->oid_in_use.erase(oid);
|
||||
context->oid_not_in_use.insert(oid);
|
||||
context->kick();
|
||||
done = true;
|
||||
context->state_lock.Unlock();
|
||||
}
|
||||
|
||||
bool finished() override
|
||||
{
|
||||
return done;
|
||||
}
|
||||
|
||||
string getType() override
|
||||
{
|
||||
return "TierPromoteOp";
|
||||
}
|
||||
};
|
||||
|
||||
class HitSetListOp : public TestOp {
|
||||
librados::AioCompletion *comp1, *comp2;
|
||||
uint32_t hash;
|
||||
|
@ -391,6 +391,11 @@ private:
|
||||
cout << m_op << ": " << "chunk read oid " << oid << " target oid " << oid2 << std::endl;
|
||||
return new ChunkReadOp(m_op, &context, oid, context.pool_name, false, m_stats);
|
||||
|
||||
case TEST_OP_TIER_PROMOTE:
|
||||
oid = *(rand_choose(context.oid_not_in_use));
|
||||
cout << m_op << ": " << "tier_promote oid " << oid << std::endl;
|
||||
return new TierPromoteOp(m_op, &context, oid, m_stats);
|
||||
|
||||
case TEST_OP_SET_REDIRECT:
|
||||
oid = *(rand_choose(context.oid_not_in_use));
|
||||
oid2 = *(rand_choose(context.oid_redirect_not_in_use));
|
||||
@ -465,6 +470,7 @@ int main(int argc, char **argv)
|
||||
{ TEST_OP_SET_REDIRECT, "set_redirect", true },
|
||||
{ TEST_OP_UNSET_REDIRECT, "unset_redirect", true },
|
||||
{ TEST_OP_CHUNK_READ, "chunk_read", true },
|
||||
{ TEST_OP_TIER_PROMOTE, "tier_promote", true },
|
||||
{ TEST_OP_READ /* grr */, NULL },
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user