From cb88763ccbe372e0520dc97c77f791cf8abae9ab Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 2 Dec 2013 17:39:15 -0800 Subject: [PATCH] crush/mapper: fix up the indep tests Fix indentation. Simplify+fix the changed vs moved calculation. Use the new SET_CHOOSE_LEAF_TRIES command. Signed-off-by: Sage Weil --- src/test/crush/indep.cc | 94 +++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/src/test/crush/indep.cc b/src/test/crush/indep.cc index 1025a27e4cd..92d61ea485e 100644 --- a/src/test/crush/indep.cc +++ b/src/test/crush/indep.cc @@ -52,14 +52,15 @@ CrushWrapper *build_indep_map(CephContext *cct, int num_rack, int num_host, } } - crush_rule *rule = crush_make_rule(3, 0, 123, 1, 20); + crush_rule *rule = crush_make_rule(4, 0, 123, 1, 20); assert(rule); - crush_rule_set_step(rule, 0, CRUSH_RULE_TAKE, rootno, 0); - crush_rule_set_step(rule, 1, + crush_rule_set_step(rule, 0, CRUSH_RULE_SET_CHOOSE_LEAF_TRIES, 10, 0); + crush_rule_set_step(rule, 1, CRUSH_RULE_TAKE, rootno, 0); + crush_rule_set_step(rule, 2, CRUSH_RULE_CHOOSE_LEAF_INDEP, CRUSH_CHOOSE_N, 1); - crush_rule_set_step(rule, 2, CRUSH_RULE_EMIT, 0, 0); + crush_rule_set_step(rule, 3, CRUSH_RULE_EMIT, 0, 0); int rno = crush_add_rule(c->crush, rule, -1); c->set_rule_name(rno, "data"); @@ -192,51 +193,54 @@ TEST(CRUSH, indep_out_progressive) { for (int x = 1; x < 5; ++x) { vector<__u32> weight(c->get_max_devices(), 0x10000); - std::map pos; - vector prev; - for (unsigned i=0; i out; - c->do_rule(0, x, out, 7, weight); - cout << "(" << i << "/" << weight.size() << " out) " - << x << " -> " << out << std::endl; - int num_none = 0; - for (unsigned k=0; k pos; + vector prev; + for (unsigned i=0; i out; + c->do_rule(0, x, out, 7, weight); + cout << "(" << i << "/" << weight.size() << " out) " + << x << " -> " << out << std::endl; + int num_none = 0; + for (unsigned k=0; k