From: Brad Hubbard Date: Fri, 3 Aug 2018 06:42:57 +0000 (+1000) Subject: TestOSDMap: Test with negative upmap values X-Git-Tag: v13.2.2~34^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F23888%2Fhead;p=ceph.git TestOSDMap: Test with negative upmap values Check we can handle negative pg_upmap and pg_upmap_items values. Signed-off-by: Brad Hubbard (cherry picked from commit f76c889c2cb02539f5c5bdfc7bd5ab8f506bad86) --- diff --git a/src/test/osd/TestOSDMap.cc b/src/test/osd/TestOSDMap.cc index b3a982461d55..1f2df7fe0db2 100644 --- a/src/test/osd/TestOSDMap.cc +++ b/src/test/osd/TestOSDMap.cc @@ -611,6 +611,20 @@ TEST_F(OSDMapTest, CleanPGUpmaps) { break; } } + { + // Check we can handle a negative pg_upmap value + vector new_pg_upmap; + new_pg_upmap.push_back(up[0]); + new_pg_upmap.push_back(-823648512); + OSDMap::Incremental pending_inc(osdmap.get_epoch() + 1); + pending_inc.new_pg_upmap[pgid] = mempool::osdmap::vector( + new_pg_upmap.begin(), new_pg_upmap.end()); + osdmap.apply_incremental(pending_inc); + vector new_up; + int new_up_primary; + // crucial call - _apply_upmap should ignore the negative value + osdmap.pg_to_raw_up(pgid, &new_up, &new_up_primary); + } ASSERT_NE(-1, replaced_by); // generate a new pg_upmap item and apply vector new_pg_upmap; @@ -702,6 +716,23 @@ TEST_F(OSDMapTest, CleanPGUpmaps) { ASSERT_TRUE(!candidate_children.empty()); up_after_out = new_up; // needed for verification.. } + { + // Make sure we can handle a negative pg_upmap_item + int victim = up[0]; + int replaced_by = -823648512; + vector> new_pg_upmap_items; + new_pg_upmap_items.push_back(make_pair(victim, replaced_by)); + // apply + OSDMap::Incremental pending_inc(osdmap.get_epoch() + 1); + pending_inc.new_pg_upmap_items[pgid] = + mempool::osdmap::vector>( + new_pg_upmap_items.begin(), new_pg_upmap_items.end()); + osdmap.apply_incremental(pending_inc); + vector new_up; + int new_up_primary; + // crucial call - _apply_upmap should ignore the negative value + osdmap.pg_to_raw_up(pgid, &new_up, &new_up_primary); + } { // STEP-2: generating a new pg_upmap_items entry by // replacing up[0] with one coming from candidate_children