]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test: Removed ObjectModel seed generation from constructor 65987/head
authorMatty Williams <Matty.Williams@ibm.com>
Fri, 17 Oct 2025 15:50:52 +0000 (16:50 +0100)
committerMatty Williams <Matty.Williams@ibm.com>
Wed, 25 Mar 2026 15:15:25 +0000 (15:15 +0000)
Having rng() in the constructor of ObjectModel and RadosIo was causing random number generation to differ between compilers.

Fixes: https://tracker.ceph.com/issues/73553
Signed-off-by: Matty Williams <Matty.Williams@ibm.com>
src/common/io_exerciser/ObjectModel.cc
src/common/io_exerciser/ObjectModel.h
src/test/osd/ceph_test_rados_io_sequence/ProgramOptionReader.h
src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.cc

index 3e47caeca3382c068f360c1c5a01d0ab3f7016d2..cd9f741065a73f448b69be0b2ee4e4955215dab0 100644 (file)
@@ -4,20 +4,14 @@
 #include <algorithm>
 #include <execution>
 #include <iterator>
-
-#include "common/debug.h"
-#include "common/dout.h"
-
-#define dout_subsys ceph_subsys_rados
-#define dout_context g_ceph_context
+#include <random>
 
 using ObjectModel = ceph::io_exerciser::ObjectModel;
 
 ObjectModel::ObjectModel(const std::string& primary_oid, const std::string& secondary_oid,
                          uint64_t block_size, int seed, bool delete_objects)
