]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/test/osd/TestOSDMap.cc
update sources to v12.1.0
[ceph.git] / ceph / src / test / osd / TestOSDMap.cc
index e833ab2e4ff5a8e0c528c33828d543112590d08d..0d8eec7b561d854c0fa7eddd5176437075ee8793 100644 (file)
@@ -6,6 +6,7 @@
 #include "global/global_context.h"
 #include "global/global_init.h"
 #include "common/common_init.h"
+#include "common/ceph_argparse.h"
 
 #include <iostream>
 
@@ -13,6 +14,7 @@ using namespace std;
 
 int main(int argc, char **argv) {
   std::vector<const char*> args(argv, argv+argc);
+  env_to_vec(args);
   auto cct = global_init(nullptr, args, CEPH_ENTITY_TYPE_CLIENT,
                         CODE_ENVIRONMENT_UTILITY,
                         CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
@@ -54,9 +56,10 @@ public:
     osdmap.apply_incremental(pending_inc);
 
     // Create an EC ruleset and a pool using it
-    int r = osdmap.crush->add_simple_ruleset("erasure", "default", "osd",
-                                            "indep", pg_pool_t::TYPE_ERASURE,
-                                            &cerr);
+    int r = osdmap.crush->add_simple_rule(
+      "erasure", "default", "osd",
+      "indep", pg_pool_t::TYPE_ERASURE,
+      &cerr);
 
     OSDMap::Incremental new_pool_inc(osdmap.get_epoch() + 1);
     new_pool_inc.new_pool_max = osdmap.get_pool_max();
@@ -68,7 +71,7 @@ public:
     p->set_pg_num(64);
     p->set_pgp_num(64);
     p->type = pg_pool_t::TYPE_ERASURE;
-    p->crush_ruleset = r;
+    p->crush_rule = r;
     new_pool_inc.new_pool_names[pool_id] = "ec";
     osdmap.apply_incremental(new_pool_inc);
   }
@@ -352,16 +355,6 @@ TEST_F(OSDMapTest, KeepsNecessaryTemps) {
 TEST_F(OSDMapTest, PrimaryAffinity) {
   set_up_map();
 
-  /*
-  osdmap.print(cout);
-  Formatter *f = Formatter::create("json-pretty");
-  f->open_object_section("CRUSH");
-  osdmap.crush->dump(f);
-  f->close_section();
-  f->flush(cout);
-  delete f;
-  */
-
   int n = get_num_osds();
   for (map<int64_t,pg_pool_t>::const_iterator p = osdmap.get_pools().begin();
        p != osdmap.get_pools().end();
@@ -374,7 +367,6 @@ TEST_F(OSDMapTest, PrimaryAffinity) {
       vector<int> primary(n, 0);
       test_mappings(0, 10000, &any, &first, &primary);
       for (int i=0; i<n; ++i) {
-       //cout << "osd." << i << " " << any[i] << " " << first[i] << " " << primary[i] << std::endl;
        ASSERT_LT(0, any[i]);
        ASSERT_LT(0, first[i]);
        ASSERT_LT(0, primary[i]);
@@ -389,7 +381,6 @@ TEST_F(OSDMapTest, PrimaryAffinity) {
       vector<int> primary(n, 0);
       test_mappings(pool, 10000, &any, &first, &primary);
       for (int i=0; i<n; ++i) {
-       //cout << "osd." << i << " " << any[i] << " " << first[i] << " " << primary[i] << std::endl;
        ASSERT_LT(0, any[i]);
        if (i >= 2) {
          ASSERT_LT(0, first[i]);
@@ -411,7 +402,6 @@ TEST_F(OSDMapTest, PrimaryAffinity) {
       vector<int> primary(n, 0);
       test_mappings(pool, 10000, &any, &first, &primary);
       for (int i=0; i<n; ++i) {
-       //cout << "osd." << i << " " << any[i] << " " << first[i] << " " << primary[i] << std::endl;
        ASSERT_LT(0, any[i]);
        if (i >= 2) {
          ASSERT_LT(0, first[i]);
@@ -432,3 +422,19 @@ TEST_F(OSDMapTest, PrimaryAffinity) {
     osdmap.set_primary_affinity(1, 0x10000);
   }
 }
+
+TEST(PGTempMap, basic)
+{
+  PGTempMap m;
+  pg_t a(1,1);
+  for (auto i=3; i<1000; ++i) {
+    pg_t x(i, 1);
+    m.set(x, {static_cast<int>(i)});
+  }
+  pg_t b(2,1);
+  m.set(a, {1, 2});
+  ASSERT_NE(m.find(a), m.end());
+  ASSERT_EQ(m.find(a), m.begin());
+  ASSERT_EQ(m.find(b), m.end());
+  ASSERT_EQ(998u, m.size());
+}