From 7690f72dfa649da90276ede1907b84862b3b1e98 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Wed, 27 Oct 2021 18:58:52 +0300 Subject: [PATCH] test/store_test: add a UT for omap format upgrade. Signed-off-by: Igor Fedotov (cherry picked from commit ccb6fdf3b6ba700da1efea597deabe79329a4504) --- src/test/objectstore/store_test.cc | 72 ++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index 0ef0d75e09b09..ebb8ee0e1b313 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -37,6 +37,7 @@ #include "common/ceph_mutex.h" #include "common/Cond.h" #include "common/errno.h" +#include "common/pretty_binary.h" #include "include/stringify.h" #include "include/coredumpctl.h" @@ -9390,6 +9391,77 @@ TEST_P(StoreTestSpecificAUSize, Ticket45195Repro) { ASSERT_EQ(r, 0x10000); } +TEST_P(StoreTestSpecificAUSize, OmapUpgradeTest) { + if (string(GetParam()) != "bluestore") + return; + + SetVal(g_conf(), "bluestore_debug_legacy_omap", "true"); + g_conf().apply_changes(nullptr); + + StartDeferred(0x1000); + int64_t poolid = 11; + coll_t cid(spg_t(pg_t(1, poolid), shard_id_t::NO_SHARD)); + ghobject_t hoid(hobject_t("tesomap", "", CEPH_NOSNAP, 0, poolid, "")); + auto ch = store->create_new_collection(cid); + int r; + { + ObjectStore::Transaction t; + t.create_collection(cid, 0); + r = queue_transaction(store, ch, std::move(t)); + ASSERT_EQ(r, 0); + } + + map attrs; + bufferlist expected_header; + expected_header.append("this is a header"); + { + ObjectStore::Transaction t; + t.touch(cid, hoid); + bufferlist header; + header.append(expected_header); + t.omap_setheader(cid, hoid, header); + map start_set; + bufferlist bl; + bl.append(string("value")); + start_set.emplace(string("key1"), bl); + t.omap_setkeys(cid, hoid, start_set); + r = queue_transaction(store, ch, std::move(t)); + } + { + map res; + bufferlist h; + r = store->omap_get(ch, hoid, &h, &res); + ASSERT_EQ(r, 0); + ASSERT_TRUE(bl_eq(h, expected_header)); + ASSERT_EQ(res.size(), 1); + ASSERT_EQ(res.begin()->first, "key1"); + } + store->umount(); + ASSERT_EQ(store->fsck(false), 0); + SetVal(g_conf(), "bluestore_debug_legacy_omap", "false"); + SetVal(g_conf(), "bluestore_fsck_error_on_no_per_pool_omap", "true"); + g_conf().apply_changes(nullptr); + ASSERT_EQ(store->fsck(false), 2); + ASSERT_EQ(store->quick_fix(), 0); + store->mount(); + ch = store->open_collection(cid); + { + map res; + bufferlist h; + r = store->omap_get(ch, hoid, &h, &res); + ASSERT_EQ(r, 0); + ASSERT_EQ(res.size(), 1); + ASSERT_EQ(res.begin()->first, "key1"); + } + { + ObjectStore::Transaction t; + t.remove(cid, hoid); + t.remove_collection(cid); + r = queue_transaction(store, ch, std::move(t)); + ASSERT_EQ(r, 0); + } +} + #endif // WITH_BLUESTORE int main(int argc, char **argv) { -- 2.39.5