]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
TestOSDMap: Test with negative upmap values 23406/head
authorBrad Hubbard <bhubbard@redhat.com>
Fri, 3 Aug 2018 06:42:57 +0000 (16:42 +1000)
committerBrad Hubbard <bhubbard@redhat.com>
Fri, 3 Aug 2018 06:49:47 +0000 (16:49 +1000)
Check we can handle negative pg_upmap and pg_upmap_items values.

Signed-off-by: Brad Hubbard <bhubbard@redhat.com>
src/test/osd/TestOSDMap.cc

index 7e9c2bcddd1052ff46f4122a0c2d63f57d5c34ae..0aab1ff9b5506cb730b73de436ef0e9a5c8afa93 100644 (file)
@@ -612,6 +612,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;
@@ -703,6 +717,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