本文整理汇总了C++中TestFiberManager类的典型用法代码示例。如果您正苦于以下问题:C++ TestFiberManager类的具体用法?C++ TestFiberManager怎么用?C++ TestFiberManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestFiberManager类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(routeHandleTest, allAsync) {
vector<std::shared_ptr<TestHandle>> test_handles{
make_shared<TestHandle>(GetRouteTestData(mc_res_found, "a")),
make_shared<TestHandle>(GetRouteTestData(mc_res_notfound, "b")),
make_shared<TestHandle>(GetRouteTestData(mc_res_remote_error, "c"))
};
TestFiberManager fm;
TestRouteHandle<AllAsyncRoute<TestRouteHandleIf>> rh(
get_route_handles(test_handles));
fm.runAll(
{
[&]() {
auto op = McOperation<mc_op_get>();
auto reply = rh.route(McRequest("key"), op);
/* Check that we got no result back */
EXPECT_TRUE(reply.result() == mc_res_notfound);
}
});
/* Check that everything is complete in the background */
for (auto& h : test_handles) {
EXPECT_TRUE(h->saw_keys == vector<string> {"key"});
}
}
开发者ID:sravan64,项目名称:mcrouter,代码行数:28,代码来源:RouteHandleTest.cpp
示例2: TEST
TEST(routeHandleTest, allMajorityTieTyped) {
TestFiberManager fm;
vector<std::shared_ptr<TestHandle>> test_handles{
make_shared<TestHandle>(GetRouteTestData(mc_res_remote_error, "a")),
make_shared<TestHandle>(GetRouteTestData(mc_res_notfound, "b")),
make_shared<TestHandle>(GetRouteTestData(mc_res_notfound, "c")),
make_shared<TestHandle>(GetRouteTestData(mc_res_remote_error, "d"))
};
TestRouteHandle<AllMajorityRoute<TestRouteHandleIf>> rh(
get_route_handles(test_handles));
fm.runAll(
{
[&]() {
TypedThriftRequest<cpp2::McGetRequest> req;
req.setKey("key");
auto reply = rh.route(req);
/* Check that we got the _worst_ majority reply */
EXPECT_TRUE(reply.result() == mc_res_remote_error);
}
});
/* Check that everything is complete */
for (auto& h : test_handles) {
EXPECT_EQ(vector<string>{"key"}, h->saw_keys);
}
}
开发者ID:THIAGOWESLLEY2,项目名称:mcrouter,代码行数:31,代码来源:RouteHandleTest.cpp
示例3: TEST
TEST(routeHandleTest, allInitial) {
vector<std::shared_ptr<TestHandle>> test_handles{
make_shared<TestHandle>(GetRouteTestData(carbon::Result::FOUND, "a")),
make_shared<TestHandle>(GetRouteTestData(carbon::Result::NOTFOUND, "b")),
make_shared<TestHandle>(
GetRouteTestData(carbon::Result::REMOTE_ERROR, "c")),
};
TestFiberManager fm;
auto routeHandles = get_route_handles(test_handles);
TestRouteHandle<AllInitialRoute<TestRouteHandleIf>> rh(routeHandles);
fm.runAll({[&]() {
auto reply = rh.route(McGetRequest("key"));
/* Check that we got the initial result back */
EXPECT_EQ(carbon::Result::FOUND, reply.result());
EXPECT_EQ("a", carbon::valueRangeSlow(reply).str());
}});
/* Check that everything is complete in the background */
for (auto& h : test_handles) {
EXPECT_EQ(vector<string>{"key"}, h->saw_keys);
}
/* Check that traverse is correct */
int cnt = 0;
RouteHandleTraverser<TestRouteHandleIf> t{
[&cnt](const TestRouteHandleIf&) { ++cnt; }};
rh.traverse(McGetRequest("key"), t);
EXPECT_EQ(cnt, routeHandles.size());
}
开发者ID:facebook,项目名称:mcrouter,代码行数:32,代码来源:RouteHandleTest.cpp
示例4: TEST
TEST(ReliablePoolRouteTest, deleteOps) {
counter = 0;
vector<std::shared_ptr<TestHandle>> saltedHandle{
make_shared<TestHandle>(DeleteRouteTestData(mc_res_found)),
make_shared<TestHandle>(DeleteRouteTestData(mc_res_notfound)),
make_shared<TestHandle>(DeleteRouteTestData(mc_res_found)),
};
TestFiberManager fm;
fm.runAll(
{
[&] () {
TestRouteHandle<ReliablePoolRoute<TestRouteHandleIf, HashFunc>> rh(
get_route_handles(saltedHandle),
HashFunc(saltedHandle.size()),
"", 5);
auto reply = rh.routeSimple(McRequest("key"),
McOperation<mc_op_delete>());
// Get the most awfull reply
EXPECT_EQ(reply.result(), mc_res_notfound);
}
});
EXPECT_TRUE(saltedHandle[0]->saw_keys == (vector<std::string>{"key", "key"}));
EXPECT_TRUE(saltedHandle[1]->saw_keys == (vector<std::string>{"key", "key"}));
EXPECT_TRUE(saltedHandle[2]->saw_keys == (vector<std::string>{"key", "key"}));
}
开发者ID:apinski-cavium,项目名称:mcrouter,代码行数:29,代码来源:ReliablePoolRouteTest.cpp
示例5: TEST
TEST(BigValueRouteTest, smallvalue) {
// for small values, this route handle simply passes it to child route handle
vector<std::shared_ptr<TestHandle>> test_handles{
make_shared<TestHandle>(GetRouteTestData(mc_res_found, "a"),
UpdateRouteTestData(mc_res_stored),
DeleteRouteTestData(mc_res_deleted))
};
auto route_handles = get_route_handles(test_handles);
TestFiberManager fm;
fm.runAll({
[&]() {
McrouterRouteHandle<BigValueRoute> rh(route_handles[0], opts);
std::string key = "key_get";
auto msg = createMcMsgRef(key, "value");
msg->op = mc_op_get;
McRequestWithMcOp<mc_op_get> req_get(std::move(msg));
auto f_get = rh.route(req_get);
EXPECT_EQ("a", toString(f_get.value()));
EXPECT_EQ(test_handles[0]->saw_keys, vector<std::string>{"key_get"});
test_handles[0]->saw_keys.clear();
std::string key_set = "key_set";
auto msg_set = createMcMsgRef(key_set, "value");
msg_set->op = mc_op_set;
McRequestWithMcOp<mc_op_set> req_set(std::move(msg_set));
auto f_set = rh.route(req_set);
EXPECT_EQ(mc_res_stored, f_set.result());
EXPECT_EQ(test_handles[0]->saw_keys, vector<std::string>{"key_set"});
}
});
}
开发者ID:THIAGOWESLLEY2,项目名称:mcrouter,代码行数:34,代码来源:BigValueRouteTest.cpp
示例6: TEST
TEST(shadowRouteTest, defaultPolicy) {
vector<std::shared_ptr<TestHandle>> normalHandle{
make_shared<TestHandle>(GetRouteTestData(mc_res_found, "a")),
};
auto normalRh = get_route_handles(normalHandle)[0];
vector<std::shared_ptr<TestHandle>> shadowHandles{
make_shared<TestHandle>(GetRouteTestData(mc_res_found, "b")),
make_shared<TestHandle>(GetRouteTestData(mc_res_found, "c")),
};
TestFiberManager fm;
auto data = make_shared<proxy_pool_shadowing_policy_t::Data>();
vector<std::shared_ptr<proxy_pool_shadowing_policy_t>> settings {
make_shared<proxy_pool_shadowing_policy_t>(data, nullptr),
make_shared<proxy_pool_shadowing_policy_t>(data, nullptr),
};
auto shadowRhs = get_route_handles(shadowHandles);
ShadowData<TestRouteHandleIf> shadowData = {
{std::move(shadowRhs[0]), std::move(settings[0])},
{std::move(shadowRhs[1]), std::move(settings[1])},
};
TestRouteHandle<ShadowRoute<TestRouteHandleIf, DefaultShadowPolicy>> rh(
normalRh,
std::move(shadowData),
0,
DefaultShadowPolicy());
fm.runAll(
{
[&] () {
auto reply = rh.route(McRequest("key"),
McOperation<mc_op_get>());
EXPECT_TRUE(reply.result() == mc_res_found);
EXPECT_TRUE(toString(reply.value()) == "a");
}
});
EXPECT_TRUE(shadowHandles[0]->saw_keys.empty());
EXPECT_TRUE(shadowHandles[1]->saw_keys.empty());
data->end_index = 1;
data->end_key_fraction = 1.0;
fm.runAll(
{
[&] () {
auto reply = rh.route(McRequest("key"),
McOperation<mc_op_get>());
EXPECT_TRUE(reply.result() == mc_res_found);
EXPECT_TRUE(toString(reply.value()) == "a");
}
});
EXPECT_TRUE(shadowHandles[0]->saw_keys == vector<string>{"key"});
EXPECT_TRUE(shadowHandles[1]->saw_keys == vector<string>{"key"});
}
开发者ID:0xd3adsh3ll,项目名称:mcrouter,代码行数:61,代码来源:ShadowRouteTest.cpp
示例7: TEST
TEST(warmUpRouteTest, warmUp) {
vector<std::shared_ptr<TestHandle>> test_handles{
make_shared<TestHandle>(GetRouteTestData(mc_res_found, "a"),
UpdateRouteTestData(mc_res_stored),
DeleteRouteTestData(mc_res_deleted)),
make_shared<TestHandle>(GetRouteTestData(mc_res_found, "b"),
UpdateRouteTestData(mc_res_stored),
DeleteRouteTestData(mc_res_notfound)),
make_shared<TestHandle>(GetRouteTestData(mc_res_notfound, ""),
UpdateRouteTestData(mc_res_notstored),
DeleteRouteTestData(mc_res_notfound)),
};
auto route_handles = get_route_handles(test_handles);
TestFiberManager fm;
fm.run([&]() {
TestRouteHandle<WarmUpRoute<TestRouteHandleIf>> rh(
route_handles[0], route_handles[1], 1);
auto reply_get = rh.route(
McRequestWithMcOp<mc_op_get>("key_get"));
EXPECT_TRUE("b" == toString(reply_get.value()));
EXPECT_TRUE(vector<string>{"key_get"} != test_handles[0]->saw_keys);
EXPECT_TRUE(vector<string>{"key_get"} == test_handles[1]->saw_keys);
(test_handles[0]->saw_keys).clear();
(test_handles[1]->saw_keys).clear();
auto reply_del = rh.route(
McRequestWithMcOp<mc_op_delete>("key_del"));
EXPECT_TRUE(mc_res_notfound == reply_del.result());
EXPECT_TRUE(vector<string>{"key_del"} != test_handles[0]->saw_keys);
EXPECT_TRUE(vector<string>{"key_del"} == test_handles[1]->saw_keys);
});
fm.run([&]() {
TestRouteHandle<WarmUpRoute<TestRouteHandleIf>> rh(
route_handles[0], route_handles[2], 1);
auto reply_get = rh.route(
McRequestWithMcOp<mc_op_get>("key_get"));
EXPECT_TRUE("a" == toString(reply_get.value()));
EXPECT_TRUE(vector<string>{"key_get"} == test_handles[0]->saw_keys);
EXPECT_TRUE(vector<string>{"key_get"} == test_handles[2]->saw_keys);
});
fm.run([&]() {
EXPECT_TRUE((vector<uint32_t>{0, 1}) == test_handles[2]->sawExptimes);
(test_handles[0]->saw_keys).clear();
(test_handles[2]->saw_keys).clear();
EXPECT_TRUE((vector<mc_op_t>{ mc_op_get, mc_op_add }) ==
test_handles[2]->sawOperations);
});
fm.run([&]() {
TestRouteHandle<WarmUpRoute<TestRouteHandleIf>> rh(
route_handles[0], route_handles[2], 1);
auto reply_del = rh.route(
McRequestWithMcOp<mc_op_delete>("key_del"));
EXPECT_TRUE(mc_res_notfound == reply_del.result());
EXPECT_TRUE(vector<string>{"key_del"} != test_handles[0]->saw_keys);
EXPECT_TRUE(vector<string>{"key_del"} == test_handles[2]->saw_keys);
});
}
开发者ID:DennyLoko,项目名称:mcrouter,代码行数:64,代码来源:WarmUpRouteTest.cpp
示例8: TEST
TEST(migrateRouteTest, migrate) {
auto curr_time = time(nullptr);
auto interval = 50;
auto tp_func = []() {
return time(nullptr);
};
typedef decltype(tp_func) TimeProviderFunc;
vector<std::shared_ptr<TestHandle>> test_handles{
make_shared<TestHandle>(GetRouteTestData(mc_res_found, "a"),
UpdateRouteTestData(),
DeleteRouteTestData(mc_res_deleted)),
make_shared<TestHandle>(GetRouteTestData(mc_res_found, "b"),
UpdateRouteTestData(),
DeleteRouteTestData(mc_res_notfound)),
};
auto route_handles = get_route_handles(test_handles);
TestFiberManager fm;
fm.runAll({
[&]() { // case 1: curr_time < start_time
TestRouteHandle<MigrateRoute<TestRouteHandleIf, TimeProviderFunc>> rh(
route_handles[0], route_handles[1], curr_time + 25, interval, tp_func);
TypedThriftRequest<cpp2::McGetRequest> req_get("key_get");
int cnt = 0;
RouteHandleTraverser<TestRouteHandleIf> t{
[&cnt](const TestRouteHandleIf&) { ++cnt; }
};
rh.traverse(req_get, t);
EXPECT_EQ(1, cnt);
auto reply_get = rh.route(req_get);
EXPECT_EQ("a", reply_get.valueRangeSlow().str());
EXPECT_EQ(vector<string>{"key_get"}, test_handles[0]->saw_keys);
EXPECT_NE(vector<string>{"key_get"}, test_handles[1]->saw_keys);
(test_handles[0]->saw_keys).clear();
(test_handles[1]->saw_keys).clear();
TypedThriftRequest<cpp2::McDeleteRequest> req_del("key_del");
cnt = 0;
rh.traverse(req_del, t);
EXPECT_EQ(1, cnt);
auto reply_del = rh.route(req_del);
EXPECT_EQ(mc_res_deleted, reply_del.result());
EXPECT_EQ(vector<string>{"key_del"}, test_handles[0]->saw_keys);
EXPECT_NE(vector<string>{"key_del"}, test_handles[1]->saw_keys);
},
[&]() { // case 2: curr_time < start_time + interval
vector<std::shared_ptr<TestHandle>> test_handles{
make_shared<TestHandle>(GetRouteTestData(mc_res_found, "a"),
UpdateRouteTestData(),
DeleteRouteTestData(mc_res_deleted)),
make_shared<TestHandle>(GetRouteTestData(mc_res_notfound, "b"),
UpdateRouteTestData(),
DeleteRouteTestData(mc_res_notfound)),
};
auto route_handles_c2 = get_route_handles(test_handles);
TestRouteHandle<MigrateRoute<TestRouteHandleIf, TimeProviderFunc>> rh(
route_handles_c2[0], route_handles_c2[1],
curr_time - 25, interval, tp_func);
TypedThriftRequest<cpp2::McGetRequest> req_get("key_get");
int cnt = 0;
RouteHandleTraverser<TestRouteHandleIf> t{
[&cnt](const TestRouteHandleIf&) { ++cnt; }
};
rh.traverse(req_get, t);
EXPECT_EQ(cnt, 1);
auto reply_get = rh.route(req_get);
EXPECT_EQ("a", reply_get.valueRangeSlow().str());
EXPECT_EQ(vector<string>{"key_get"}, test_handles[0]->saw_keys);
EXPECT_NE(vector<string>{"key_get"}, test_handles[1]->saw_keys);
(test_handles[0]->saw_keys).clear();
(test_handles[1]->saw_keys).clear();
TypedThriftRequest<cpp2::McDeleteRequest> req_del("key_del");
cnt = 0;
rh.traverse(req_del, t);
EXPECT_EQ(cnt, 2);
auto reply_del = rh.route(req_del);
EXPECT_EQ(mc_res_notfound, reply_del.result());
EXPECT_EQ(vector<string>{"key_del"}, test_handles[0]->saw_keys);
EXPECT_EQ(vector<string>{"key_del"}, test_handles[1]->saw_keys);
},
[&]() { // case 3: curr_time < start_time + 2*interval
vector<std::shared_ptr<TestHandle>> test_handles{
make_shared<TestHandle>(GetRouteTestData(mc_res_notfound, "a"),
UpdateRouteTestData(),
DeleteRouteTestData(mc_res_notfound)),
make_shared<TestHandle>(GetRouteTestData(mc_res_found, "b"),
UpdateRouteTestData(),
DeleteRouteTestData(mc_res_deleted)),
//.........这里部分代码省略.........
开发者ID:ConfusedReality,项目名称:mcrouter,代码行数:101,代码来源:MigrateRouteTest.cpp
示例9: TEST
TEST(RouteHandleFactoryTest, sanity) {
TestFiberManager fm;
RouteHandleProvider<TestRouteHandleIf> provider;
RouteHandleFactory<TestRouteHandleIf> factory(provider);
auto rh = factory.create("AllAsyncRoute|ErrorRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->routeSimple(McRequest("a"), McOperation<mc_op_get>());
EXPECT_EQ(reply.result(), mc_res_notfound);
});
rh = factory.create("AllFastestRoute|ErrorRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->routeSimple(McRequest("a"), McOperation<mc_op_get>());
EXPECT_TRUE(reply.isError());
});
rh = factory.create("AllInitialRoute|ErrorRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->routeSimple(McRequest("a"), McOperation<mc_op_get>());
EXPECT_TRUE(reply.isError());
});
rh = factory.create("AllMajorityRoute|ErrorRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->routeSimple(McRequest("a"), McOperation<mc_op_get>());
EXPECT_TRUE(reply.isError());
});
rh = factory.create("AllSyncRoute|ErrorRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->routeSimple(McRequest("a"), McOperation<mc_op_get>());
EXPECT_TRUE(reply.isError());
});
rh = factory.create("FailoverRoute|NullRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->routeSimple(McRequest("a"), McOperation<mc_op_get>());
EXPECT_EQ(reply.result(), mc_res_notfound);
});
rh = factory.create("HashRoute|ErrorRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->routeSimple(McRequest("a"), McOperation<mc_op_get>());
EXPECT_TRUE(reply.isError());
});
rh = factory.create("HostIdRoute|ErrorRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->routeSimple(McRequest("a"), McOperation<mc_op_get>());
EXPECT_TRUE(reply.isError());
});
rh = factory.create("LatestRoute|NullRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->routeSimple(McRequest("a"), McOperation<mc_op_get>());
EXPECT_EQ(reply.result(), mc_res_notfound);
});
rh = factory.create("MissFailoverRoute|NullRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->routeSimple(McRequest("a"), McOperation<mc_op_get>());
EXPECT_EQ(reply.result(), mc_res_notfound);
});
rh = factory.create("RandomRoute|ErrorRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->routeSimple(McRequest("a"), McOperation<mc_op_get>());
EXPECT_TRUE(reply.isError());
});
}
开发者ID:cppfool,项目名称:mcrouter,代码行数:84,代码来源:routehandlefactory_test.cpp
示例10: TEST
TEST(BigValueRouteTest, bigvalue) {
// for big values, used saw_keys of test route handle to verify that
// get path and set path saw original key and chunk keys in correct sequesne.
std::string rand_suffix_get ("123456");
int num_chunks = 10;
// initial reply of the form version-num_chunks-rand_suffix for get path
std::string init_reply =
folly::format("{}-{}-{}", version, num_chunks, rand_suffix_get).str();
std::string init_reply_error =
folly::format("{}-{}", version, num_chunks).str();
vector<std::shared_ptr<TestHandle>> test_handles{
make_shared<TestHandle>(GetRouteTestData(
mc_res_found, init_reply, MC_MSG_FLAG_BIG_VALUE)),
make_shared<TestHandle>(GetRouteTestData(
mc_res_found, init_reply_error, MC_MSG_FLAG_BIG_VALUE)),
make_shared<TestHandle>(UpdateRouteTestData(mc_res_stored)),
make_shared<TestHandle>(UpdateRouteTestData(mc_res_stored))
};
auto route_handles = get_route_handles(test_handles);
TestFiberManager fm;
std::shared_ptr<ProxyRequestContext> ctx;
fm.runAll({
[&]() {
{ // Test Get Like path with init_reply in corect format
McrouterRouteHandle<BigValueRoute> rh(route_handles[0], opts);
auto msg = createMcMsgRef("key_get");
msg->op = mc_op_get;
ProxyMcRequest req_get(std::move(msg));
auto f_get = rh.route(req_get, McOperation<mc_op_get>(), ctx);
auto keys_get = test_handles[0]->saw_keys;
EXPECT_TRUE(keys_get.size() == num_chunks + 1);
// first get the result for original key
EXPECT_TRUE(keys_get.front() == "key_get");
std::string merged_str;
// since reply for first key indicated that it is for a big get request,
// perform get request on chunk keys
for (int i = 1; i < num_chunks + 1; i++) {
auto chunk_key = folly::format(
"key_get|#|{}:{}", i-1, rand_suffix_get).str();
EXPECT_EQ(chunk_key, keys_get[i]);
merged_str.append(init_reply);
}
// each chunk_key saw value as init_reply.
// In GetLike path, it gets appended num_chunks time
EXPECT_TRUE(toString(f_get.value()) == merged_str);
}
{ // Test Get Like path with init_reply_error
McrouterRouteHandle<BigValueRoute> rh(route_handles[1], opts);
auto msg = createMcMsgRef("key_get");
msg->op = mc_op_get;
ProxyMcRequest req_get(std::move(msg));
auto f_get = rh.route(req_get, McOperation<mc_op_get>(), ctx);
auto keys_get = test_handles[1]->saw_keys;
EXPECT_TRUE(keys_get.size() == 1);
// first get the result for original key, then return mc_res_notfound
EXPECT_TRUE(keys_get.front() == "key_get");
EXPECT_TRUE(f_get.result() == mc_res_notfound);
EXPECT_TRUE(toString(f_get.value()) == "");
}
{ // Test Update Like path with mc_op_set op
McrouterRouteHandle<BigValueRoute> rh(route_handles[2], opts);
std::string big_value = folly::to<std::string>(
std::string(threshold*(num_chunks/2), 't'),
std::string(threshold*(num_chunks/2), 's'));
std::string chunk_type_1 = std::string(threshold, 't');
std::string chunk_type_2 = std::string(threshold, 's');
auto msg_set = createMcMsgRef("key_set", big_value);
msg_set->op = mc_op_set;
ProxyMcRequest req_set(std::move(msg_set));
auto f_set = rh.route(req_set, McOperation<mc_op_set>(), ctx);
auto keys_set = test_handles[2]->saw_keys;
auto values_set = test_handles[2]->sawValues;
EXPECT_TRUE(keys_set.size() == num_chunks + 1);
std::string rand_suffix_set;
// first set chunk values corresponding to chunk keys
for(int i = 0; i < num_chunks; i++) {
auto chunk_key_prefix = folly::format("key_set|#|{}:", i).str();
auto length = chunk_key_prefix.length();
auto saw_prefix = keys_set[i].substr(0, length);
EXPECT_TRUE(saw_prefix == chunk_key_prefix);
if (rand_suffix_set.empty()) { // rand_suffic same for all chunk_keys
rand_suffix_set = keys_set[i].substr(length);
} else {
EXPECT_TRUE(rand_suffix_set == keys_set[i].substr(length));
}
//.........这里部分代码省略.........
开发者ID:apinski-cavium,项目名称:mcrouter,代码行数:101,代码来源:BigValueRouteTest.cpp
示例11: TEST
TEST(RouteHandleFactoryTest, sanity) {
TestFiberManager fm;
auto router = getTestRouter();
auto proxy = router->getProxy(0);
PoolFactory pf(folly::dynamic::object(), router->configApi());
McRouteHandleProvider provider(*proxy, pf);
RouteHandleFactory<McrouterRouteHandleIf> factory(provider);
auto rh = factory.create("AllAsyncRoute|ErrorRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->route(McRequestWithMcOp<mc_op_get>("a"));
EXPECT_EQ(reply.result(), mc_res_notfound);
});
rh = factory.create("AllFastestRoute|ErrorRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->route(McRequestWithMcOp<mc_op_get>("a"));
EXPECT_TRUE(reply.isError());
});
rh = factory.create("AllInitialRoute|ErrorRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->route(McRequestWithMcOp<mc_op_get>("a"));
EXPECT_TRUE(reply.isError());
});
rh = factory.create("AllMajorityRoute|ErrorRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->route(McRequestWithMcOp<mc_op_get>("a"));
EXPECT_TRUE(reply.isError());
});
rh = factory.create("AllSyncRoute|ErrorRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->route(McRequestWithMcOp<mc_op_get>("a"));
EXPECT_TRUE(reply.isError());
});
rh = factory.create("FailoverRoute|NullRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->route(McRequestWithMcOp<mc_op_get>("a"));
EXPECT_EQ(reply.result(), mc_res_notfound);
});
rh = factory.create("HashRoute|ErrorRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->route(McRequestWithMcOp<mc_op_get>("a"));
EXPECT_TRUE(reply.isError());
});
rh = factory.create("HostIdRoute|ErrorRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->route(McRequestWithMcOp<mc_op_get>("a"));
EXPECT_TRUE(reply.isError());
});
rh = factory.create("LatestRoute|NullRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->route(McRequestWithMcOp<mc_op_get>("a"));
EXPECT_EQ(reply.result(), mc_res_notfound);
});
rh = factory.create("LoggingRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
mockFiberContext();
auto reply = rh->route(McRequestWithMcOp<mc_op_get>("a"));
EXPECT_EQ(reply.result(), mc_res_notfound);
});
rh = factory.create("MissFailoverRoute|NullRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->route(McRequestWithMcOp<mc_op_get>("a"));
EXPECT_EQ(reply.result(), mc_res_notfound);
});
rh = factory.create("RandomRoute|ErrorRoute");
EXPECT_TRUE(rh != nullptr);
fm.run([&rh]() {
auto reply = rh->route(McRequestWithMcOp<mc_op_get>("a"));
EXPECT_TRUE(reply.isError());
});
}
开发者ID:DennyLoko,项目名称:mcrouter,代码行数:94,代码来源:route_handle_factory_test.cpp
注:本文中的TestFiberManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论