feat(infra/exdata): exdata as independent component

This commit is contained in:
yangwei
2024-09-06 18:36:24 +08:00
parent 3de8bbdabc
commit a24214cbee
12 changed files with 270 additions and 177 deletions

View File

@@ -2,6 +2,9 @@
#include <gtest/gtest.h>
#include "stellar/utils.h"
#include "stellar/stellar_exdata.h"
#include "exdata/exdata_internal.h"
#include "plugin_manager_gtest_mock.h"
@@ -20,7 +23,7 @@ void whitebox_test_plugin_manager_intrisic_metadata(struct stellar *st, struct p
EXPECT_TRUE(plug_mgr->plugin_load_specs_array==NULL);
//session exdata schema null
EXPECT_TRUE(plug_mgr->stellar_exdata_schema_array==NULL);
EXPECT_TRUE(plug_mgr->exdata_schema!=NULL);
//stellar mq schema null
EXPECT_TRUE(plug_mgr->stellar_mq_schema_array==NULL);
@@ -33,7 +36,7 @@ void whitebox_test_plugin_manager_intrisic_metadata(struct stellar *st, struct p
int thread_num=stellar_get_worker_thread_num(st);
for(int i=0; i<thread_num; i++)
{
EXPECT_TRUE(plug_mgr->per_thread_data[i].per_thread_pkt_exdata_array.exdata_array==NULL);
EXPECT_TRUE(plug_mgr->per_thread_data[i].exdata_array==NULL);
EXPECT_TRUE(plug_mgr->per_thread_data[i].dealth_letter_queue==NULL);
for(int j=0; j<STELLAR_MQ_PRIORITY_MAX; j++)
EXPECT_TRUE(plug_mgr->per_thread_data[i].priority_mq[j]==NULL);
@@ -76,14 +79,14 @@ TEST(plugin_manager_init, packet_exdata_new_index_overwrite) {
{
SCOPED_TRACE("White-box test, check stellar internal schema");
struct stellar_exdata_schema *exdata_schema = (struct stellar_exdata_schema *)utarray_eltptr(
plug_mgr->stellar_exdata_schema_array, (unsigned int)exdata_idx);
struct exdata_meta *exdata_schema = (struct exdata_meta *)utarray_eltptr(
plug_mgr->exdata_schema->exdata_meta_array, (unsigned int)exdata_idx);
EXPECT_EQ(exdata_schema->free_func, (void *)test_mock_overwrite_packet_exdata_free);
EXPECT_EQ(exdata_schema->free_arg, plug_mgr);
EXPECT_EQ(exdata_schema->idx, exdata_idx);
EXPECT_STREQ(exdata_schema->name, exdata_name);
int exdata_num = utarray_len(plug_mgr->stellar_exdata_schema_array);
int exdata_num = utarray_len(plug_mgr->exdata_schema->exdata_meta_array);
EXPECT_EQ(exdata_num, 1);
}
@@ -210,14 +213,14 @@ TEST(plugin_manager_init, session_exdata_new_index_overwrite) {
{
SCOPED_TRACE("White-box test, check stellar internal schema");
struct stellar_exdata_schema *exdata_schema = (struct stellar_exdata_schema *)utarray_eltptr(
plug_mgr->stellar_exdata_schema_array, (unsigned int)exdata_idx);
struct exdata_meta *exdata_schema = (struct exdata_meta *)utarray_eltptr(
plug_mgr->exdata_schema->exdata_meta_array, (unsigned int)exdata_idx);
EXPECT_EQ(exdata_schema->free_func, (void *)test_mock_overwrite_session_exdata_free);
EXPECT_EQ(exdata_schema->free_arg, plug_mgr);
EXPECT_EQ(exdata_schema->idx, exdata_idx);
EXPECT_STREQ(exdata_schema->name, exdata_name);
int exdata_num = utarray_len(plug_mgr->stellar_exdata_schema_array);
int exdata_num = utarray_len(plug_mgr->exdata_schema->exdata_meta_array);
EXPECT_EQ(exdata_num, 1);
}
plugin_manager_exit(plug_mgr);
@@ -497,8 +500,8 @@ TEST(plugin_manager, packet_plugins_share_exdata) {
env.packet_exdata_idx[i]=stellar_exdata_new_index(&st, exdata_name[i], test_packet_exdata_free, &env);
{
SCOPED_TRACE("White-box test, check stellar internal schema");
struct stellar_exdata_schema *exdata_schema = (struct stellar_exdata_schema *)utarray_eltptr(
plug_mgr->stellar_exdata_schema_array, env.packet_exdata_idx[i]);
struct exdata_meta *exdata_schema = (struct exdata_meta *)utarray_eltptr(
plug_mgr->exdata_schema->exdata_meta_array, env.packet_exdata_idx[i]);
EXPECT_EQ(exdata_schema->free_func, (void *)test_packet_exdata_free);
EXPECT_EQ(exdata_schema->free_arg, &env);
@@ -509,7 +512,7 @@ TEST(plugin_manager, packet_plugins_share_exdata) {
{
SCOPED_TRACE("White-box test, check stellar internal schema");
EXPECT_EQ(utarray_len(plug_mgr->stellar_exdata_schema_array), exdata_idx_len);
EXPECT_EQ(utarray_len(plug_mgr->exdata_schema->exdata_meta_array), exdata_idx_len);
}
int exdata_set_plugin_id=stellar_plugin_register(&st, test_exdata_set_on_packet, NULL,&env);