✨ feat(stellar mq): add dispatch_cb per topic
This commit is contained in:
@@ -27,7 +27,7 @@ void whitebox_test_plugin_manager_intrisic_metadata(struct stellar *st, struct p
|
||||
|
||||
//registered plugin array null
|
||||
EXPECT_TRUE(plug_mgr->registered_polling_plugin_array==NULL);
|
||||
EXPECT_TRUE(plug_mgr->registered_packet_plugin_array==NULL);
|
||||
EXPECT_TRUE(plug_mgr->registered_plugin_array==NULL);
|
||||
|
||||
EXPECT_TRUE(plug_mgr->per_thread_data!=NULL);
|
||||
int thread_num=stellar_get_worker_thread_num(st);
|
||||
@@ -102,7 +102,7 @@ TEST(plugin_manager_init, packet_mq_topic_create_and_update) {
|
||||
|
||||
EXPECT_EQ(stellar_mq_get_topic_id(&st, topic_name), -1); // illegal topic_name
|
||||
|
||||
int topic_id = stellar_mq_create_topic(&st, topic_name, test_mock_packet_msg_free, &st);
|
||||
int topic_id = stellar_mq_create_topic(&st, topic_name, NULL, test_mock_packet_msg_free, &st);
|
||||
EXPECT_GE(topic_id, 0);
|
||||
struct stellar_mq_topic_schema *topic_schema = NULL;
|
||||
{
|
||||
@@ -116,7 +116,7 @@ TEST(plugin_manager_init, packet_mq_topic_create_and_update) {
|
||||
}
|
||||
|
||||
EXPECT_EQ(stellar_mq_get_topic_id(&st, topic_name), topic_id);
|
||||
EXPECT_EQ(stellar_mq_create_topic(&st, topic_name, test_mock_overwrite_packet_msg_free, plug_mgr),
|
||||
EXPECT_EQ(stellar_mq_create_topic(&st, topic_name, NULL, test_mock_overwrite_packet_msg_free, plug_mgr),
|
||||
-1); // duplicate create, return error
|
||||
{
|
||||
SCOPED_TRACE("White-box test, check stellar internal schema");
|
||||
@@ -128,7 +128,7 @@ TEST(plugin_manager_init, packet_mq_topic_create_and_update) {
|
||||
EXPECT_STREQ(topic_schema->topic_name, topic_name);
|
||||
}
|
||||
|
||||
EXPECT_EQ(stellar_mq_update_topic(&st, topic_id, test_mock_overwrite_packet_msg_free, plug_mgr), 0);
|
||||
EXPECT_EQ(stellar_mq_update_topic(&st, topic_id, NULL, test_mock_overwrite_packet_msg_free, plug_mgr), 0);
|
||||
|
||||
{
|
||||
SCOPED_TRACE("White-box test, check stellar internal schema");
|
||||
@@ -166,7 +166,7 @@ TEST(plugin_manager_init, packet_mq_subscribe) {
|
||||
|
||||
const char *topic_name="PACKET_TOPIC";
|
||||
|
||||
int topic_id=stellar_mq_create_topic(&st, topic_name, test_mock_packet_msg_free, &st);
|
||||
int topic_id=stellar_mq_create_topic(&st, topic_name, NULL, test_mock_packet_msg_free, &st);
|
||||
EXPECT_GE(topic_id, 0);
|
||||
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, topic_id, test_mock_on_packet_msg, 10),-1);//illgeal plugin_id
|
||||
@@ -246,7 +246,7 @@ TEST(plugin_manager, packet_plugin_illegal_exdata) {
|
||||
|
||||
{
|
||||
SCOPED_TRACE("White-box test, check stellar internal schema");
|
||||
int packet_plugin_num = utarray_len(plug_mgr->registered_packet_plugin_array);
|
||||
int packet_plugin_num = utarray_len(plug_mgr->registered_plugin_array);
|
||||
EXPECT_EQ(packet_plugin_num, 1);
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ TEST(plugin_manager, packet_plugins_with_proto_filter) {
|
||||
|
||||
{
|
||||
SCOPED_TRACE("White-box test, check stellar internal schema");
|
||||
EXPECT_EQ(utarray_len(plug_mgr->registered_packet_plugin_array), proto_filter_plugin_num);
|
||||
EXPECT_EQ(utarray_len(plug_mgr->registered_plugin_array), proto_filter_plugin_num);
|
||||
}
|
||||
|
||||
struct packet pkt={&st, IPv4, 0};
|
||||
@@ -420,7 +420,7 @@ TEST(plugin_manager, packet_plugins_share_exdata) {
|
||||
|
||||
{
|
||||
SCOPED_TRACE("White-box test, check stellar internal schema");
|
||||
EXPECT_EQ(utarray_len(plug_mgr->registered_packet_plugin_array), 2); // Fix plugin number
|
||||
EXPECT_EQ(utarray_len(plug_mgr->registered_plugin_array), 2); // Fix plugin number
|
||||
}
|
||||
|
||||
struct packet pkt={&st, IPv4, ip_proto};
|
||||
@@ -490,7 +490,7 @@ TEST(plugin_manager, packet_plugins_mq_pub_sub) {
|
||||
for(int i=0; i<topic_id_num; i++)
|
||||
{
|
||||
sprintf(topic_name[i], "PACKET_TOPIC_%d", i);
|
||||
env.packet_topic_id[i]=stellar_mq_create_topic(&st, topic_name[i], test_packet_msg_free_cb_func, &env);
|
||||
env.packet_topic_id[i]=stellar_mq_create_topic(&st, topic_name[i], NULL, test_packet_msg_free_cb_func, &env);
|
||||
EXPECT_GE(env.packet_topic_id[i], 0);
|
||||
{
|
||||
SCOPED_TRACE("White-box test, check stellar internal schema");
|
||||
@@ -525,7 +525,7 @@ TEST(plugin_manager, packet_plugins_mq_pub_sub) {
|
||||
|
||||
{
|
||||
SCOPED_TRACE("White-box test, check stellar internal schema");
|
||||
EXPECT_EQ(utarray_len(plug_mgr->registered_packet_plugin_array), topic_sub_num+1);
|
||||
EXPECT_EQ(utarray_len(plug_mgr->registered_plugin_array), topic_sub_num+1);
|
||||
}
|
||||
|
||||
struct packet pkt={&st, IPv4, ip_proto};
|
||||
@@ -607,7 +607,7 @@ TEST(plugin_manager, packet_plugins_pub_overlimit) {
|
||||
for(int i=0; i<topic_id_num; i++)
|
||||
{
|
||||
sprintf(topic_name[i], "PACKET_TOPIC_%d", i);
|
||||
env.packet_topic_id[i]=stellar_mq_create_topic(&st, topic_name[i], overlimit_packet_msg_free_cb_func, &env);
|
||||
env.packet_topic_id[i]=stellar_mq_create_topic(&st, topic_name[i], NULL, overlimit_packet_msg_free_cb_func, &env);
|
||||
EXPECT_GE(env.packet_topic_id[i], 0);
|
||||
{
|
||||
SCOPED_TRACE("White-box test, check stellar internal schema");
|
||||
@@ -642,7 +642,7 @@ TEST(plugin_manager, packet_plugins_pub_overlimit) {
|
||||
|
||||
{
|
||||
SCOPED_TRACE("White-box test, check stellar internal schema");
|
||||
EXPECT_EQ(utarray_len(plug_mgr->registered_packet_plugin_array), topic_sub_num+1);
|
||||
EXPECT_EQ(utarray_len(plug_mgr->registered_plugin_array), topic_sub_num+1);
|
||||
}
|
||||
|
||||
struct packet pkt={&st, IPv4, ip_proto};
|
||||
@@ -712,7 +712,7 @@ TEST(plugin_manager, packet_plugin_exdata_free_pub_msg) {
|
||||
EXPECT_GE(plugin_id, 0);
|
||||
|
||||
env.packet_exdata_idx[0]=stellar_exdata_new_index(&st, "PACKET_EXDATA", test_exdata_free_pub_msg_exdata_free, &env);
|
||||
env.packet_topic_id[0]=stellar_mq_create_topic(&st, "PACKET_TOPIC", test_exdata_free_pub_msg_free, &env);
|
||||
env.packet_topic_id[0]=stellar_mq_create_topic(&st, "PACKET_TOPIC", NULL, test_exdata_free_pub_msg_free, &env);
|
||||
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.packet_topic_id[0], test_exdata_free_pub_msg_on_packet_msg, plugin_id),0);
|
||||
|
||||
@@ -776,7 +776,7 @@ TEST(plugin_manager_init, session_mq_topic_create_and_update) {
|
||||
|
||||
EXPECT_EQ(stellar_mq_get_topic_id(&st, topic_name), -1);// illegal topic_name
|
||||
|
||||
int topic_id=stellar_mq_create_topic(&st, topic_name, test_mock_session_msg_free, &st);
|
||||
int topic_id=stellar_mq_create_topic(&st, topic_name, NULL, test_mock_session_msg_free, &st);
|
||||
EXPECT_GE(topic_id, 0);
|
||||
struct stellar_mq_topic_schema *topic_schema;
|
||||
{
|
||||
@@ -790,7 +790,7 @@ TEST(plugin_manager_init, session_mq_topic_create_and_update) {
|
||||
}
|
||||
|
||||
EXPECT_EQ(stellar_mq_get_topic_id(&st, topic_name), topic_id);
|
||||
EXPECT_EQ(stellar_mq_create_topic(&st, topic_name, test_mock_overwrite_session_msg_free, plug_mgr), -1); // duplicate create, return error
|
||||
EXPECT_EQ(stellar_mq_create_topic(&st, topic_name, NULL, test_mock_overwrite_session_msg_free, plug_mgr), -1); // duplicate create, return error
|
||||
|
||||
{
|
||||
SCOPED_TRACE("White-box test, check stellar internal schema");
|
||||
@@ -802,7 +802,7 @@ TEST(plugin_manager_init, session_mq_topic_create_and_update) {
|
||||
EXPECT_STREQ(topic_schema->topic_name, topic_name);
|
||||
}
|
||||
|
||||
EXPECT_EQ(stellar_mq_update_topic(&st, topic_id, test_mock_overwrite_session_msg_free, plug_mgr), 0);
|
||||
EXPECT_EQ(stellar_mq_update_topic(&st, topic_id, NULL, test_mock_overwrite_session_msg_free, plug_mgr), 0);
|
||||
|
||||
{
|
||||
SCOPED_TRACE("White-box test, check stellar internal schema");
|
||||
@@ -842,7 +842,7 @@ TEST(plugin_manager_init, session_mq_subscribe_overwrite) {
|
||||
|
||||
const char *topic_name="SESSION_TOPIC";
|
||||
|
||||
int topic_id=stellar_mq_create_topic(&st, topic_name, test_mock_session_msg_free, &st);
|
||||
int topic_id=stellar_mq_create_topic(&st, topic_name, NULL, test_mock_session_msg_free, &st);
|
||||
EXPECT_GE(topic_id, 0);
|
||||
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, topic_id, test_mock_on_session_msg, 10),-1);//illgeal plugin_id
|
||||
@@ -1014,11 +1014,11 @@ TEST(plugin_manager, session_plugin_on_intrinsic_ingress_egress) {
|
||||
int plugin_id=stellar_plugin_register(&st, 0, NULL, NULL, &env);
|
||||
EXPECT_GE(plugin_id, 0);
|
||||
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL);
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL, NULL);
|
||||
EXPECT_GE(env.intrinsc_tcp_topic_id, 0);
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.intrinsc_tcp_topic_id, test_basic_on_session_ingress, plugin_id), 0);
|
||||
|
||||
env.intrinsc_egress_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_OUTPUT, NULL, NULL);
|
||||
env.intrinsc_egress_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_OUTPUT, NULL, NULL, NULL);
|
||||
EXPECT_GE(env.intrinsc_egress_topic_id, 0);
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.intrinsc_egress_topic_id, test_basic_on_session_ingress, plugin_id), 0);// Intentional error
|
||||
|
||||
@@ -1122,11 +1122,11 @@ TEST(plugin_manager, DISABLED_session_plugin_ignore_on_ctx_new_sub_other_msg) {
|
||||
env.test_mq_pub_plugin_id=stellar_plugin_register(&st, 0, NULL, NULL,&env);
|
||||
EXPECT_GE(env.test_mq_pub_plugin_id, 0);
|
||||
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL);
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL, NULL);
|
||||
EXPECT_GE(env.intrinsc_tcp_topic_id, 0);
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.intrinsc_tcp_topic_id, test_mq_pub_on_session, env.test_mq_pub_plugin_id), 0);
|
||||
|
||||
env.test_mq_topic_id=stellar_mq_create_topic(&st, "SESSION_MQ_TOPIC", test_session_msg_free, &env);
|
||||
env.test_mq_topic_id=stellar_mq_create_topic(&st, "SESSION_MQ_TOPIC", NULL, test_session_msg_free, &env);
|
||||
EXPECT_GE(env.test_mq_topic_id, 0);
|
||||
|
||||
env.test_mq_sub_plugin_id=stellar_plugin_register(&st, 0, NULL, NULL, &env);
|
||||
@@ -1288,11 +1288,11 @@ TEST(plugin_manager,DISABLED_session_plugin_pub_msg_overlimt) {
|
||||
env.test_mq_pub_plugin_id=stellar_plugin_register(&st, 0, NULL, NULL, &env);
|
||||
EXPECT_GE(env.test_mq_pub_plugin_id, 0);
|
||||
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL);
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL, NULL);
|
||||
EXPECT_GE(env.intrinsc_tcp_topic_id, 0);
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.intrinsc_tcp_topic_id, test_overlimit_pub_on_session, env.test_mq_pub_plugin_id), 0);
|
||||
|
||||
env.test_mq_topic_id=stellar_mq_create_topic(&st, "SESSION_MQ_TOPIC", test_overlimit_session_msg_free, &env);
|
||||
env.test_mq_topic_id=stellar_mq_create_topic(&st, "SESSION_MQ_TOPIC", NULL, test_overlimit_session_msg_free, &env);
|
||||
EXPECT_GE(env.test_mq_topic_id, 0);
|
||||
|
||||
env.test_mq_sub_plugin_id=stellar_plugin_register(&st, 0, NULL, NULL, &env);
|
||||
@@ -1399,11 +1399,11 @@ TEST(plugin_manager, DISABLED_session_plugin_on_ctx_new_then_dettach) {
|
||||
int plugin_id=stellar_plugin_register(&st, 0, NULL, NULL, &env);
|
||||
EXPECT_GE(plugin_id,0);
|
||||
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL);
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL, NULL);
|
||||
EXPECT_GE(env.intrinsc_tcp_topic_id, 0);
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.intrinsc_tcp_topic_id, test_dettach_on_session, plugin_id), 0);
|
||||
|
||||
env.test_mq_topic_id=stellar_mq_create_topic(&st, "SESSION_MQ_TOPIC", test_dettach_msg_free, &env);
|
||||
env.test_mq_topic_id=stellar_mq_create_topic(&st, "SESSION_MQ_TOPIC", NULL, test_dettach_msg_free, &env);
|
||||
EXPECT_GE(env.test_mq_topic_id, 0);
|
||||
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.test_mq_topic_id, test_dettach_on_session, plugin_id), 0);
|
||||
@@ -1486,11 +1486,11 @@ TEST(plugin_manager, DISABLED_session_plugin_pub_on_ctx_free) {
|
||||
int plugin_id=stellar_plugin_register(&st, 0, NULL, NULL, &env);
|
||||
EXPECT_GE(plugin_id,0);
|
||||
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL);
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL, NULL);
|
||||
EXPECT_GE(env.intrinsc_tcp_topic_id, 0);
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.intrinsc_tcp_topic_id, test_invalid_pub_msg_on_session, plugin_id), 0);
|
||||
|
||||
env.test_mq_topic_id=stellar_mq_create_topic(&st, "SESSION_MQ_TOPIC", NULL, &env);
|
||||
env.test_mq_topic_id=stellar_mq_create_topic(&st, "SESSION_MQ_TOPIC", NULL, NULL, &env);
|
||||
EXPECT_GE(env.test_mq_topic_id, 0);
|
||||
|
||||
// pesudo packet and session
|
||||
@@ -1608,11 +1608,11 @@ TEST(plugin_manager, DISABLED_session_plugin_pub_msg_on_closing) {
|
||||
int plugin_id=stellar_plugin_register(&st, 0, NULL, NULL, &env);
|
||||
EXPECT_GE(plugin_id,0);
|
||||
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL);
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL, NULL);
|
||||
EXPECT_GE(env.intrinsc_tcp_topic_id, 0);
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.intrinsc_tcp_topic_id, test_session_closing_on_intrisic_msg, plugin_id), 0);
|
||||
|
||||
env.test_mq_topic_id=stellar_mq_create_topic(&st, "SESSION_CLOSING_TOPIC", NULL, &env);
|
||||
env.test_mq_topic_id=stellar_mq_create_topic(&st, "SESSION_CLOSING_TOPIC", NULL, NULL, &env);
|
||||
EXPECT_GE(env.test_mq_topic_id, 0);
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.test_mq_topic_id, test_session_closing_on_userdefine_msg, plugin_id), 0);
|
||||
|
||||
@@ -1729,7 +1729,7 @@ TEST(plugin_manager, DISABLED_test_session_mq_topic_is_active) {
|
||||
env.plugin_id_1=plugin_id_1;
|
||||
env.plugin_id_2=plugin_id_2;
|
||||
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL);
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL, NULL);
|
||||
EXPECT_GE(env.intrinsc_tcp_topic_id, 0);
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.intrinsc_tcp_topic_id, test_session_mq_topic_is_active_plugin_1_on_msg, plugin_id_1), 0);
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.intrinsc_tcp_topic_id, test_session_mq_topic_is_active_plugin_2_on_msg, plugin_id_2), 0);
|
||||
@@ -1828,7 +1828,7 @@ TEST(plugin_manager, DISABLED_test_session_dettach) {
|
||||
env.plugin_id_1=plugin_id_1;
|
||||
env.plugin_id_2=plugin_id_2;
|
||||
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL);
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL, NULL);
|
||||
EXPECT_GE(env.intrinsc_tcp_topic_id, 0);
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.intrinsc_tcp_topic_id, test_session_dettach_plugin_1_on_msg, plugin_id_1), 0);
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.intrinsc_tcp_topic_id, test_session_dettach_plugin_2_on_msg, plugin_id_2), 0);
|
||||
@@ -1974,7 +1974,7 @@ TEST(plugin_manager, test_session_mq_priority) {
|
||||
env.exdata_ctx_1_id=stellar_exdata_new_index(&st, "SESSION_CTX_1", stellar_exdata_free_default, &env) ;
|
||||
env.exdata_ctx_2_id=stellar_exdata_new_index(&st, "SESSION_CTX_2", stellar_exdata_free_default, &env) ;
|
||||
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL);
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL, NULL);
|
||||
EXPECT_GE(env.intrinsc_tcp_topic_id, 0);
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.intrinsc_tcp_topic_id, test_session_mq_priority_plugin_1_on_msg, plugin_id_1), 0);
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.intrinsc_tcp_topic_id, test_session_mq_priority_plugin_2_on_msg, plugin_id_2), 0);
|
||||
@@ -2063,7 +2063,7 @@ TEST(plugin_manager, session_exdata_free_pub_msg) {
|
||||
env.plugin_id_1=stellar_plugin_register(&st, 0, NULL, NULL, &env);
|
||||
EXPECT_GE(env.plugin_id_1,0);
|
||||
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL);
|
||||
env.intrinsc_tcp_topic_id=stellar_mq_create_topic(&st, TOPIC_TCP_INPUT, NULL, NULL, NULL);
|
||||
EXPECT_GE(env.intrinsc_tcp_topic_id, 0);
|
||||
EXPECT_EQ(stellar_mq_subscribe(&st, env.intrinsc_tcp_topic_id, test_session_exdata_free_pub_msg_on_session, env.plugin_id_1), 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user