MCPcopy Create free account
hub / github.com/Tencent/phxqueue / CheckTopicConfig

Method CheckTopicConfig

phxqueue/test/check_config.cpp:70–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70void CheckConfig::CheckTopicConfig(const int topic_id, const config::TopicConfig *topic_config) {
71
72 auto &&topic = topic_config->GetProto().topic();
73 PHX_ASSERT(topic_id, ==, topic.topic_id());
74 for (int i{0}; i < topic.handle_ids_size(); ++i) {
75 auto handle_id = topic.handle_ids(i);
76 int rank;
77 PHX_ASSERT(phxqueue::comm::as_integer(comm::RetCode::RET_OK), ==, phxqueue::comm::as_integer(topic_config->GetHandleIDRank(handle_id, rank)));
78 PHX_ASSERT(rank, ==, i);
79 }
80
81 // pub
82 std::vector<std::shared_ptr<const config::proto::Pub>> pubs;
83 PHX_ASSERT(phxqueue::comm::as_integer(comm::RetCode::RET_OK), ==, phxqueue::comm::as_integer(topic_config->GetAllPub(pubs)));
84
85 std::set<int> pub_ids;
86 PHX_ASSERT(phxqueue::comm::as_integer(comm::RetCode::RET_OK), ==, phxqueue::comm::as_integer(topic_config->GetAllPubID(pub_ids)));
87 PHX_ASSERT(pubs.size(), ==, pub_ids.size());
88 for (auto &&pub : pubs) {
89 auto pub_id = pub->pub_id();
90 PHX_ASSERT(pub_ids.end() != pub_ids.find(pub_id), ==, true);
91 PHX_ASSERT(topic_config->IsValidPubID(pub_id), ==, true);
92
93 {
94 std::shared_ptr<const config::proto::Pub> tmp_pub;
95 PHX_ASSERT(phxqueue::comm::as_integer(comm::RetCode::RET_OK), ==, phxqueue::comm::as_integer(topic_config->GetPubByPubID(pub_id, tmp_pub)));
96 PHX_ASSERT(tmp_pub->pub_id(), ==, pub_id);
97 }
98
99 {
100 std::set<int> sub_ids;
101 PHX_ASSERT(phxqueue::comm::as_integer(comm::RetCode::RET_OK), ==, phxqueue::comm::as_integer(topic_config->GetSubIDsByPubID(pub_id, sub_ids)));
102 PHX_ASSERT(pub->sub_ids_size(), ==, sub_ids.size());
103 for (int i{0}; i < pub->sub_ids_size(); ++i) {
104 auto sub_id = pub->sub_ids(i);
105 PHX_ASSERT(sub_ids.end() != sub_ids.find(sub_id), ==, true);
106 }
107 }
108 }
109
110 // sub
111 std::vector<std::shared_ptr<const config::proto::Sub>> subs;
112 PHX_ASSERT(phxqueue::comm::as_integer(comm::RetCode::RET_OK), ==, phxqueue::comm::as_integer(topic_config->GetAllSub(subs)));
113
114 std::set<int> sub_ids;
115 PHX_ASSERT(phxqueue::comm::as_integer(comm::RetCode::RET_OK), ==, phxqueue::comm::as_integer(topic_config->GetAllSubID(sub_ids)));
116 PHX_ASSERT(subs.size(), ==, sub_ids.size());
117 for (auto &&sub : subs) {
118 auto sub_id = sub->sub_id();
119 PHX_ASSERT(sub_ids.end() != sub_ids.find(sub_id), ==, true);
120 PHX_ASSERT(topic_config->IsValidSubID(sub_id), ==, true);
121
122 {
123 std::shared_ptr<const config::proto::Sub> tmp_sub;
124 PHX_ASSERT(phxqueue::comm::as_integer(comm::RetCode::RET_OK), ==, phxqueue::comm::as_integer(topic_config->GetSubBySubID(sub_id, tmp_sub)));
125 PHX_ASSERT(tmp_sub->sub_id(), ==, sub_id);
126 }
127 }

Callers

nothing calls this directly

Calls 15

as_integerFunction · 0.85
GetHandleIDRankMethod · 0.80
GetAllPubMethod · 0.80
GetAllPubIDMethod · 0.80
IsValidPubIDMethod · 0.80
GetPubByPubIDMethod · 0.80
GetSubIDsByPubIDMethod · 0.80
GetAllSubMethod · 0.80
GetAllSubIDMethod · 0.80
IsValidSubIDMethod · 0.80
GetSubBySubIDMethod · 0.80

Tested by

no test coverage detected