-    : Model(primary_oid, secondary_oid, block_size, delete_objects), primary_created(false), secondary_created(false) {
-  rng.seed(seed);
-}
+    : Model(primary_oid, secondary_oid, block_size, delete_objects),
+      primary_created(false), secondary_created(false), rng(seed) {}
 
 int ObjectModel::get_seed(uint64_t offset) const {
   ceph_assert(offset < primary_contents.size());
@@ -58,10 +52,7 @@ void ObjectModel::applyIoOp(IoOp& op) {
     constexpr int64_t max = static_cast<int64_t>(std::numeric_limits<int>::max());
     constexpr uint64_t range = static_cast<uint64_t>(max - min + 1);
     uint64_t rand_value = rng();
-    int64_t result = static_cast<int64_t>(rand_value % range + min);
-    dout(0) << "S1 rand_value: " << rand_value << " range: " 
-            << range << " result: " << result  << " addr: " << &rng << dendl;
-    return result;
+    return static_cast<int64_t>(rand_value % range + min);
   };
 
   auto verify_and_record_read_op =
index f14bfd0c64b805243af9d1be4ab9a2aa4714e41e..c2db1d1314bbf21e007d152e7b0d14a496135fe9 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <string>
 #include <vector>
+#include <random>
 
 /* Overview
  *
@@ -29,8 +30,7 @@ class ObjectModel : public Model {
   bool secondary_created;
   std::vector<int> primary_contents;
   std::vector<int> secondary_contents;
-  std::mt19937_64 rng =
-      std::mt19937_64();
+  std::mt19937_64 rng;
 
   // Track read and write I/Os that can be submitted in
   // parallel to detect violations:
index 15a268cb2c5779ef40d8275d5f2f6df40b998745..11e5ba13ee42d135537a73a9a3fcaa32530ab606 100644 (file)
@@ -5,14 +5,9 @@
 #include <random>
 #include <string>
 
-#include "common/debug.h"
-#include "common/dout.h"
 #include "include/ceph_assert.h"
 #include "include/random.h"
 
-#define dout_subsys ceph_subsys_rados
-#define dout_context g_ceph_context
-
 /* Overview
  *
  * class ProgramOptionReader
@@ -114,8 +109,6 @@ class ProgramOptionSelector : public ProgramOptionReader<option_type> {
       uint64_t range = static_cast<uint64_t>(num_selections);
       uint64_t rand_value = rng();
       size_t index = static_cast<size_t>(rand_value % range);
-      dout(0) << "S4 rand_value: " << rand_value << " range: " 
-            << range << " index: " << index  << " addr: " << &rng << dendl;
       return selections_array[index];
     }
   }
@@ -165,15 +158,11 @@ public:
       uint64_t range = static_cast<uint64_t>(num_selections_stable);
       uint64_t rand_value = rng();
       size_t index = static_cast<size_t>(rand_value % range);
-      dout(0) << "S2 rand_value: " << rand_value << " range: " 
-            << range << " index: " << index << " addr: " << &rng << dendl;
       return selections_array_stable[index];
     } else {
       uint64_t range = static_cast<uint64_t>(num_selections);
       uint64_t rand_value = rng();
       size_t index = static_cast<size_t>(rand_value % range);
-      dout(0) << "S6 rand_value: " << rand_value << " range: " 
-            << range << " index: " << index << " addr: " << &rng << dendl;
       return selections_array[index];
     }
   }
@@ -223,8 +212,6 @@ class ProgramOptionGeneratedSelector
       uint64_t range = static_cast<uint64_t>(selection.size());
       uint64_t rand_value = rng();
       size_t index = static_cast<size_t>(rand_value % range);
-      dout(0) << "S3 rand_value: " << rand_value << " range: " 
-            << range << " index: " << index  << " addr: " << &rng << dendl;
       return selection[index];
     } else {
       return std::nullopt;
index a8e66354890ee975fa6f034d20a3aa89b7369b2e..4f4d68c5edfb8c71db31c1ad3b4fee512a0784cb 100644 (file)
@@ -552,30 +552,27 @@ ceph::io_sequence::tester::SelectErasureChunkSize::generate_selections() {
 
   auto generate_random_int = [this](uint64_t range) -> uint64_t {
     uint64_t rand_value = rng();
-    uint64_t index = rand_value % range;
-    dout(0) << "S5 rand_value: " << rand_value << " range: " 
-            << range << " index: " << index  << " addr: " << &rng << dendl;
-    return index;
+    return rand_value % range;;
   };
 
   if (4096 % minimum_chunksize == 0) {
     choices.push_back(4096);
   } else {
-    uint64_t r = generate_random_int(4); // 0–3
+    uint64_t r = generate_random_int(4); // [0–3]
     choices.push_back(minimum_chunksize * (r + 1));
   }
 
   if ((64 * 1024) % minimum_chunksize == 0) {
     choices.push_back(64 * 1024);
   } else {
-    uint64_t r = generate_random_int(64); // 0–63
+    uint64_t r = generate_random_int(64); // [0–63]
     choices.push_back(minimum_chunksize * (r + 1));
   }
 
   if ((256 * 1024) % minimum_chunksize == 0) {
     choices.push_back(256 * 1024);
   } else {
-    uint64_t r = generate_random_int(256); // 0–255
+    uint64_t r = generate_random_int(256); // [0–255]
     choices.push_back(minimum_chunksize * (r + 1));
   }
 
@@ -1042,8 +1039,9 @@ ceph::io_sequence::tester::TestObject::TestObject(
     : rng(rng), verbose(verbose), seqseed(seqseed), testrecovery(testrecovery), checkconsistency(checkconsistency),
       delete_objects(delete_objects) {
   if (dryrun) {
+    int model_seed = rng();
     exerciser_model = std::make_unique<ceph::io_exerciser::ObjectModel>(
-        primary_oid, secondary_oid, sbs.select(), rng(), delete_objects);
+        primary_oid, secondary_oid, sbs.select(), model_seed, delete_objects);
   } else {
     const std::string pool = spo.select();
     if (!dryrun) {
@@ -1061,9 +1059,9 @@ ceph::io_sequence::tester::TestObject::TestObject(
 
     bufferlist outbl;
     auto formatter = std::make_unique<JSONFormatter>(false);
-
+    int model_seed = rng();
     exerciser_model = std::make_unique<ceph::io_exerciser::RadosIo>(
-        rados, asio, pool, primary_oid, secondary_oid, sbs.select(), rng(),
+        rados, asio, pool, primary_oid, secondary_oid, sbs.select(), model_seed,
         threads, lock, cond, spo.is_replicated_pool(),
         spo.get_allow_pool_ec_optimizations(), delete_objects);
     dout(0) << "= " << primary_oid << " pool=" << pool << " threads=" << threads
@@ -1324,14 +1322,15 @@ bool ceph::io_sequence::tester::TestRunner::run_interactive_test() {
   std::unique_ptr<ceph::io_exerciser::Model> model;
 
   if (dryrun) {
+    int model_seed = rng();
     model = std::make_unique<ceph::io_exerciser::ObjectModel>(
-        primary_object_name, secondary_object_name, sbs.select(), rng());
+        primary_object_name, secondary_object_name, sbs.select(), model_seed);
   } else {
     const std::string pool = spo.select();
     dout(0) << "Pool name: " << pool << dendl;
-
+    int model_seed = rng();
     model = std::make_unique<ceph::io_exerciser::RadosIo>(
-        rados, asio, pool, primary_object_name, secondary_object_name, sbs.select(), rng(),
+        rados, asio, pool, primary_object_name, secondary_object_name, sbs.select(), model_seed,
         1,  // 1 thread
         lock, cond, spo.is_replicated_pool(),
         spo.get_allow_pool_ec_optimizations());