Skip to content

Commit

Permalink
RadosModel: assert exists on subsequent writes
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Just <sjust@redhat.com>
  • Loading branch information
athanatos committed May 21, 2015
1 parent c2d17b9 commit 121aa3b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
11 changes: 9 additions & 2 deletions src/test/osd/RadosModel.h
Expand Up @@ -47,6 +47,7 @@ typename T::iterator rand_choose(T &cont) {
enum TestOpType {
TEST_OP_READ,
TEST_OP_WRITE,
TEST_OP_WRITE_EXCL,
TEST_OP_DELETE,
TEST_OP_SNAP_CREATE,
TEST_OP_SNAP_REMOVE,
Expand All @@ -61,7 +62,8 @@ enum TestOpType {
TEST_OP_CACHE_FLUSH,
TEST_OP_CACHE_TRY_FLUSH,
TEST_OP_CACHE_EVICT,
TEST_OP_APPEND
TEST_OP_APPEND,
TEST_OP_APPEND_EXCL
};

class TestWatchContext : public librados::WatchCtx2 {
Expand Down Expand Up @@ -716,14 +718,17 @@ class WriteOp : public TestOp {
bufferlist rbuffer;

bool do_append;
bool do_excl;

WriteOp(int n,
RadosTestContext *context,
const string &oid,
bool do_append,
bool do_excl,
TestOpStat *stat = 0)
: TestOp(n, context, stat),
oid(oid), waiting_on(0), last_acked_tid(0), do_append(do_append)
oid(oid), waiting_on(0), last_acked_tid(0), do_append(do_append),
do_excl(do_excl)
{}

void _begin()
Expand Down Expand Up @@ -795,6 +800,8 @@ class WriteOp : public TestOp {
} else {
op.write(i->first, to_write);
}
if (do_excl && tid == 1)
op.assert_exists();
context->io_ctx.aio_operate(
context->prefix+oid, completion,
&op);
Expand Down
23 changes: 19 additions & 4 deletions src/test/osd/TestRados.cc
Expand Up @@ -55,9 +55,9 @@ class WeightedTestGenerator : public TestOpGenerator
cout << m_op << ": write initial oid " << oid.str() << std::endl;
context.oid_not_flushing.insert(oid.str());
if (m_ec_pool) {
return new WriteOp(m_op, &context, oid.str(), true);
return new WriteOp(m_op, &context, oid.str(), true, true);
} else {
return new WriteOp(m_op, &context, oid.str(), false);
return new WriteOp(m_op, &context, oid.str(), false, true);
}
} else if (m_op >= m_ops) {
return NULL;
Expand Down Expand Up @@ -105,7 +105,14 @@ class WeightedTestGenerator : public TestOpGenerator
oid = *(rand_choose(context.oid_not_in_use));
cout << m_op << ": " << "write oid " << oid << " current snap is "
<< context.current_snap << std::endl;
return new WriteOp(m_op, &context, oid, false, m_stats);
return new WriteOp(m_op, &context, oid, false, false, m_stats);

case TEST_OP_WRITE_EXCL:
oid = *(rand_choose(context.oid_not_in_use));
cout << m_op << ": " << "write (excl) oid "
<< oid << " current snap is "
<< context.current_snap << std::endl;
return new WriteOp(m_op, &context, oid, false, true, m_stats);

case TEST_OP_DELETE:
oid = *(rand_choose(context.oid_not_in_use));
Expand Down Expand Up @@ -206,7 +213,13 @@ class WeightedTestGenerator : public TestOpGenerator
oid = *(rand_choose(context.oid_not_in_use));
cout << "append oid " << oid << " current snap is "
<< context.current_snap << std::endl;
return new WriteOp(m_op, &context, oid, true, m_stats);
return new WriteOp(m_op, &context, oid, true, false, m_stats);

case TEST_OP_APPEND_EXCL:
oid = *(rand_choose(context.oid_not_in_use));
cout << "append oid (excl) " << oid << " current snap is "
<< context.current_snap << std::endl;
return new WriteOp(m_op, &context, oid, true, true, m_stats);

default:
cerr << m_op << ": Invalid op type " << type << std::endl;
Expand Down Expand Up @@ -244,6 +257,7 @@ int main(int argc, char **argv)
} op_types[] = {
{ TEST_OP_READ, "read", true },
{ TEST_OP_WRITE, "write", false },
{ TEST_OP_WRITE_EXCL, "write_excl", false },
{ TEST_OP_DELETE, "delete", true },
{ TEST_OP_SNAP_CREATE, "snap_create", true },
{ TEST_OP_SNAP_REMOVE, "snap_remove", true },
Expand All @@ -259,6 +273,7 @@ int main(int argc, char **argv)
{ TEST_OP_CACHE_TRY_FLUSH, "cache_try_flush", true },
{ TEST_OP_CACHE_EVICT, "cache_evict", true },
{ TEST_OP_APPEND, "append", true },
{ TEST_OP_APPEND_EXCL, "append_excl", true },
{ TEST_OP_READ /* grr */, NULL },
};

Expand Down

0 comments on commit 121aa3b

Please sign in to comment.