From: Samuel Just Date: Thu, 21 May 2015 18:36:42 +0000 (-0700) Subject: RadosModel: assert exists on subsequent writes X-Git-Tag: v0.94.3~62^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4cdc5f7d6b3ec488c79c09cb44a43d4d9398b74c;p=ceph.git RadosModel: assert exists on subsequent writes Signed-off-by: Samuel Just (cherry picked from commit 121aa3bc612b86281535ac3bcfe98bc99bc99ace) --- diff --git a/src/test/osd/RadosModel.h b/src/test/osd/RadosModel.h index f9c0f9bc9e4e5..9192c5dd19d2b 100644 --- a/src/test/osd/RadosModel.h +++ b/src/test/osd/RadosModel.h @@ -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, @@ -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 { @@ -716,14 +718,17 @@ public: 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() @@ -795,6 +800,8 @@ public: } 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); diff --git a/src/test/osd/TestRados.cc b/src/test/osd/TestRados.cc index 4d8b45cc486a6..e8eb0db9df053 100644 --- a/src/test/osd/TestRados.cc +++ b/src/test/osd/TestRados.cc @@ -55,9 +55,9 @@ public: 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; @@ -105,7 +105,14 @@ private: 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)); @@ -206,7 +213,13 @@ private: 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; @@ -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 }, @@ -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 }, };