fix group_exclude logic miss & add some corner case
This commit is contained in:
@@ -30,12 +30,14 @@ target_link_libraries(maat_ex_data_gtest maat_frame_static gtest_static)
|
||||
add_subdirectory(group_exclude)
|
||||
|
||||
file(COPY table_info.conf DESTINATION ./)
|
||||
file(COPY tsg_table_info.conf DESTINATION ./)
|
||||
file(COPY file_test_tableinfo.conf DESTINATION ./)
|
||||
file(COPY literal_expr.conf DESTINATION ./)
|
||||
file(COPY regex_expr.conf DESTINATION ./)
|
||||
file(COPY maat_json.json DESTINATION ./)
|
||||
file(COPY maat_json.json DESTINATION ../tools/)
|
||||
file(COPY ntcrule DESTINATION ./)
|
||||
file(COPY tsgrule DESTINATION ./)
|
||||
file(COPY testdata DESTINATION ./)
|
||||
file(COPY test_streamfiles DESTINATION ./)
|
||||
file(COPY json_update DESTINATION ./)
|
||||
|
||||
136
test/group_exclude/group_exclude_L4.conf
Normal file
136
test/group_exclude/group_exclude_L4.conf
Normal file
@@ -0,0 +1,136 @@
|
||||
{
|
||||
"add_items": [
|
||||
{
|
||||
"group_id": 14,
|
||||
"super_group_id": 8,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 14,
|
||||
"super_group_id": 9,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 8,
|
||||
"super_group_id": 5,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 9,
|
||||
"super_group_id": 1,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 16,
|
||||
"super_group_id": 9,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 16,
|
||||
"super_group_id": 10,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 10,
|
||||
"super_group_id": 7,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 7,
|
||||
"super_group_id": 6,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 6,
|
||||
"super_group_id": 1,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 17,
|
||||
"super_group_id": 11,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 17,
|
||||
"super_group_id": 12,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 17,
|
||||
"super_group_id":13,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 11,
|
||||
"super_group_id": 6,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 12,
|
||||
"super_group_id": 7,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 7,
|
||||
"super_group_id": 2,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 7,
|
||||
"super_group_id": 4,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 13,
|
||||
"super_group_id": 3,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 15,
|
||||
"super_group_id": 8,
|
||||
"is_exclude": 1
|
||||
},
|
||||
{
|
||||
"group_id": 9,
|
||||
"super_group_id": 5,
|
||||
"is_exclude": 1
|
||||
},
|
||||
{
|
||||
"group_id": 5,
|
||||
"super_group_id": 1,
|
||||
"is_exclude": 1
|
||||
},
|
||||
{
|
||||
"group_id": 10,
|
||||
"super_group_id": 6,
|
||||
"is_exclude": 1
|
||||
},
|
||||
{
|
||||
"group_id": 6,
|
||||
"super_group_id": 2,
|
||||
"is_exclude": 1
|
||||
},
|
||||
{
|
||||
"group_id": 6,
|
||||
"super_group_id": 3,
|
||||
"is_exclude": 1
|
||||
},
|
||||
{
|
||||
"group_id": 18,
|
||||
"super_group_id":13,
|
||||
"is_exclude": 1
|
||||
},
|
||||
{
|
||||
"group_id": 13,
|
||||
"super_group_id": 4,
|
||||
"is_exclude": 1
|
||||
}
|
||||
],
|
||||
"del_items": [
|
||||
{
|
||||
"group_id": 10,
|
||||
"super_group_id": 6,
|
||||
"is_exclude": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
test/group_exclude/group_exclude_L4.png
Normal file
BIN
test/group_exclude/group_exclude_L4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 74 KiB |
76
test/group_exclude/group_exclude_exceed.conf
Normal file
76
test/group_exclude/group_exclude_exceed.conf
Normal file
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"add_items": [
|
||||
{
|
||||
"group_id": 6,
|
||||
"super_group_id": 3,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 3,
|
||||
"super_group_id": 1,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 7,
|
||||
"super_group_id": 1,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 7,
|
||||
"super_group_id": 3,
|
||||
"is_exclude": 1
|
||||
},
|
||||
{
|
||||
"group_id": 13,
|
||||
"super_group_id": 10,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 10,
|
||||
"super_group_id": 11,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 11,
|
||||
"super_group_id": 8,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 8,
|
||||
"super_group_id": 5,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 5,
|
||||
"super_group_id": 4,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 5,
|
||||
"super_group_id": 12,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 4,
|
||||
"super_group_id": 2,
|
||||
"is_exclude": 0
|
||||
},
|
||||
{
|
||||
"group_id": 4,
|
||||
"super_group_id": 1,
|
||||
"is_exclude": 1
|
||||
},
|
||||
{
|
||||
"group_id": 2,
|
||||
"super_group_id": 12,
|
||||
"is_exclude": 1
|
||||
}
|
||||
],
|
||||
"del_items": [
|
||||
{
|
||||
"group_id": 13,
|
||||
"super_group_id": 10,
|
||||
"is_exclude": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
test/group_exclude/group_exclude_exceed.png
Normal file
BIN
test/group_exclude/group_exclude_exceed.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
@@ -11,6 +11,7 @@
|
||||
|
||||
#define MAX_ITEM_NUM 64
|
||||
#define WAIT_FOR_EFFECTIVE_S 2
|
||||
#define MAX_G2G_SCAN_TIMES (1000 * 1000)
|
||||
|
||||
const char *table_info_path = "./table_info.conf";
|
||||
|
||||
@@ -138,38 +139,34 @@ protected:
|
||||
log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_schema_new failed.");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
|
||||
if (NULL == g2g_runtime) {
|
||||
log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
log_handle_destroy(logger);
|
||||
maat_garbage_bin_free(garbage_bin);
|
||||
group2group_runtime_free(g2g_runtime);
|
||||
group2group_schema_free(g2g_schema);
|
||||
}
|
||||
|
||||
static void *g2g_schema;
|
||||
static void *g2g_runtime;
|
||||
static struct log_handle *logger;
|
||||
static struct maat_garbage_bin *garbage_bin;
|
||||
};
|
||||
|
||||
void *MaatGroupExclude::g2g_schema;
|
||||
void *MaatGroupExclude::g2g_runtime;
|
||||
struct log_handle *MaatGroupExclude::logger;
|
||||
struct maat_garbage_bin *MaatGroupExclude::garbage_bin;
|
||||
|
||||
TEST_F(MaatGroupExclude, level_3_basic) {
|
||||
TEST_F(MaatGroupExclude, level_3_function) {
|
||||
char table_line[1024];
|
||||
struct group2group_rule rules;
|
||||
const char *table_name = "EXCLUDE_GROUP2GROUP";
|
||||
|
||||
void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
|
||||
if (NULL == g2g_runtime) {
|
||||
log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
int ret = parse_config_file("group_exclude_L3.conf", &rules);
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
@@ -199,7 +196,7 @@ TEST_F(MaatGroupExclude, level_3_basic) {
|
||||
group2group_runtime_commit(g2g_runtime, table_name, 2);
|
||||
|
||||
super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
|
||||
super_group_ids, MAX_ITEM_NUM);
|
||||
super_group_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_group_cnt, 3);
|
||||
EXPECT_EQ(super_group_ids[0], 1);
|
||||
EXPECT_EQ(super_group_ids[1], 6);
|
||||
@@ -213,12 +210,290 @@ TEST_F(MaatGroupExclude, level_3_basic) {
|
||||
group2group_runtime_commit(g2g_runtime, table_name, 3);
|
||||
|
||||
super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
|
||||
super_group_ids, MAX_ITEM_NUM);
|
||||
super_group_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_group_cnt, 4);
|
||||
EXPECT_EQ(super_group_ids[0], 1);
|
||||
EXPECT_EQ(super_group_ids[1], 4);
|
||||
EXPECT_EQ(super_group_ids[2], 6);
|
||||
EXPECT_EQ(super_group_ids[3], 7);
|
||||
|
||||
group2group_runtime_free(g2g_runtime);
|
||||
}
|
||||
|
||||
TEST_F(MaatGroupExclude, level_3_perf) {
|
||||
char table_line[1024];
|
||||
struct group2group_rule rules;
|
||||
const char *table_name = "EXCLUDE_GROUP2GROUP";
|
||||
|
||||
void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
|
||||
if (NULL == g2g_runtime) {
|
||||
log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
int ret = parse_config_file("group_exclude_L3.conf", &rules);
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
for (size_t i = 0; i < rules.n_add_item; i++) {
|
||||
memset(table_line, 0, sizeof(table_line));
|
||||
|
||||
sprintf(table_line, "%lld\t%lld\t%d\t%d", rules.add_items[i].group_id,
|
||||
rules.add_items[i].super_group_id, rules.add_items[i].is_exclude, 1);
|
||||
group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
|
||||
}
|
||||
|
||||
group2group_runtime_commit(g2g_runtime, table_name, 4);
|
||||
|
||||
long long hit_group_ids[2] = {11, 13};
|
||||
long long super_group_ids[MAX_ITEM_NUM];
|
||||
size_t super_group_cnt = 0;
|
||||
struct timespec start, end;
|
||||
struct log_handle *logger = MaatGroupExclude::logger;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (int i = 0; i < MAX_G2G_SCAN_TIMES; i++) {
|
||||
super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
|
||||
super_group_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_group_cnt, 2);
|
||||
EXPECT_EQ(super_group_ids[0], 2);
|
||||
EXPECT_EQ(super_group_ids[1], 7);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
long long time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
|
||||
log_info(logger, MODULE_GROUP_EXCLUDE_GTEST, "level_3_basic hit 2 super_groups scan consume time %lldms",
|
||||
time_elapse_ms);
|
||||
|
||||
//delete group_id = 7, super_group_id = 6, is_exclude = 1
|
||||
memset(table_line, 0, sizeof(table_line));
|
||||
sprintf(table_line, "%lld\t%lld\t%d\t%d", rules.del_items[0].group_id,
|
||||
rules.del_items[0].super_group_id, rules.del_items[0].is_exclude, 0);
|
||||
group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
|
||||
group2group_runtime_commit(g2g_runtime, table_name, 5);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (int i = 0; i < MAX_G2G_SCAN_TIMES; i++) {
|
||||
super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
|
||||
super_group_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_group_cnt, 3);
|
||||
EXPECT_EQ(super_group_ids[0], 1);
|
||||
EXPECT_EQ(super_group_ids[1], 6);
|
||||
EXPECT_EQ(super_group_ids[2], 7);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
|
||||
log_info(logger, MODULE_GROUP_EXCLUDE_GTEST, "level_3_basic hit 3 super_groups scan consume time %lldms",
|
||||
time_elapse_ms);
|
||||
|
||||
//delete group_id = 13, super_group_id = 4, is_exclude = 1
|
||||
memset(table_line, 0, sizeof(table_line));
|
||||
sprintf(table_line, "%lld\t%lld\t%d\t%d", rules.del_items[1].group_id,
|
||||
rules.del_items[1].super_group_id, rules.del_items[1].is_exclude, 0);
|
||||
group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
|
||||
group2group_runtime_commit(g2g_runtime, table_name, 6);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (int i = 0; i < MAX_G2G_SCAN_TIMES; i++) {
|
||||
super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
|
||||
super_group_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_group_cnt, 4);
|
||||
EXPECT_EQ(super_group_ids[0], 1);
|
||||
EXPECT_EQ(super_group_ids[1], 4);
|
||||
EXPECT_EQ(super_group_ids[2], 6);
|
||||
EXPECT_EQ(super_group_ids[3], 7);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
|
||||
log_info(logger, MODULE_GROUP_EXCLUDE_GTEST, "level_3_basic hit 4 super_groups scan consume time %lldms",
|
||||
time_elapse_ms);
|
||||
|
||||
group2group_runtime_free(g2g_runtime);
|
||||
}
|
||||
|
||||
TEST_F(MaatGroupExclude, level_4_function) {
|
||||
char table_line[1024];
|
||||
struct group2group_rule rules;
|
||||
const char *table_name = "EXCLUDE_GROUP2GROUP";
|
||||
|
||||
void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
|
||||
if (NULL == g2g_runtime) {
|
||||
log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
int ret = parse_config_file("group_exclude_L4.conf", &rules);
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
for (size_t i = 0; i < rules.n_add_item; i++) {
|
||||
memset(table_line, 0, sizeof(table_line));
|
||||
|
||||
sprintf(table_line, "%lld\t%lld\t%d\t%d", rules.add_items[i].group_id,
|
||||
rules.add_items[i].super_group_id, rules.add_items[i].is_exclude, 1);
|
||||
group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
|
||||
}
|
||||
|
||||
group2group_runtime_commit(g2g_runtime, table_name, 7);
|
||||
|
||||
long long hit_group_ids[2] = {14, 16};
|
||||
long long super_group_ids[MAX_ITEM_NUM];
|
||||
size_t super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
|
||||
super_group_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_group_cnt, 5);
|
||||
EXPECT_EQ(super_group_ids[0], 4);
|
||||
EXPECT_EQ(super_group_ids[1], 7);
|
||||
EXPECT_EQ(super_group_ids[2], 8);
|
||||
EXPECT_EQ(super_group_ids[3], 9);
|
||||
EXPECT_EQ(super_group_ids[4], 10);
|
||||
|
||||
//delete group_id = 10, super_group_id = 6, is_exclude = 1
|
||||
memset(table_line, 0, sizeof(table_line));
|
||||
sprintf(table_line, "%lld\t%lld\t%d\t%d", rules.del_items[0].group_id,
|
||||
rules.del_items[0].super_group_id, rules.del_items[0].is_exclude, 0);
|
||||
group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
|
||||
group2group_runtime_commit(g2g_runtime, table_name, 8);
|
||||
|
||||
super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
|
||||
super_group_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_group_cnt, 7);
|
||||
EXPECT_EQ(super_group_ids[0], 1);
|
||||
EXPECT_EQ(super_group_ids[1], 4);
|
||||
EXPECT_EQ(super_group_ids[2], 6);
|
||||
EXPECT_EQ(super_group_ids[3], 7);
|
||||
EXPECT_EQ(super_group_ids[4], 8);
|
||||
EXPECT_EQ(super_group_ids[5], 9);
|
||||
EXPECT_EQ(super_group_ids[6], 10);
|
||||
|
||||
group2group_runtime_free(g2g_runtime);
|
||||
}
|
||||
|
||||
TEST_F(MaatGroupExclude, level_4_perf) {
|
||||
char table_line[1024];
|
||||
struct group2group_rule rules;
|
||||
const char *table_name = "EXCLUDE_GROUP2GROUP";
|
||||
|
||||
void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
|
||||
if (NULL == g2g_runtime) {
|
||||
log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
int ret = parse_config_file("group_exclude_L4.conf", &rules);
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
for (size_t i = 0; i < rules.n_add_item; i++) {
|
||||
memset(table_line, 0, sizeof(table_line));
|
||||
|
||||
sprintf(table_line, "%lld\t%lld\t%d\t%d", rules.add_items[i].group_id,
|
||||
rules.add_items[i].super_group_id, rules.add_items[i].is_exclude, 1);
|
||||
group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
|
||||
}
|
||||
|
||||
group2group_runtime_commit(g2g_runtime, table_name, 7);
|
||||
|
||||
long long hit_group_ids[2] = {14, 16};
|
||||
long long super_group_ids[MAX_ITEM_NUM];
|
||||
size_t super_group_cnt = 0;
|
||||
struct timespec start, end;
|
||||
struct log_handle *logger = MaatGroupExclude::logger;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (int i = 0; i < MAX_G2G_SCAN_TIMES; i++) {
|
||||
super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
|
||||
super_group_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_group_cnt, 5);
|
||||
EXPECT_EQ(super_group_ids[0], 4);
|
||||
EXPECT_EQ(super_group_ids[1], 7);
|
||||
EXPECT_EQ(super_group_ids[2], 8);
|
||||
EXPECT_EQ(super_group_ids[3], 9);
|
||||
EXPECT_EQ(super_group_ids[4], 10);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
long long time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
|
||||
log_info(logger, MODULE_GROUP_EXCLUDE_GTEST, "level_4_basic hit 5 super_groups scan consume time %lldms",
|
||||
time_elapse_ms);
|
||||
|
||||
//delete group_id = 10, super_group_id = 6, is_exclude = 1
|
||||
memset(table_line, 0, sizeof(table_line));
|
||||
sprintf(table_line, "%lld\t%lld\t%d\t%d", rules.del_items[0].group_id,
|
||||
rules.del_items[0].super_group_id, rules.del_items[0].is_exclude, 0);
|
||||
group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
|
||||
group2group_runtime_commit(g2g_runtime, table_name, 8);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (int i = 0; i < MAX_G2G_SCAN_TIMES; i++) {
|
||||
super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
|
||||
super_group_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_group_cnt, 7);
|
||||
EXPECT_EQ(super_group_ids[0], 1);
|
||||
EXPECT_EQ(super_group_ids[1], 4);
|
||||
EXPECT_EQ(super_group_ids[2], 6);
|
||||
EXPECT_EQ(super_group_ids[3], 7);
|
||||
EXPECT_EQ(super_group_ids[4], 8);
|
||||
EXPECT_EQ(super_group_ids[5], 9);
|
||||
EXPECT_EQ(super_group_ids[6], 10);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
|
||||
log_info(logger, MODULE_GROUP_EXCLUDE_GTEST, "level_4_basic hit 7 super_groups scan consume time %lldms",
|
||||
time_elapse_ms);
|
||||
|
||||
group2group_runtime_free(g2g_runtime);
|
||||
}
|
||||
|
||||
TEST_F(MaatGroupExclude, level_exceed_function) {
|
||||
char table_line[1024];
|
||||
struct group2group_rule rules;
|
||||
const char *table_name = "EXCLUDE_GROUP2GROUP";
|
||||
|
||||
void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
|
||||
if (NULL == g2g_runtime) {
|
||||
log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
int ret = parse_config_file("group_exclude_exceed.conf", &rules);
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
for (size_t i = 0; i < rules.n_add_item; i++) {
|
||||
memset(table_line, 0, sizeof(table_line));
|
||||
|
||||
sprintf(table_line, "%lld\t%lld\t%d\t%d", rules.add_items[i].group_id,
|
||||
rules.add_items[i].super_group_id, rules.add_items[i].is_exclude, 1);
|
||||
group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
|
||||
}
|
||||
|
||||
group2group_runtime_commit(g2g_runtime, table_name, 8);
|
||||
|
||||
long long hit_group_ids[2] = {7, 13};
|
||||
long long super_group_ids[MAX_ITEM_NUM];
|
||||
size_t super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
|
||||
super_group_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_group_cnt, 6);
|
||||
EXPECT_EQ(super_group_ids[0], 4);
|
||||
EXPECT_EQ(super_group_ids[1], 5);
|
||||
EXPECT_EQ(super_group_ids[2], 8);
|
||||
EXPECT_EQ(super_group_ids[3], 10);
|
||||
EXPECT_EQ(super_group_ids[4], 11);
|
||||
EXPECT_EQ(super_group_ids[5], 12);
|
||||
|
||||
//delete group_id = 13, super_group_id = 10, is_exclude = 0
|
||||
memset(table_line, 0, sizeof(table_line));
|
||||
sprintf(table_line, "%lld\t%lld\t%d\t%d", rules.del_items[0].group_id,
|
||||
rules.del_items[0].super_group_id, rules.del_items[0].is_exclude, 0);
|
||||
group2group_runtime_update(g2g_runtime, g2g_schema, table_name, table_line, 4);
|
||||
group2group_runtime_commit(g2g_runtime, table_name, 9);
|
||||
|
||||
hit_group_ids[0] = 7;
|
||||
hit_group_ids[1] = 10;
|
||||
super_group_cnt = group2group_runtime_get_super_groups(g2g_runtime, hit_group_ids, 2,
|
||||
super_group_ids, MAX_ITEM_NUM);
|
||||
EXPECT_EQ(super_group_cnt, 5);
|
||||
EXPECT_EQ(super_group_ids[0], 2);
|
||||
EXPECT_EQ(super_group_ids[1], 4);
|
||||
EXPECT_EQ(super_group_ids[2], 5);
|
||||
EXPECT_EQ(super_group_ids[3], 8);
|
||||
EXPECT_EQ(super_group_ids[4], 11);
|
||||
|
||||
group2group_runtime_free(g2g_runtime);
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
@@ -227,4 +502,4 @@ int main(int argc, char ** argv)
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
ret=RUN_ALL_TESTS();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -294,7 +294,8 @@ class MaatPerfStringScan : public testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestCase() {
|
||||
const char *accept_tags = "{\"tags\":[{\"tag\":\"location\",\"value\":\"北京/朝阳/华严北里/甲22号\"},{\"tag\":\"isp\",\"value\":\"移动\"},{\"tag\":\"location\",\"value\":\"Astana\"}]}";
|
||||
const char *accept_tags = "{\"tags\":[{\"tag\":\"location\",\"value\":\"北京/朝阳/华严北里/甲22号\"},"
|
||||
"{\"tag\":\"isp\",\"value\":\"移动\"},{\"tag\":\"location\",\"value\":\"Astana\"}]}";
|
||||
char redis_ip[64] = "127.0.0.1";
|
||||
int redis_port = 6379;
|
||||
int redis_db = 0;
|
||||
@@ -308,7 +309,7 @@ protected:
|
||||
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_logger(opts, "./maat_framework_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_logger(opts, "./maat_framework_perf_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
maat_options_set_caller_thread_number(opts, 5);
|
||||
|
||||
@@ -362,7 +363,7 @@ void *perf_string_scan_thread(void *arg)
|
||||
int *is_all_hit = ALLOC(int, 1);
|
||||
*is_all_hit = (hit_times == param->test_count ? 1 : 0);
|
||||
log_info(param->logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"thread_id:%d time_elapse:%lldms hit_times:%d",
|
||||
"thread_id:%d string_scan time_elapse:%lldms hit_times:%d",
|
||||
param->thread_id, param->time_elapse_ms, hit_times);
|
||||
return is_all_hit;
|
||||
}
|
||||
@@ -421,7 +422,7 @@ void *perf_ip_scan_thread(void *arg)
|
||||
int *is_all_hit = ALLOC(int, 1);
|
||||
*is_all_hit = (hit_times == param->test_count ? 1 : 0);
|
||||
log_info(param->logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"thread_id:%d time_elapse:%lldms hit_times:%d",
|
||||
"thread_id:%d ip_scan time_elapse:%lldms hit_times:%d",
|
||||
param->thread_id, param->time_elapse_ms, hit_times);
|
||||
return is_all_hit;
|
||||
}
|
||||
@@ -456,7 +457,7 @@ void *perf_ip_update_thread(void *arg)
|
||||
return is_all_hit;
|
||||
}
|
||||
|
||||
TEST_F(MaatPerfStringScan, basic) {
|
||||
TEST_F(MaatPerfStringScan, MultiThread) {
|
||||
const char *table_name = "KEYWORDS_TABLE";
|
||||
struct maat *maat_instance = MaatPerfStringScan::_shared_maat_instance;
|
||||
|
||||
@@ -498,14 +499,169 @@ TEST_F(MaatPerfStringScan, basic) {
|
||||
}
|
||||
scan_per_second = scan_count * 1000 / time_elapse_ms;
|
||||
//EXPECT_GT(scan_per_second, 800 * 1000);
|
||||
printf("High match rate on %d-threads speed %lld lookups/s/thread\n", PERF_THREAD_NUM, scan_per_second);
|
||||
log_info(maat_instance->logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"StringScan match rate on %d-threads speed %lld lookups/s/thread",
|
||||
PERF_THREAD_NUM, scan_per_second);
|
||||
}
|
||||
|
||||
class MaatPerfStreamScan : public testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestCase() {
|
||||
const char *accept_tags = "{\"tags\":[{\"tag\":\"location\",\"value\":\"北京/朝阳/华严北里/甲22号\"},"
|
||||
"{\"tag\":\"isp\",\"value\":\"移动\"},{\"tag\":\"location\",\"value\":\"Astana\"}]}";
|
||||
char redis_ip[64] = "127.0.0.1";
|
||||
int redis_port = 6379;
|
||||
int redis_db = 0;
|
||||
|
||||
logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
|
||||
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
|
||||
if (ret < 0) {
|
||||
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_logger(opts, "./maat_framework_perf_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
maat_options_set_caller_thread_number(opts, 5);
|
||||
|
||||
_shared_maat_instance = maat_new(opts, table_info_path);
|
||||
maat_options_free(opts);
|
||||
if (NULL == _shared_maat_instance) {
|
||||
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"[%s:%d] create maat instance in MaatFlagScan failed.",
|
||||
__FUNCTION__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
maat_free(_shared_maat_instance);
|
||||
log_handle_destroy(logger);
|
||||
}
|
||||
|
||||
static struct log_handle *logger;
|
||||
static struct maat *_shared_maat_instance;
|
||||
};
|
||||
|
||||
struct maat *MaatPerfStreamScan::_shared_maat_instance;
|
||||
struct log_handle *MaatPerfStreamScan::logger;
|
||||
|
||||
void *perf_stream_scan_thread(void *arg)
|
||||
{
|
||||
struct thread_param *param = (struct thread_param *)arg;
|
||||
struct maat *maat_instance = param->maat_instance;
|
||||
const char *table_name = param->table_name;
|
||||
struct timespec start, end;
|
||||
const char *scan_data = "http://www.cyberessays.com/search_results.php?action=search&query=yulingjing,abckkk,1234567";
|
||||
long long results[ARRAY_SIZE] = {0};
|
||||
int ret = 0, hit_times = 0;
|
||||
size_t n_hit_result = 0;
|
||||
struct maat_state *state_array[ARRAY_SIZE];
|
||||
struct maat_stream *sp[ARRAY_SIZE];
|
||||
int table_id = maat_get_table_id(maat_instance, table_name);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (int i = 0; i < param->test_count; i++) {
|
||||
for (int j = 0; j < ARRAY_SIZE; j++) {
|
||||
state_array[j] = maat_state_new(maat_instance, param->thread_id);
|
||||
sp[j] = maat_stream_new(maat_instance, table_id, state_array[j]);
|
||||
|
||||
ret = maat_stream_scan(sp[j], scan_data, strlen(scan_data), results, ARRAY_SIZE,
|
||||
&n_hit_result, state_array[j]);
|
||||
if (ret == MAAT_SCAN_HIT) {
|
||||
hit_times++;
|
||||
}
|
||||
maat_stream_free(sp[j]);
|
||||
maat_state_free(state_array[j]);
|
||||
}
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
|
||||
param->time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
|
||||
int *is_all_hit = ALLOC(int, 1);
|
||||
*is_all_hit = ((hit_times == param->test_count*ARRAY_SIZE) ? 1 : 0);
|
||||
|
||||
log_info(param->logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"thread_id:%d stream_scan time_elapse:%lldms hit_times:%d",
|
||||
param->thread_id, param->time_elapse_ms, hit_times);
|
||||
return is_all_hit;
|
||||
}
|
||||
|
||||
void *perf_stream_update_thread(void *arg)
|
||||
{
|
||||
struct thread_param *param = (struct thread_param *)arg;
|
||||
struct maat *maat_instance = param->maat_instance;
|
||||
const char *table_name = param->table_name;
|
||||
const int CMD_EXPR_NUM = 10;
|
||||
char keyword_buf[128];
|
||||
|
||||
for (int i = 0; i < CMD_EXPR_NUM; i++) {
|
||||
random_keyword_generate(keyword_buf, sizeof(keyword_buf));
|
||||
test_add_expr_command(maat_instance, table_name, keyword_buf);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
int *is_all_hit = ALLOC(int, 1);
|
||||
*is_all_hit = 1;
|
||||
|
||||
return is_all_hit;
|
||||
}
|
||||
|
||||
TEST_F(MaatPerfStreamScan, MultiThread) {
|
||||
const char *table_name = "HTTP_URL";
|
||||
struct maat *maat_instance = MaatPerfStreamScan::_shared_maat_instance;
|
||||
|
||||
int table_id = maat_get_table_id(maat_instance, table_name);
|
||||
ASSERT_GT(table_id, 0);
|
||||
|
||||
pthread_t threads[PERF_THREAD_NUM + 1];
|
||||
struct thread_param thread_params[PERF_THREAD_NUM + 1];
|
||||
int i = 0;
|
||||
int *is_all_hit = NULL;
|
||||
|
||||
for (i = 0; i < PERF_THREAD_NUM + 1; i++) {
|
||||
thread_params[i].maat_instance = maat_instance;
|
||||
thread_params[i].thread_id = i;
|
||||
thread_params[i].table_name = table_name;
|
||||
thread_params[i].test_count = 100 * 1000;
|
||||
thread_params[i].time_elapse_ms = 0;
|
||||
thread_params[i].logger = logger;
|
||||
|
||||
if (i < PERF_THREAD_NUM) {
|
||||
pthread_create(&threads[i], NULL, perf_stream_scan_thread, thread_params+i);
|
||||
} else {
|
||||
thread_params[i].test_count = 0;
|
||||
pthread_create(&threads[i], NULL, perf_stream_update_thread, thread_params+i);
|
||||
}
|
||||
}
|
||||
|
||||
long long time_elapse_ms = 0;
|
||||
long long scan_count = 0;
|
||||
long long scan_per_second = 0;
|
||||
for (i = 0; i < PERF_THREAD_NUM + 1; i++) {
|
||||
pthread_join(threads[i], (void **)&is_all_hit);
|
||||
time_elapse_ms += thread_params[i].time_elapse_ms;
|
||||
scan_count += thread_params[i].test_count;
|
||||
//maybe expr_runtime rebuild in stream_scan, so should not expect is_all_hit always 1
|
||||
//EXPECT_EQ(*is_all_hit, 1);
|
||||
*is_all_hit = 0;
|
||||
free(is_all_hit);
|
||||
}
|
||||
scan_per_second = scan_count * 1000 / time_elapse_ms;
|
||||
|
||||
log_info(maat_instance->logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"StreamScan match rate on %d-threads speed %lld lookups/s/thread",
|
||||
PERF_THREAD_NUM, scan_per_second);
|
||||
}
|
||||
|
||||
class MaatPerfIPScan : public testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestCase() {
|
||||
const char *accept_tags = "{\"tags\":[{\"tag\":\"location\",\"value\":\"北京/朝阳/华严北里/甲22号\"},{\"tag\":\"isp\",\"value\":\"移动\"},{\"tag\":\"location\",\"value\":\"Astana\"}]}";
|
||||
const char *accept_tags = "{\"tags\":[{\"tag\":\"location\",\"value\":\"北京/朝阳/华严北里/甲22号\"},"
|
||||
"{\"tag\":\"isp\",\"value\":\"移动\"},{\"tag\":\"location\",\"value\":\"Astana\"}]}";
|
||||
char redis_ip[64] = "127.0.0.1";
|
||||
int redis_port = 6379;
|
||||
int redis_db = 0;
|
||||
@@ -544,7 +700,7 @@ protected:
|
||||
struct maat *MaatPerfIPScan::_shared_maat_instance;
|
||||
struct log_handle *MaatPerfIPScan::logger;
|
||||
|
||||
TEST_F(MaatPerfIPScan, basic)
|
||||
TEST_F(MaatPerfIPScan, MultiThread)
|
||||
{
|
||||
const char *table_name = "IP_PLUS_CONFIG";
|
||||
struct maat *maat_instance = MaatPerfIPScan::_shared_maat_instance;
|
||||
@@ -561,7 +717,7 @@ TEST_F(MaatPerfIPScan, basic)
|
||||
thread_params[i].maat_instance = maat_instance;
|
||||
thread_params[i].thread_id = i;
|
||||
thread_params[i].table_name = table_name;
|
||||
thread_params[i].test_count = 1 * 1000 * 1000;
|
||||
thread_params[i].test_count = 10 * 1000 * 1000;
|
||||
thread_params[i].time_elapse_ms = 0;
|
||||
thread_params[i].logger = logger;
|
||||
|
||||
@@ -586,8 +742,588 @@ TEST_F(MaatPerfIPScan, basic)
|
||||
free(is_all_hit);
|
||||
}
|
||||
scan_per_second = scan_count * 1000 / time_elapse_ms;
|
||||
//EXPECT_GT(scan_per_second, 800 * 1000);
|
||||
printf("High match rate on %d-threads speed %lld lookups/s/thread\n", PERF_THREAD_NUM, scan_per_second);
|
||||
|
||||
log_info(maat_instance->logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"IPScan match rate on %d-threads speed %lld lookups/s/thread",
|
||||
PERF_THREAD_NUM, scan_per_second);
|
||||
}
|
||||
|
||||
class MaatPerfFQDNPluginScan : public testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestCase() {
|
||||
const char *accept_tags = "{\"tags\":[{\"tag\":\"location\",\"value\":\"北京/朝阳/华严北里/甲22号\"},"
|
||||
"{\"tag\":\"isp\",\"value\":\"移动\"},{\"tag\":\"location\",\"value\":\"Astana\"}]}";
|
||||
char redis_ip[64] = "127.0.0.1";
|
||||
int redis_port = 6379;
|
||||
int redis_db = 0;
|
||||
|
||||
logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
|
||||
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
|
||||
if (ret < 0) {
|
||||
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_logger(opts, "./maat_framework_perf_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
maat_options_set_caller_thread_number(opts, 5);
|
||||
|
||||
_shared_maat_instance = maat_new(opts, table_info_path);
|
||||
maat_options_free(opts);
|
||||
if (NULL == _shared_maat_instance) {
|
||||
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"[%s:%d] create maat instance in MaatFlagScan failed.",
|
||||
__FUNCTION__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
maat_free(_shared_maat_instance);
|
||||
log_handle_destroy(logger);
|
||||
}
|
||||
|
||||
static struct log_handle *logger;
|
||||
static struct maat *_shared_maat_instance;
|
||||
};
|
||||
|
||||
struct maat *MaatPerfFQDNPluginScan::_shared_maat_instance;
|
||||
struct log_handle *MaatPerfFQDNPluginScan::logger;
|
||||
|
||||
struct perf_fqdn_plugin_ud {
|
||||
long long rule_id;
|
||||
int catid;
|
||||
int ref_cnt;
|
||||
};
|
||||
|
||||
void perf_fqdn_plugin_EX_new_cb(const char *table_name, int table_id, const char *key,
|
||||
const char *table_line, void **ad, long argl, void *argp)
|
||||
{
|
||||
int *counter=(int *)argp;
|
||||
size_t column_offset=0, column_len=0;
|
||||
|
||||
struct perf_fqdn_plugin_ud *ud = ALLOC(struct perf_fqdn_plugin_ud, 1);
|
||||
int ret = maat_helper_read_column(table_line, 1, &column_offset, &column_len);
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
ud->rule_id = atoll(table_line+column_offset);
|
||||
ret = maat_helper_read_column(table_line, 4, &column_offset, &column_len);
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
sscanf(table_line+column_offset, "catid=%d",&ud->catid);
|
||||
ud->ref_cnt = 1;
|
||||
*ad = ud;
|
||||
(*counter)++;
|
||||
}
|
||||
|
||||
void perf_fqdn_plugin_EX_free_cb(int table_id, void **ad, long argl, void *argp)
|
||||
{
|
||||
struct perf_fqdn_plugin_ud *u = (struct perf_fqdn_plugin_ud *)(*ad);
|
||||
if ((__sync_sub_and_fetch(&u->ref_cnt, 1) == 0)) {
|
||||
free(u);
|
||||
*ad = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void perf_fqdn_plugin_EX_dup_cb(int table_id, void **to, void **from, long argl, void *argp)
|
||||
{
|
||||
struct perf_fqdn_plugin_ud *u = (struct perf_fqdn_plugin_ud *)(*from);
|
||||
__sync_add_and_fetch(&(u->ref_cnt), 1);
|
||||
*to = u;
|
||||
}
|
||||
|
||||
void* perf_fqdn_plugin_scan_thread(void *arg)
|
||||
{
|
||||
struct thread_param *param = (struct thread_param *)arg;
|
||||
struct maat *maat_instance = param->maat_instance;
|
||||
struct perf_fqdn_plugin_ud *result[ARRAY_SIZE];
|
||||
|
||||
int i=0, j=0, ret=0, hit_times=0;
|
||||
int table_id = maat_get_table_id(maat_instance, param->table_name);
|
||||
|
||||
memset(&result, 0, sizeof(result));
|
||||
struct timespec start, end;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (i = 0; i < param->test_count; i++) {
|
||||
|
||||
ret = maat_fqdn_plugin_table_get_ex_data(maat_instance, table_id,
|
||||
"r3---sn-i3belne6.example2.com",
|
||||
(void**)result, ARRAY_SIZE);
|
||||
if (ret == 2) {
|
||||
hit_times++;
|
||||
}
|
||||
|
||||
for (j = 0; j < ret; j++) {
|
||||
perf_fqdn_plugin_EX_free_cb(0, (void**)&(result[j]), 0, NULL);
|
||||
}
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
|
||||
param->time_elapse_ms = (end.tv_sec-start.tv_sec)*1000 + (end.tv_nsec-start.tv_nsec)/1000000;
|
||||
int* is_all_hit = (int*)malloc(sizeof(int));
|
||||
*is_all_hit = (hit_times == param->test_count) ? 1 : 0;
|
||||
log_info(param->logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"thread_id:%d fqdn_plugin_get_ex_data time_elapse:%lldms hit_times:%d",
|
||||
param->thread_id, param->time_elapse_ms, hit_times);
|
||||
|
||||
return is_all_hit;
|
||||
}
|
||||
|
||||
void random_fqdn_generate(char *fqdn_buff, int sz)
|
||||
{
|
||||
int min_fqdn_len = 6, max_fqdn_len = 32;
|
||||
int i=0, j=0;
|
||||
|
||||
int len = random() % (max_fqdn_len - min_fqdn_len) + min_fqdn_len;
|
||||
if (len >= sz) {
|
||||
len = sz - 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < len-4; i++) {
|
||||
fqdn_buff[i] = 'a' + random() % ('z' - 'a');
|
||||
if (j > 5) {
|
||||
if (random() % 3 == 0) {
|
||||
fqdn_buff[i] = '.';
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
j++;
|
||||
}
|
||||
fqdn_buff[i] = '\0';
|
||||
}
|
||||
|
||||
void *perf_fqdn_plugin_update_thread(void *arg)
|
||||
{
|
||||
struct thread_param *param = (struct thread_param *)arg;
|
||||
struct maat *maat_instance = param->maat_instance;
|
||||
const int CMD_EXPR_NUM = 20;
|
||||
int i = 0;
|
||||
struct maat_cmd_line line_rule;
|
||||
char line_buff[1024], fqdn_buff[256];
|
||||
|
||||
for (i = 0; i < CMD_EXPR_NUM; i++) {
|
||||
line_rule.rule_id = (int)maat_cmd_incrby(maat_instance, "TEST_PLUG_SEQ", 1);
|
||||
line_rule.table_name = param->table_name;
|
||||
random_fqdn_generate(fqdn_buff, sizeof(fqdn_buff));
|
||||
snprintf(line_buff, 1024, "%lld\t1\t%s\tcatid=4\t1", line_rule.rule_id, fqdn_buff);
|
||||
line_rule.table_line = line_buff;
|
||||
line_rule.expire_after = 0;
|
||||
maat_cmd_set_line(maat_instance, &line_rule);
|
||||
sleep(WAIT_FOR_EFFECTIVE_S);
|
||||
}
|
||||
|
||||
int *is_all_hit = (int *)malloc(sizeof(int));
|
||||
*is_all_hit = 1;
|
||||
|
||||
return is_all_hit;
|
||||
}
|
||||
|
||||
TEST_F(MaatPerfFQDNPluginScan, MultiThread) {
|
||||
struct maat *maat_instance = MaatPerfFQDNPluginScan::_shared_maat_instance;
|
||||
const char *table_name = "TEST_FQDN_PLUGIN_WITH_EXDATA";
|
||||
int fqdn_plugin_ex_data_counter = 0;
|
||||
|
||||
int table_id = maat_get_table_id(maat_instance, table_name);
|
||||
ASSERT_GT(table_id, 0);
|
||||
|
||||
pthread_t threads[PERF_THREAD_NUM + 1];
|
||||
struct thread_param thread_params[PERF_THREAD_NUM + 1];
|
||||
int i = 0;
|
||||
int *is_all_hit = NULL;
|
||||
|
||||
int ret = maat_plugin_table_ex_schema_register(maat_instance, table_name,
|
||||
perf_fqdn_plugin_EX_new_cb,
|
||||
perf_fqdn_plugin_EX_free_cb,
|
||||
perf_fqdn_plugin_EX_dup_cb,
|
||||
0, &fqdn_plugin_ex_data_counter);
|
||||
ASSERT_TRUE(ret>=0);
|
||||
|
||||
for (i = 0; i < PERF_THREAD_NUM + 1; i++) {
|
||||
thread_params[i].maat_instance = maat_instance;
|
||||
thread_params[i].thread_id = i;
|
||||
thread_params[i].table_name = table_name;
|
||||
thread_params[i].test_count = 1 * 1000 * 1000;
|
||||
thread_params[i].time_elapse_ms = 0;
|
||||
thread_params[i].logger = logger;
|
||||
|
||||
if (i < PERF_THREAD_NUM) {
|
||||
pthread_create(&threads[i], NULL, perf_fqdn_plugin_scan_thread, thread_params + i);
|
||||
} else {
|
||||
thread_params[i].test_count = 0;
|
||||
pthread_create(&threads[i], NULL, perf_fqdn_plugin_update_thread, thread_params + i);
|
||||
}
|
||||
}
|
||||
|
||||
long long time_elapse_ms = 0;
|
||||
long long scan_count = 0;
|
||||
long long scan_per_second = 0;
|
||||
for (i = 0; i < PERF_THREAD_NUM + 1; i++) {
|
||||
pthread_join(threads[i], (void **)&is_all_hit);
|
||||
time_elapse_ms += thread_params[i].time_elapse_ms;
|
||||
scan_count += thread_params[i].test_count;
|
||||
|
||||
EXPECT_EQ(*is_all_hit, 1);
|
||||
*is_all_hit = 0;
|
||||
free(is_all_hit);
|
||||
}
|
||||
scan_per_second = scan_count * 1000 / time_elapse_ms;
|
||||
|
||||
log_info(maat_instance->logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"FQDNPluginScan match rate on %d-threads speed %lld lookups/s/thread",
|
||||
PERF_THREAD_NUM, scan_per_second);
|
||||
}
|
||||
|
||||
class MaatPerfBoolPluginScan : public testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestCase() {
|
||||
const char *accept_tags = "{\"tags\":[{\"tag\":\"location\",\"value\":\"北京/朝阳/华严北里/甲22号\"},"
|
||||
"{\"tag\":\"isp\",\"value\":\"移动\"},{\"tag\":\"location\",\"value\":\"Astana\"}]}";
|
||||
char redis_ip[64] = "127.0.0.1";
|
||||
int redis_port = 6379;
|
||||
int redis_db = 0;
|
||||
|
||||
logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
|
||||
int ret = write_config_to_redis(redis_ip, redis_port, redis_db, logger);
|
||||
if (ret < 0) {
|
||||
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_redis(opts, redis_ip, redis_port, redis_db);
|
||||
maat_options_set_logger(opts, "./maat_framework_perf_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_accept_tags(opts, accept_tags);
|
||||
maat_options_set_caller_thread_number(opts, 5);
|
||||
|
||||
_shared_maat_instance = maat_new(opts, table_info_path);
|
||||
maat_options_free(opts);
|
||||
if (NULL == _shared_maat_instance) {
|
||||
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"[%s:%d] create maat instance in BoolPluginScan failed.",
|
||||
__FUNCTION__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
maat_free(_shared_maat_instance);
|
||||
log_handle_destroy(logger);
|
||||
}
|
||||
|
||||
static struct log_handle *logger;
|
||||
static struct maat *_shared_maat_instance;
|
||||
};
|
||||
|
||||
struct maat *MaatPerfBoolPluginScan::_shared_maat_instance;
|
||||
struct log_handle *MaatPerfBoolPluginScan::logger;
|
||||
|
||||
struct bool_plugin_ud {
|
||||
int id;
|
||||
char *name;
|
||||
int ref_cnt;
|
||||
};
|
||||
void perf_bool_plugin_ex_new_cb(const char *table_name, int table_id, const char *key,
|
||||
const char *table_line, void **ad, long argl, void *argp)
|
||||
{
|
||||
int *counter=(int *)argp;
|
||||
size_t column_offset=0, column_len=0;
|
||||
struct bool_plugin_ud *ud = ALLOC(struct bool_plugin_ud, 1);
|
||||
|
||||
int ret = get_column_pos(table_line, 1, &column_offset, &column_len);
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
ud->id = atoi(table_line + column_offset);
|
||||
ret = get_column_pos(table_line, 3, &column_offset, &column_len);
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
ud->name = (char *)malloc(column_len+1);
|
||||
memcpy(ud->name, table_line+column_offset, column_len);
|
||||
ud->ref_cnt = 1;
|
||||
*ad = ud;
|
||||
(*counter)++;
|
||||
}
|
||||
void perf_bool_plugin_ex_free_cb(int table_id, void **ad, long argl, void *argp)
|
||||
{
|
||||
struct bool_plugin_ud *u = (struct bool_plugin_ud *)(*ad);
|
||||
if ((__sync_sub_and_fetch(&u->ref_cnt, 1) == 0))
|
||||
{
|
||||
free(u->name);
|
||||
free(u);
|
||||
*ad = NULL;
|
||||
}
|
||||
}
|
||||
void perf_bool_plugin_ex_dup_cb(int table_id, void **to, void **from, long argl, void *argp)
|
||||
{
|
||||
struct bool_plugin_ud *u = (struct bool_plugin_ud *)(*from);
|
||||
__sync_add_and_fetch(&(u->ref_cnt), 1);
|
||||
*to = u;
|
||||
}
|
||||
|
||||
void* perf_bool_plugin_scan_thread(void *arg)
|
||||
{
|
||||
struct thread_param *param = (struct thread_param *)arg;
|
||||
struct maat *maat_instance = param->maat_instance;
|
||||
struct perf_fqdn_plugin_ud *result[ARRAY_SIZE];
|
||||
|
||||
int i=0, j=0, ret=0, hit_times=0;
|
||||
int table_id = maat_get_table_id(maat_instance, param->table_name);
|
||||
|
||||
memset(&result, 0, sizeof(result));
|
||||
struct timespec start, end;
|
||||
unsigned long long items_4[]={7, 0, 1, 2, 3, 4, 5, 6, 7, 7, 7};
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
for (i = 0; i < param->test_count; i++) {
|
||||
|
||||
ret = maat_bool_plugin_table_get_ex_data(maat_instance, table_id, items_4,
|
||||
sizeof(items_4)/sizeof(unsigned long long),
|
||||
(void**)result, 6);
|
||||
if (ret == 1) {
|
||||
hit_times++;
|
||||
}
|
||||
|
||||
for (j = 0; j < ret; j++) {
|
||||
perf_bool_plugin_ex_free_cb(0, (void**)&(result[j]), 0, NULL);
|
||||
}
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
|
||||
param->time_elapse_ms = (end.tv_sec-start.tv_sec)*1000 + (end.tv_nsec-start.tv_nsec)/1000000;
|
||||
int* is_all_hit = (int*)malloc(sizeof(int));
|
||||
*is_all_hit = (hit_times == param->test_count) ? 1 : 0;
|
||||
|
||||
log_info(param->logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"thread_id:%d bool_plugin_get_ex_data time_elapse:%lldms hit_times:%d",
|
||||
param->thread_id, param->time_elapse_ms, hit_times);
|
||||
|
||||
return is_all_hit;
|
||||
}
|
||||
|
||||
void *perf_bool_plugin_update_thread(void *arg)
|
||||
{
|
||||
struct thread_param *param = (struct thread_param *)arg;
|
||||
struct maat *maat_instance = param->maat_instance;
|
||||
const int CMD_EXPR_NUM = 20;
|
||||
int i = 0;
|
||||
struct maat_cmd_line line_rule;
|
||||
char line_buff[1024];
|
||||
|
||||
for (i = 0; i < CMD_EXPR_NUM; i++) {
|
||||
line_rule.rule_id = (int)maat_cmd_incrby(maat_instance, "TEST_PLUG_SEQ", 1);
|
||||
line_rule.table_name = param->table_name;
|
||||
snprintf(line_buff, 1024, "%lld\t1&%d\ttunnel2\t1", line_rule.rule_id, i);
|
||||
line_rule.table_line = line_buff;
|
||||
line_rule.expire_after = 0;
|
||||
maat_cmd_set_line(maat_instance, &line_rule);
|
||||
sleep(WAIT_FOR_EFFECTIVE_S);
|
||||
}
|
||||
|
||||
int *is_all_hit = (int *)malloc(sizeof(int));
|
||||
*is_all_hit = 1;
|
||||
|
||||
return is_all_hit;
|
||||
}
|
||||
|
||||
TEST_F(MaatPerfBoolPluginScan, MultiThread) {
|
||||
int ex_data_counter = 0;
|
||||
const char *table_name = "TEST_BOOL_PLUGIN_WITH_EXDATA";
|
||||
struct maat *maat_instance = MaatPerfBoolPluginScan::_shared_maat_instance;
|
||||
|
||||
int table_id = maat_get_table_id(maat_instance, table_name);
|
||||
ASSERT_GT(table_id, 0);
|
||||
|
||||
int ret = maat_plugin_table_ex_schema_register(maat_instance, table_name,
|
||||
perf_bool_plugin_ex_new_cb,
|
||||
perf_bool_plugin_ex_free_cb,
|
||||
perf_bool_plugin_ex_dup_cb,
|
||||
0, &ex_data_counter);
|
||||
ASSERT_TRUE(ret >= 0);
|
||||
|
||||
pthread_t threads[PERF_THREAD_NUM + 1];
|
||||
struct thread_param thread_params[PERF_THREAD_NUM + 1];
|
||||
int i = 0;
|
||||
int *is_all_hit = NULL;
|
||||
|
||||
for (i = 0; i < PERF_THREAD_NUM + 1; i++) {
|
||||
thread_params[i].maat_instance = maat_instance;
|
||||
thread_params[i].thread_id = i;
|
||||
thread_params[i].table_name = table_name;
|
||||
thread_params[i].test_count = 1 * 1000 * 1000;
|
||||
thread_params[i].time_elapse_ms = 0;
|
||||
thread_params[i].logger = logger;
|
||||
|
||||
if (i < PERF_THREAD_NUM) {
|
||||
pthread_create(&threads[i], NULL, perf_bool_plugin_scan_thread, thread_params + i);
|
||||
} else {
|
||||
thread_params[i].test_count = 0;
|
||||
pthread_create(&threads[i], NULL, perf_bool_plugin_update_thread, thread_params + i);
|
||||
}
|
||||
}
|
||||
|
||||
long long time_elapse_ms = 0;
|
||||
long long scan_count = 0;
|
||||
long long scan_per_second = 0;
|
||||
for (i = 0; i < PERF_THREAD_NUM + 1; i++) {
|
||||
pthread_join(threads[i], (void **)&is_all_hit);
|
||||
time_elapse_ms += thread_params[i].time_elapse_ms;
|
||||
scan_count += thread_params[i].test_count;
|
||||
|
||||
EXPECT_EQ(*is_all_hit, 1);
|
||||
*is_all_hit = 0;
|
||||
free(is_all_hit);
|
||||
}
|
||||
scan_per_second = scan_count * 1000 / time_elapse_ms;
|
||||
|
||||
log_info(maat_instance->logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"BoolPluginScan match rate on %d-threads speed %lld lookups/s/thread",
|
||||
PERF_THREAD_NUM, scan_per_second);
|
||||
}
|
||||
|
||||
class MaatPerfFileScan : public testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestCase() {
|
||||
logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
|
||||
const char *rule_folder = "./tsgrule/full/index";
|
||||
const char *table_info = "./tsg_table_info.conf";
|
||||
|
||||
struct maat_options *opts = maat_options_new();
|
||||
maat_options_set_iris(opts, rule_folder, rule_folder);
|
||||
maat_options_set_logger(opts, "./maat_framework_perf_gtest.log", LOG_LEVEL_INFO);
|
||||
maat_options_set_caller_thread_number(opts, 5);
|
||||
|
||||
_shared_maat_instance = maat_new(opts, table_info);
|
||||
maat_options_free(opts);
|
||||
if (NULL == _shared_maat_instance) {
|
||||
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"[%s:%d] create maat instance in MaatPerfFileScan failed.",
|
||||
__FUNCTION__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
maat_free(_shared_maat_instance);
|
||||
log_handle_destroy(logger);
|
||||
}
|
||||
|
||||
static struct log_handle *logger;
|
||||
static struct maat *_shared_maat_instance;
|
||||
};
|
||||
|
||||
struct maat *MaatPerfFileScan::_shared_maat_instance;
|
||||
struct log_handle *MaatPerfFileScan::logger;
|
||||
|
||||
struct perf_ip_plugin_ud {
|
||||
long long rule_id;
|
||||
int ref_cnt;
|
||||
};
|
||||
|
||||
void perf_ip_plugin_EX_new_cb(const char *table_name, int table_id, const char *key,
|
||||
const char *table_line, void **ad, long argl, void *argp)
|
||||
{
|
||||
int *counter=(int *)argp, ret=0;
|
||||
size_t column_offset=0, column_len=0;
|
||||
|
||||
struct perf_ip_plugin_ud *ud = ALLOC(struct perf_ip_plugin_ud, 1);
|
||||
ret = maat_helper_read_column(table_line, 1, &column_offset, &column_len);
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
ud->rule_id = atoll(table_line+column_offset);
|
||||
ret = maat_helper_read_column(table_line, 5, &column_offset, &column_len);
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
ud->ref_cnt = 1;
|
||||
*ad = ud;
|
||||
(*counter)++;
|
||||
}
|
||||
|
||||
void perf_ip_plugin_EX_free_cb(int table_id, void **ad, long argl, void *argp)
|
||||
{
|
||||
struct perf_ip_plugin_ud *u = (struct perf_ip_plugin_ud*)(*ad);
|
||||
if ((__sync_sub_and_fetch(&u->ref_cnt, 1) == 0)) {
|
||||
free(u);
|
||||
*ad = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void perf_ip_plugin_EX_dup_cb(int table_id, void **to, void **from, long argl, void *argp)
|
||||
{
|
||||
struct perf_ip_plugin_ud *u = (struct perf_ip_plugin_ud*)(*from);
|
||||
__sync_add_and_fetch(&(u->ref_cnt), 1);
|
||||
*to = u;
|
||||
}
|
||||
|
||||
static void *ip_plugin_get_thread(void *arg)
|
||||
{
|
||||
const char *table_name = "TSG_IP_LOCATION_BUILT_IN";
|
||||
int test_times = 1000*1000, hit_times = 0;
|
||||
int ret = 0, i=0, j=0;
|
||||
struct maat *maat_instance = (struct maat *)arg;
|
||||
|
||||
int table_id = maat_get_table_id(maat_instance, table_name);
|
||||
|
||||
struct timespec start, end;
|
||||
struct ip_addr ipv4;
|
||||
ipv4.ip_type = IPv4;
|
||||
|
||||
inet_pton(AF_INET, "191.70.72.1", &ipv4.ipv4);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
struct perf_ip_plugin_ud *results[ARRAY_SIZE];
|
||||
for (i = 0; i < test_times; i++) {
|
||||
ret = maat_ip_plugin_table_get_ex_data(maat_instance, table_id, &ipv4, (void**)results, 4);
|
||||
if (ret > 0) {
|
||||
hit_times++;
|
||||
}
|
||||
|
||||
for (j = 0; j < ret; j++) {
|
||||
perf_ip_plugin_EX_free_cb(table_id, (void**)&(results[j]), 0, NULL);
|
||||
}
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
|
||||
long long time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000;
|
||||
log_info(maat_instance->logger, MODULE_FRAMEWORK_PERF_GTEST,
|
||||
"ip_plugin_get_ex_data time_elapse:%lldms hit_times:%d",
|
||||
time_elapse_ms, hit_times);
|
||||
|
||||
int *is_all_hit = (int *)malloc(sizeof(int));
|
||||
*is_all_hit = (hit_times == test_times) ? 1 : 0;
|
||||
return is_all_hit;
|
||||
}
|
||||
|
||||
TEST_F(MaatPerfFileScan, IPPlugin) {
|
||||
struct maat *maat_instance = MaatPerfFileScan::_shared_maat_instance;
|
||||
const char* table_name = "TSG_IP_LOCATION_BUILT_IN";
|
||||
int ip_plugin_ex_data_counter = 0;
|
||||
int* is_all_hit = NULL;
|
||||
|
||||
int table_id = maat_get_table_id(maat_instance, table_name);
|
||||
ASSERT_GT(table_id, 0);
|
||||
|
||||
int ret = maat_plugin_table_ex_schema_register(maat_instance, table_name,
|
||||
perf_ip_plugin_EX_new_cb,
|
||||
perf_ip_plugin_EX_free_cb,
|
||||
perf_ip_plugin_EX_dup_cb,
|
||||
0, &ip_plugin_ex_data_counter);
|
||||
ASSERT_TRUE(ret>=0);
|
||||
|
||||
int i = 0;
|
||||
pthread_t threads[PERF_THREAD_NUM];
|
||||
|
||||
for (i = 0; i < PERF_THREAD_NUM; i++) {
|
||||
pthread_create(&(threads[i]), NULL, ip_plugin_get_thread, maat_instance);
|
||||
}
|
||||
|
||||
for (i = 0; i < PERF_THREAD_NUM; i++) {
|
||||
pthread_join(threads[i], (void**)&is_all_hit);
|
||||
EXPECT_EQ(*is_all_hit, 1);
|
||||
*is_all_hit=0;
|
||||
free(is_all_hit);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
|
||||
@@ -2836,6 +2836,112 @@
|
||||
"group_name": "Untitled"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"compile_id": 206,
|
||||
"service": 0,
|
||||
"action": 0,
|
||||
"do_blacklist": 0,
|
||||
"do_log": 0,
|
||||
"effective_rage": 0,
|
||||
"user_region": "duplicateRuleFor191",
|
||||
"is_valid": "yes",
|
||||
"groups": [
|
||||
{
|
||||
"regions": [
|
||||
{
|
||||
"table_type": "expr",
|
||||
"table_name": "KEYWORDS_TABLE",
|
||||
"table_content": {
|
||||
"keywords": "54455354",
|
||||
"expr_type": "none",
|
||||
"format": "hexbin",
|
||||
"match_method": "sub"
|
||||
}
|
||||
}
|
||||
],
|
||||
"group_name": "Untitled"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"compile_id": 207,
|
||||
"service": 0,
|
||||
"action": 0,
|
||||
"do_blacklist": 0,
|
||||
"do_log": 0,
|
||||
"user_region": "duplicateRuleFor192",
|
||||
"is_valid": "yes",
|
||||
"groups": [
|
||||
{
|
||||
"regions": [
|
||||
{
|
||||
"table_type": "flag",
|
||||
"table_name": "FLAG_CONFIG",
|
||||
"table_content": {
|
||||
"flag": 1,
|
||||
"flag_mask": 3
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"compile_id": 208,
|
||||
"service": 0,
|
||||
"action": 0,
|
||||
"do_blacklist": 0,
|
||||
"do_log": 0,
|
||||
"effective_rage": 0,
|
||||
"user_region": "duplicateRuleFor154",
|
||||
"is_valid": "yes",
|
||||
"groups": [
|
||||
{
|
||||
"regions": [
|
||||
{
|
||||
"table_type": "ip_plus",
|
||||
"table_name": "IP_PLUS_CONFIG",
|
||||
"table_content": {
|
||||
"addr_type": "ipv4",
|
||||
"addr_format": "range",
|
||||
"ip1": "10.0.7.100",
|
||||
"ip2": "10.0.7.106",
|
||||
"port_format": "range",
|
||||
"port1": "65530",
|
||||
"port2": "65535",
|
||||
"protocol": 6
|
||||
}
|
||||
}
|
||||
],
|
||||
"not_flag": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"compile_id": 209,
|
||||
"service": 1,
|
||||
"action": 1,
|
||||
"do_blacklist": 1,
|
||||
"do_log": 1,
|
||||
"user_region": "duplicateRuleFor179",
|
||||
"is_valid": "yes",
|
||||
"groups": [
|
||||
{
|
||||
"group_name": "Untitled",
|
||||
"regions": [
|
||||
{
|
||||
"table_name": "INTERGER_PLUS",
|
||||
"table_type": "interval_plus",
|
||||
"table_content": {
|
||||
"district": "interval.plus",
|
||||
"low_boundary": 2020,
|
||||
"up_boundary": 2020
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"plugin_table": [
|
||||
|
||||
15
test/tsg_table_info.conf
Normal file
15
test/tsg_table_info.conf
Normal file
@@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"table_id": 42,
|
||||
"table_name":"TSG_IP_LOCATION_BUILT_IN",
|
||||
"table_type":"ip_plugin",
|
||||
"valid_column":18,
|
||||
"custom": {
|
||||
"item_id":1,
|
||||
"ip_type":3,
|
||||
"start_ip":4,
|
||||
"end_ip":5,
|
||||
"addr_format":7
|
||||
}
|
||||
}
|
||||
]
|
||||
1001
test/tsgrule/TSG_IP_LOCATION_BUILT_IN.head_1k
Normal file
1001
test/tsgrule/TSG_IP_LOCATION_BUILT_IN.head_1k
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
TSG_IP_LOCATION_BUILT_IN 1000 ./tsgrule/TSG_IP_LOCATION_BUILT_IN.head_1k
|
||||
|
||||
Reference in New Issue
Block a user