]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
TestOSDMap: Test with negative upmap values 23888/head
authorBrad Hubbard <bhubbard@redhat.com>
Fri, 3 Aug 2018 06:42:57 +0000 (16:42 +1000)
committerNathan Cutler <ncutler@suse.com>
Sun, 2 Sep 2018 18:01:06 +0000 (20:01 +0200)
Check we can handle negative pg_upmap and pg_upmap_items values.

Signed-off-by: Brad Hubbard <bhubbard@redhat.com>
(cherry picked from commit f76c889c2cb02539f5c5bdfc7bd5ab8f506bad86)

src/test/osd/TestOSDMap.cc

index b3a982461d55e6e20a55cd93121a0d355a7703ba..1f2df7fe0db2d4b28771b428db01a91403a2cdfe 100644 (file)
@@ -611,6 +611,20 @@ TEST_F(OSDMapTest, CleanPGUpmaps) {
           break;
         }
       }
+      {
+        // Check we can handle a negative pg_upmap value
+        vector<int32_t> 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<int32_t>(
+            new_pg_upmap.begin(), new_pg_upmap.end());
+        osdmap.apply_incremental(pending_inc);
+        vector<int> 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<int32_t> 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<pair<int32_t,int32_t>> 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<pair<int32_t,int32_t>>(
+        new_pg_upmap_items.begin(), new_pg_upmap_items.end());
+      osdmap.apply_incremental(pending_inc);
+      vector<int> 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