From 67efb7af48a64bc2e59e73763d75c08de840b33f Mon Sep 17 00:00:00 2001 From: myoungwon oh Date: Tue, 13 Jul 2021 18:56:25 +0900 Subject: [PATCH] test: add test case to verify idempotent op Signed-off-by: Myoungwon Oh --- src/test/librados/tier_cxx.cc | 101 ++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/src/test/librados/tier_cxx.cc b/src/test/librados/tier_cxx.cc index ff87975ad3c60b..dee0f884ebe9f3 100644 --- a/src/test/librados/tier_cxx.cc +++ b/src/test/librados/tier_cxx.cc @@ -6179,6 +6179,107 @@ TEST_F(LibRadosTwoPoolsPP, ManifestEvictRollback) { is_intended_refcount_state(ioctx, "foo", cache_ioctx, "chunk2", 1); } +TEST_F(LibRadosTwoPoolsPP, ManifestIdempotentCount) { + // skip test if not yet octopus + if (_get_required_osd_release(cluster) < "pacific") { + cout << "cluster is not yet pacific, skipping test" << std::endl; + return; + } + + // create object + { + bufferlist bl; + bl.append("there hiHI"); + ObjectWriteOperation op; + op.write_full(bl); + ASSERT_EQ(0, cache_ioctx.operate("chunk1", &op)); + } + { + bufferlist bl; + bl.append("there hiHI"); + ObjectWriteOperation op; + op.write_full(bl); + ASSERT_EQ(0, cache_ioctx.operate("chunk4", &op)); + } + + // wait for maps to settle + cluster.wait_for_latest_osdmap(); + + { + hobject_t ref; + ref.oid.name = "boo"; + auto op = new librados::ObjectWriteOperation(); + cls_cas_chunk_get_ref(*op, ref, 3); + ASSERT_EQ(0, cache_ioctx.operate("chunk4", op)); + } + { + hobject_t ref; + ref.oid.name = "boo"; + auto op = new librados::ObjectWriteOperation(); + cls_cas_chunk_get_ref(*op, ref, 3); + ASSERT_EQ(0, cache_ioctx.operate("chunk4", op)); + } + + { + bufferlist t; + cache_ioctx.getxattr("chunk4", CHUNK_REFCOUNT_ATTR, t); + chunk_refs_t refs; + try { + auto iter = t.cbegin(); + decode(refs, iter); + } catch (buffer::error& err) { + ASSERT_TRUE(0); + } + ASSERT_EQ(3u, refs.count()); + } + { + hobject_t ref; + ref.oid.name = "boo"; + bufferlist bl; + auto op = new librados::ObjectWriteOperation(); + cls_cas_chunk_create_or_get_ref(*op, ref, bl, false, 3); + ASSERT_EQ(0, cache_ioctx.operate("chunk4", op)); + } + { + bufferlist t; + cache_ioctx.getxattr("chunk4", CHUNK_REFCOUNT_ATTR, t); + chunk_refs_t refs; + try { + auto iter = t.cbegin(); + decode(refs, iter); + } catch (buffer::error& err) { + ASSERT_TRUE(0); + } + ASSERT_EQ(3u, refs.count()); + } + { + hobject_t ref; + ref.oid.name = "boo"; + auto op = new librados::ObjectWriteOperation(); + cls_cas_chunk_put_ref(*op, ref, 2); + ASSERT_EQ(0, cache_ioctx.operate("chunk4", op)); + } + { + hobject_t ref; + ref.oid.name = "boo"; + auto op = new librados::ObjectWriteOperation(); + cls_cas_chunk_put_ref(*op, ref, 2); + ASSERT_EQ(0, cache_ioctx.operate("chunk4", op)); + } + { + bufferlist t; + cache_ioctx.getxattr("chunk4", CHUNK_REFCOUNT_ATTR, t); + chunk_refs_t refs; + try { + auto iter = t.cbegin(); + decode(refs, iter); + } catch (buffer::error& err) { + ASSERT_TRUE(0); + } + ASSERT_EQ(2u, refs.count()); + } +} + class LibRadosTwoPoolsECPP : public RadosTestECPP { public: