]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test: add replica pool support to ceph_test_rados_io_sequence
authorBill Scales <bill_scales@uk.ibm.com>
Wed, 9 Apr 2025 09:58:15 +0000 (10:58 +0100)
committerJon Bailey <jonathan.bailey1@ibm.com>
Sun, 7 Sep 2025 09:27:36 +0000 (10:27 +0100)
Make 'ceph_test_rados_io_sequenece --pool rbd' work, replica
pools don't have an erausre code profile and do not have the
ec_allow_overwrites or ec_allow_optimizations flags

Fixes: https://tracker.ceph.com/issues/70844
Signed-off-by: Bill Scales <bill_scales@uk.ibm.com>
Signed-off-by: Jon Bailey <jonathan.bailey1@ibm.com>
src/common/io_exerciser/RadosIo.cc
src/common/io_exerciser/RadosIo.h
src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.cc
src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.h

index 985101170a38062c3f25d752db2fdd0523f9b98a..468b454273e196eb42558bae0ffc2d3303685ac3 100644 (file)
@@ -46,14 +46,14 @@ RadosIo::RadosIo(librados::Rados& rados, boost::asio::io_context& asio,
                  const std::string& pool, const std::string& oid,
                  const std::optional<std::vector<int>>& cached_shard_order,
                  uint64_t block_size, int seed, int threads, ceph::mutex& lock,
-                 ceph::condition_variable& cond, bool ec_optimizations)
+                 ceph::condition_variable& cond, bool is_replicated_pool,
+                 bool ec_optimizations)
     : Model(oid, block_size),
       rados(rados),
       asio(asio),
       om(std::make_unique<ObjectModel>(oid, block_size, seed)),
       db(data_generation::DataGenerator::create_generator(
           data_generation::GenerationType::HeaderedSeededRandom, *om)),
-      cc(std::make_unique<ConsistencyChecker>(rados, asio, pool)),
       pool(pool),
       cached_shard_order(cached_shard_order),
       threads(threads),
@@ -63,6 +63,9 @@ RadosIo::RadosIo(librados::Rados& rados, boost::asio::io_context& asio,
   int rc;
   rc = rados.ioctx_create(pool.c_str(), io);
   ceph_assert(rc == 0);
+  if (!is_replicated_pool) {
+    cc = std::make_unique<ConsistencyChecker>(rados, asio, pool);
+  }
 }
 
 RadosIo::~RadosIo() {}
index f3dc0beac19de3aff26b71003b065089eeb7a5b6..ef43ad4317d8241a2a2efc4830e9fffa956d6e96 100644 (file)
@@ -48,7 +48,8 @@ class RadosIo : public Model {
           const std::string& pool, const std::string& oid,
           const std::optional<std::vector<int>>& cached_shard_order,
           uint64_t block_size, int seed, int threads, ceph::mutex& lock,
-          ceph::condition_variable& cond, bool ec_optimizations);
+          ceph::condition_variable& cond, bool is_replicated_pool,
+          bool ec_optimizations);
 
   ~RadosIo();
 
