From: myoungwon oh Date: Fri, 30 Jul 2021 10:34:02 +0000 (+0900) Subject: test: fix wrong alarm X-Git-Tag: v16.2.8~86^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4394781bfbf882fd96f7d7445b7a885d8a523c9f;p=ceph.git test: fix wrong alarm This is not a serious bug. Please look over the following scenario in HitSetWrite test: 1. append object, which causes to add the object to the hitset 2. call hit_set_get to get the object accessed recently 3. see the hitset to check that appened object is in the hitset After step 2, assert occurs because plpg_on_pool_change, which invokes hit_set_clear, is called between step 1 and step 2. So, the object this unit test want to add to the hitset is not in the hitset sometime. To avoid this, this commit adds retry logic. Fixes: https://tracker.ceph.com/issues/45423 Signed-off-by: Myoungwon Oh (cherry picked from commit 9a020694d43628a16e31f2e051088da5d98553e8) --- diff --git a/src/test/librados/tier_cxx.cc b/src/test/librados/tier_cxx.cc index 51e3b3aa9c7..8f1473fe089 100644 --- a/src/test/librados/tier_cxx.cc +++ b/src/test/librados/tier_cxx.cc @@ -2544,56 +2544,31 @@ static int _get_pg_num(Rados& cluster, string pool_name) return -1; } -TEST_F(LibRadosTwoPoolsPP, HitSetWrite) { - int num_pg = _get_pg_num(cluster, pool_name); - ceph_assert(num_pg > 0); - - // make it a tier - bufferlist inbl; - ASSERT_EQ(0, cluster.mon_command( - "{\"prefix\": \"osd tier add\", \"pool\": \"" + pool_name + - "\", \"tierpool\": \"" + cache_pool_name + - "\", \"force_nonempty\": \"--force-nonempty\" }", - inbl, NULL, NULL)); - - // enable hitset tracking for this pool - ASSERT_EQ(0, cluster.mon_command(set_pool_str(cache_pool_name, "hit_set_count", 8), - inbl, NULL, NULL)); - ASSERT_EQ(0, cluster.mon_command(set_pool_str(cache_pool_name, "hit_set_period", 600), - inbl, NULL, NULL)); - ASSERT_EQ(0, cluster.mon_command(set_pool_str(cache_pool_name, "hit_set_type", - "explicit_hash"), - inbl, NULL, NULL)); - - // wait for maps to settle - cluster.wait_for_latest_osdmap(); - - cache_ioctx.set_namespace(""); - - int num = 200; - +int make_hitset(Rados& cluster, librados::IoCtx& cache_ioctx, int num_pg, + int num, std::map& hitsets, std::string& cache_pool_name) +{ + int pg = num_pg; // do a bunch of writes for (int i=0; i hitsets; - for (int i=0; i > ls; AioCompletion *c = librados::Rados::aio_create_completion(); - ASSERT_EQ(0, cache_ioctx.hit_set_list(i, c, &ls)); + ceph_assert(0 == cache_ioctx.hit_set_list(i, c, &ls)); c->wait_for_complete(); c->release(); std::cout << "pg " << i << " ls " << ls << std::endl; - ASSERT_FALSE(ls.empty()); + ceph_assert(!ls.empty()); // get the latest c = librados::Rados::aio_create_completion(); bufferlist bl; - ASSERT_EQ(0, cache_ioctx.hit_set_get(i, c, ls.back().first, &bl)); + ceph_assert(0 == cache_ioctx.hit_set_get(i, c, ls.back().first, &bl)); c->wait_for_complete(); c->release(); @@ -2609,9 +2584,45 @@ TEST_F(LibRadosTwoPoolsPP, HitSetWrite) { } // cope with racing splits by refreshing pg_num - if (i == num_pg - 1) - num_pg = _get_pg_num(cluster, cache_pool_name); + if (i == pg - 1) + pg = _get_pg_num(cluster, cache_pool_name); } + return pg; +} + +TEST_F(LibRadosTwoPoolsPP, HitSetWrite) { + int num_pg = _get_pg_num(cluster, pool_name); + ceph_assert(num_pg > 0); + + // make it a tier + bufferlist inbl; + ASSERT_EQ(0, cluster.mon_command( + "{\"prefix\": \"osd tier add\", \"pool\": \"" + pool_name + + "\", \"tierpool\": \"" + cache_pool_name + + "\", \"force_nonempty\": \"--force-nonempty\" }", + inbl, NULL, NULL)); + + // enable hitset tracking for this pool + ASSERT_EQ(0, cluster.mon_command(set_pool_str(cache_pool_name, "hit_set_count", 8), + inbl, NULL, NULL)); + ASSERT_EQ(0, cluster.mon_command(set_pool_str(cache_pool_name, "hit_set_period", 600), + inbl, NULL, NULL)); + ASSERT_EQ(0, cluster.mon_command(set_pool_str(cache_pool_name, "hit_set_type", + "explicit_hash"), + inbl, NULL, NULL)); + + // wait for maps to settle + cluster.wait_for_latest_osdmap(); + + cache_ioctx.set_namespace(""); + + int num = 200; + + std::map hitsets; + + num_pg = make_hitset(cluster, cache_ioctx, num_pg, num, hitsets, cache_pool_name); + + int retry = 0; for (int i=0; i