MCPcopy Create free account
hub / github.com/ceph/ceph / TEST

Function TEST

src/test/erasure-code/TestErasureCodeLrc.cc:32–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30using namespace std;
31
32TEST(ErasureCodeLrc, parse_rule)
33{
34 ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir"));
35 EXPECT_EQ("default", lrc.rule_root);
36 EXPECT_EQ("host", lrc.rule_steps.front().type);
37
38 ErasureCodeProfile profile;
39 profile["crush-root"] = "other";
40 EXPECT_EQ(0, lrc.parse_rule(profile, &cerr));
41 EXPECT_EQ("other", lrc.rule_root);
42
43 profile["crush-steps"] = "[]";
44 EXPECT_EQ(0, lrc.parse_rule(profile, &cerr));
45 EXPECT_TRUE(lrc.rule_steps.empty());
46
47 profile["crush-steps"] = "0";
48 EXPECT_EQ(ERROR_LRC_ARRAY, lrc.parse_rule(profile, &cerr));
49
50 profile["crush-steps"] = "{";
51 EXPECT_EQ(ERROR_LRC_PARSE_JSON, lrc.parse_rule(profile, &cerr));
52
53 profile["crush-steps"] = "[0]";
54 EXPECT_EQ(ERROR_LRC_ARRAY, lrc.parse_rule(profile, &cerr));
55
56 profile["crush-steps"] = "[[0]]";
57 EXPECT_EQ(ERROR_LRC_RULE_OP, lrc.parse_rule(profile, &cerr));
58
59 profile["crush-steps"] = "[[\"choose\", 0]]";
60 EXPECT_EQ(ERROR_LRC_RULE_TYPE, lrc.parse_rule(profile, &cerr));
61
62 profile["crush-steps"] = "[[\"choose\", \"host\", []]]";
63 EXPECT_EQ(ERROR_LRC_RULE_N, lrc.parse_rule(profile, &cerr));
64
65 profile["crush-steps"] = "[[\"choose\", \"host\", 2]]";
66 EXPECT_EQ(0, lrc.parse_rule(profile, &cerr));
67
68 const ErasureCodeLrc::Step &step = lrc.rule_steps.front();
69 EXPECT_EQ("choose", step.op);
70 EXPECT_EQ("host", step.type);
71 EXPECT_EQ(2, step.n);
72
73 profile["crush-steps"] =
74 "["
75 " [\"choose\", \"rack\", 2], "
76 " [\"chooseleaf\", \"host\", 5], "
77 "]";
78 EXPECT_EQ(0, lrc.parse_rule(profile, &cerr));
79 EXPECT_EQ(2U, lrc.rule_steps.size());
80 {
81 const ErasureCodeLrc::Step &step = lrc.rule_steps[0];
82 EXPECT_EQ("choose", step.op);
83 EXPECT_EQ("rack", step.type);
84 EXPECT_EQ(2, step.n);
85 }
86 {
87 const ErasureCodeLrc::Step &step = lrc.rule_steps[1];
88 EXPECT_EQ("chooseleaf", step.op);
89 EXPECT_EQ("host", step.type);

Callers

nothing calls this directly

Calls 15

stringifyFunction · 0.85
getenvFunction · 0.85
set_type_nameMethod · 0.80
add_bucketMethod · 0.80
set_item_nameMethod · 0.80
insert_itemMethod · 0.80
get_max_devicesMethod · 0.80
get_rule_idMethod · 0.80
do_ruleMethod · 0.80
parse_kmlMethod · 0.80
layers_descriptionMethod · 0.80
layers_parseMethod · 0.80

Tested by

no test coverage detected