index 0526527be0ab0a269693841ab5a97aebcefa5bde..2d31bf872b602741e0feb59d0a08f04b5d802ba8 100644 (file)
@@ -134,7 +134,7 @@ constexpr std::string_view usage[] = {
     "ceph_test_rados_io_sequence --blocksize <b> --pool <p> --object <oid>",
     "                            --objectsize <min,max> --threads <t>",
     "\tCustomize the test, if a pool is specified then it defines the",
-    "\tReplica/EC configuration",
+    "\tReplicated/EC configuration",
     "",
     "ceph_test_rados_io_sequence --listsequence",
     "\t Display list of supported I/O sequences",
@@ -793,6 +793,7 @@ ceph::io_sequence::tester::SelectErasurePool::SelectErasurePool(
     bool allow_pool_balancer,
     bool allow_pool_deep_scrubbing,
     bool allow_pool_scrubbing,
+    bool check_consistency,
     bool test_recovery,
     bool allow_pool_ec_optimizations)
     : ProgramOptionReader<std::string>(vm, "pool"),
@@ -802,6 +803,7 @@ ceph::io_sequence::tester::SelectErasurePool::SelectErasurePool(
       allow_pool_balancer(allow_pool_balancer),
       allow_pool_deep_scrubbing(allow_pool_deep_scrubbing),
       allow_pool_scrubbing(allow_pool_scrubbing),
+      check_consistency(check_consistency),
       test_recovery(test_recovery),
       allow_pool_ec_optimizations(allow_pool_ec_optimizations),
       first_use(true),
@@ -844,18 +846,32 @@ const std::string ceph::io_sequence::tester::SelectErasurePool::select() {
       ceph::messaging::osd::OSDPoolGetReply pool_get_reply;
       pool_get_reply.decode_json(&p);
 
-      profile = sep.selectExistingProfile(pool_get_reply.erasure_code_profile);
+      if (pool_get_reply.erasure_code_profile.has_value()) {
+        pool_type = pg_pool_t::TYPE_ERASURE;
+        profile = sep.selectExistingProfile(*pool_get_reply.erasure_code_profile);
+      } else {
+        pool_type = pg_pool_t::TYPE_REPLICATED;
+        if (check_consistency) {
+          throw std::invalid_argument(fmt::format("checkconsistency option not "
+                                                  "allowed if using a {} pool",
+                                                  pg_pool_t::get_type_name(pool_type)));
+        }
+      }
     } else {
+      pool_type = pg_pool_t::TYPE_ERASURE;
       created_pool_name = create();
     }
 
     if (!dry_run) {
-      configureServices(force_value.value_or(created_pool_name),
+      configureServices(force_value.value_or(created_pool_name), pool_type,
                         allow_pool_autoscaling, allow_pool_balancer,
                         allow_pool_deep_scrubbing, allow_pool_scrubbing,
                         allow_pool_ec_optimizations, true, test_recovery);
 
-      setApplication(created_pool_name);
+      if (!force_value)
+      {
+        setApplication(created_pool_name);
+      }
     }
   }
 
@@ -898,6 +914,7 @@ void ceph::io_sequence::tester::SelectErasurePool::setApplication(
 
 void ceph::io_sequence::tester::SelectErasurePool::configureServices(
     const std::string& pool_name,
+    PoolType pool_type,
     bool allow_pool_autoscaling,
     bool allow_pool_balancer,
     bool allow_pool_deep_scrubbing,
@@ -953,26 +970,29 @@ void ceph::io_sequence::tester::SelectErasurePool::configureServices(
     ceph_assert(rc == 0);
   }
 
-  if (allow_pool_ec_optimizations) {
-    ceph::messaging::osd::OSDPoolSetRequest
-        allow_ec_optimisations_request{pool_name,
-                                       "allow_ec_optimizations",
-                                       "true",
-                                       std::nullopt};
-    rc = send_mon_command(allow_ec_optimisations_request, rados,
-                          "OSDPoolSetRequest", inbl, &outbl, formatter.get());
-    ceph_assert(rc == 0);
-  }
+  if (pool_type == pg_pool_t::TYPE_ERASURE)
+  {
+    if (allow_pool_ec_optimizations) {
+      ceph::messaging::osd::OSDPoolSetRequest
+          allow_ec_optimisations_request{pool_name,
+                                        "allow_ec_optimizations",
+                                        "true",
+                                        std::nullopt};
+      rc = send_mon_command(allow_ec_optimisations_request, rados,
+                            "OSDPoolSetRequest", inbl, &outbl, formatter.get());
+      ceph_assert(rc == 0);
+    }
 
-  if (allow_pool_ec_overwrites) {
-    ceph::messaging::osd::OSDPoolSetRequest
-        allow_ec_optimisations_request{pool_name,
-                                       "allow_ec_overwrites",
-                                       "true",
-                                       std::nullopt};
-    rc = send_mon_command(allow_ec_optimisations_request, rados,
-                          "OSDPoolSetRequest", inbl, &outbl, formatter.get());
-    ceph_assert(rc == 0);
+    if (allow_pool_ec_overwrites) {
+      ceph::messaging::osd::OSDPoolSetRequest
+          allow_ec_optimisations_request{pool_name,
+                                        "allow_ec_overwrites",
+                                        "true",
+                                        std::nullopt};
+      rc = send_mon_command(allow_ec_optimisations_request, rados,
+                            "OSDPoolSetRequest", inbl, &outbl, formatter.get());
+      ceph_assert(rc == 0);
+    }
   }
 
   if (test_recovery) {
@@ -1005,11 +1025,13 @@ ceph::io_sequence::tester::TestObject::TestObject(
   } else {
     const std::string pool = spo.select();
     if (!dryrun) {
-      ceph_assert(spo.getProfile());
-      pool_km = spo.getProfile()->km;
-      if (spo.getProfile()->mapping && spo.getProfile()->layers) {
-        pool_mappinglayers = {*spo.getProfile()->mapping,
-                             *spo.getProfile()->layers};
+      if (!spo.is_replicated_pool()) {
+       ceph_assert(spo.getProfile());
+       pool_km = spo.getProfile()->km;
+       if (spo.getProfile()->mapping && spo.getProfile()->layers) {
+         pool_mappinglayers = {*spo.getProfile()->mapping,
+                               *spo.getProfile()->layers};
+       }
       }
     }
 
@@ -1039,7 +1061,8 @@ ceph::io_sequence::tester::TestObject::TestObject(
 
     exerciser_model = std::make_unique<ceph::io_exerciser::RadosIo>(
         rados, asio, pool, oid, cached_shard_order, sbs.select(), rng(),
-        threads, lock, cond, spo.get_allow_pool_ec_optimizations());
+        threads, lock, cond, spo.is_replicated_pool(),
+        spo.get_allow_pool_ec_optimizations());
     dout(0) << "= " << oid << " pool=" << pool << " threads=" << threads
             << " blocksize=" << exerciser_model->get_block_size() << " ="
             << dendl;
@@ -1131,6 +1154,7 @@ ceph::io_sequence::tester::TestRunner::TestRunner(
           vm.contains("allow_pool_balancer"),
           vm.contains("allow_pool_deep_scrubbing"),
           vm.contains("allow_pool_scrubbing"),
+          vm.contains("checkconsistency"),
           vm.contains("testrecovery"),
           !vm.contains("disable_pool_ec_optimizations")},
       snt{rng, vm, "threads", true},
@@ -1318,7 +1342,7 @@ bool ceph::io_sequence::tester::TestRunner::run_interactive_test() {
     model = std::make_unique<ceph::io_exerciser::RadosIo>(
         rados, asio, pool, object_name, osd_map_reply.acting, sbs.select(), rng(),
         1,  // 1 thread
-        lock, cond,
+        lock, cond, spo.is_replicated_pool(),
         spo.get_allow_pool_ec_optimizations());
   }
 
@@ -1474,6 +1498,10 @@ bool ceph::io_sequence::tester::TestRunner::run_automated_test() {
       std::cerr << "Error: " << e.what() << std::endl;
       return false;
     }
+    catch (const std::invalid_argument &e) {
+      std::cerr << "Error: " << e.what() << std::endl;
+      return false;
+    }
   }
   if (!dryrun) {
     rados.wait_for_latest_osdmap();
index 50b9f9ac36cdac3949fc8201166a56c009020227..a874cfa924a6f71cb6f78d0c89511219acc58ce0 100644 (file)
@@ -388,6 +388,7 @@ class SelectErasurePool : public ProgramOptionReader<std::string> {
                     bool allow_pool_balancer,
                     bool allow_pool_deep_scrubbing,
                     bool allow_pool_scrubbing,
+                    bool check_consistency,
                     bool test_recovery,
                     bool allow_pool_ec_optimizations);
   const std::string select() override;
@@ -402,6 +403,9 @@ class SelectErasurePool : public ProgramOptionReader<std::string> {
   inline bool get_allow_pool_ec_optimizations() {
     return allow_pool_ec_optimizations;
   }
+
+  inline bool is_replicated_pool() const { return pool_type
+                                              == pg_pool_t::TYPE_REPLICATED; }
   inline std::optional<Profile> getProfile() { return profile; }
 
  private:
@@ -412,9 +416,13 @@ class SelectErasurePool : public ProgramOptionReader<std::string> {
   bool allow_pool_balancer;
   bool allow_pool_deep_scrubbing;
   bool allow_pool_scrubbing;
+  bool check_consistency;
   bool test_recovery;
   bool allow_pool_ec_optimizations;
 
+  using PoolType = int;
+  PoolType pool_type;
+
   bool first_use;
 
   SelectErasureProfile sep;
@@ -422,6 +430,7 @@ class SelectErasurePool : public ProgramOptionReader<std::string> {
   std::optional<Profile> profile;
 
   void configureServices(const std::string& pool_name,
+                         PoolType pool_type,
                          bool allow_pool_autoscaling,
                          bool allow_pool_balancer,
                          bool allow_pool_deep_scrubbing,