#include "global/global_context.h"
#include "global/global_init.h"
#include "common/common_init.h"
+#include "common/ceph_argparse.h"
#include <iostream>
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);
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();
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);
}
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();
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]);
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]);
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]);
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());
+}