MCPcopy Create free account
hub / github.com/apache/brpc / TEST_F

Function TEST_F

test/brpc_redis_cluster_unittest.cpp:537–589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

535};
536
537TEST_F(RedisClusterChannelTest, basic_routing_and_multi_key_commands) {
538 brpc::RedisClusterChannel channel;
539 InitChannel(&channel);
540
541 const std::string key0 = FindKeyForNode(0);
542 const std::string key1 = FindKeyForNode(1);
543
544 {
545 brpc::RedisRequest req;
546 brpc::RedisResponse resp;
547 brpc::Controller cntl;
548 ASSERT_TRUE(req.AddCommand("mset %s v0 %s v1", key0.c_str(), key1.c_str()));
549 channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
550 ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
551 ASSERT_EQ(1, resp.reply_size());
552 ASSERT_TRUE(resp.reply(0).is_string());
553 ASSERT_EQ("OK", resp.reply(0).data());
554 }
555
556 {
557 brpc::RedisRequest req;
558 brpc::RedisResponse resp;
559 brpc::Controller cntl;
560 ASSERT_TRUE(req.AddCommand("mget %s %s", key0.c_str(), key1.c_str()));
561 channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
562 ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
563 ASSERT_EQ(1, resp.reply_size());
564 ASSERT_TRUE(resp.reply(0).is_array());
565 ASSERT_EQ(2u, resp.reply(0).size());
566 ASSERT_EQ("v0", resp.reply(0)[0].data());
567 ASSERT_EQ("v1", resp.reply(0)[1].data());
568 }
569
570 {
571 brpc::RedisRequest req;
572 brpc::RedisResponse resp;
573 brpc::Controller cntl;
574 ASSERT_TRUE(req.AddCommand("exists %s %s", key0.c_str(), key1.c_str()));
575 channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
576 ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
577 ASSERT_EQ(2, resp.reply(0).integer());
578 }
579
580 {
581 brpc::RedisRequest req;
582 brpc::RedisResponse resp;
583 brpc::Controller cntl;
584 ASSERT_TRUE(req.AddCommand("del %s %s", key0.c_str(), key1.c_str()));
585 channel.CallMethod(NULL, &cntl, &req, &resp, NULL);
586 ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
587 ASSERT_EQ(2, resp.reply(0).integer());
588 }
589}
590
591TEST_F(RedisClusterChannelTest, moved_redirection) {
592 brpc::RedisClusterChannel channel;

Callers

nothing calls this directly

Calls 15

OwnerBySlotFunction · 0.85
HashSlotFunction · 0.85
bthread_usleepFunction · 0.85
ErrorTextMethod · 0.80
reply_sizeMethod · 0.80
is_stringMethod · 0.80
is_arrayMethod · 0.80
integerMethod · 0.80
is_errorMethod · 0.80
error_messageMethod · 0.80
is_integerMethod · 0.80

Tested by

no test coverage detected