redis内部key改为unsigned long,适配性能测试用例。

This commit is contained in:
zhengchao
2020-06-18 21:59:44 +08:00
parent af27d7197c
commit 73d27d983c
7 changed files with 226 additions and 153 deletions

View File

@@ -7,8 +7,8 @@ target_link_libraries(test_igraph igraph-static)
add_executable(test_maatframe test_maatframe.cpp)
target_link_libraries(test_maatframe maat_frame_shared gtest)
#add_executable(perf_test_maatframe perf_test_maatframe.cpp)
#target_link_libraries(perf_test_maatframe maat_frame_shared gtest)
add_executable(perf_test_maatframe perf_test_maatframe.cpp)
target_link_libraries(perf_test_maatframe maat_frame_shared gtest)
configure_file(table_info.conf table_info.conf COPYONLY)
configure_file(file_test_tableinfo.conf file_test_tableinfo.conf COPYONLY)

View File

@@ -3,24 +3,93 @@
#include "Maat_command.h"
#include <MESA/MESA_handle_logger.h>
#include <gtest/gtest.h>
int test_add_expr_command_copy(Maat_feather_t feather,const char* region_table,int config_id, int timeout,int label_id, const char* keywords)
#include <stdlib.h>
#include <arpa/inet.h>
void ipv4_addr_set_copy(struct ipaddr *ipv4_addr, struct stream_tuple4_v4* v4_addr,
const char* src_ip, unsigned short sport, const char* dest_ip, unsigned short dport)
{
ipv4_addr->addrtype=ADDR_TYPE_IPV4;
inet_pton(AF_INET, src_ip, &(v4_addr->saddr));
v4_addr->source=htons(sport);
inet_pton(AF_INET, dest_ip, &(v4_addr->daddr));
v4_addr->dest=htons(dport);
ipv4_addr->v4=v4_addr;
return;
}
void random_keyword_generate(char* keyword_buf, size_t sz)
{
#define MIN_KEYWORD_LEN 4
size_t i=0, len=0;
len=random()%(sz-1-MIN_KEYWORD_LEN)+MIN_KEYWORD_LEN;
for(i=0; i<len; i++)
{
keyword_buf[i]='0'+random()%('~' - '0');
}
keyword_buf[i]='\0';
return;
}
void random_ipv4_addr_generate(char* ip_buff, size_t sz)
{
unsigned int ip=random();
inet_ntop(AF_INET, &ip, ip_buff, sz);
return;
}
int test_add_ip_command(struct Maat_command_batch* batch, const char* region_table, const char* src_ip, const char* dst_ip, int config_id)
{
struct Maat_cmd_group2compile g2c;
struct Maat_cmd_group2group g2g;
struct Maat_rule_t rule;
struct Maat_cmd_region region;
int group_num=1,ret=0;
memset(&rule,0,sizeof(rule));
rule.config_id=config_id;
strcpy(rule.service_defined,"maat_command");
Maat_command_raw_set_compile(feather, MAAT_OP_ADD, &rule, "COMPILE", NULL, 1, timeout, label_id);
memset(g2c, 0, sizeof(g2c));
Maat_command_batch_set_compile(batch, MAAT_OP_ADD, &rule, "COMPILE", NULL, 1, 0, 0);
memset(&g2c, 0, sizeof(g2c));
g2c.group_id=config_id;
g2c.compile_id=config_id;
g2c.table_name="GROUP2COMPILE";
Maat_command_raw_set_group2compile(feather, MAAT_OP_ADD, &g2c);
Maat_command_batch_set_group2compile(batch, MAAT_OP_ADD, &g2c);
struct Maat_cmd_region region;
memset(&region, 0, sizeof(region));
region.region_type=REGION_IP;
region.table_name=region_table;
region.ip_rule.addr_type=ADDR_TYPE_IPv4;
region.ip_rule.direction=ADDR_DIR_DOUBLE;
region.ip_rule.src_ip=src_ip;
region.ip_rule.mask_src_ip="255.255.255.255";
region.ip_rule.src_port=0;
region.ip_rule.mask_src_port=0;//means any port should hit.
region.ip_rule.dst_ip=dst_ip;
region.ip_rule.mask_dst_ip="255.255.255.255";
region.ip_rule.dst_port=0;
region.ip_rule.mask_dst_port=65535;
region.ip_rule.protocol=0;//means any protocol should hit.
Maat_command_batch_set_region(batch, MAAT_OP_ADD, &region, g2c.group_id);
return 0;
}
int test_add_expr_command_copy(struct Maat_command_batch* batch, const char* region_table,int config_id, const char* keywords)
{
struct Maat_cmd_group2compile g2c;
struct Maat_rule_t rule;
struct Maat_cmd_region region;
memset(&rule,0,sizeof(rule));
rule.config_id=config_id;
strcpy(rule.service_defined,"maat_command");
Maat_command_batch_set_compile(batch, MAAT_OP_ADD, &rule, "COMPILE", NULL, 1, 0, 0);
memset(&g2c, 0, sizeof(g2c));
g2c.group_id=config_id;
g2c.compile_id=config_id;
g2c.table_name="GROUP2COMPILE";
Maat_command_batch_set_group2compile(batch, MAAT_OP_ADD, &g2c);
memset(&region,0,sizeof(region));
region.region_id=config_id;
region.region_type=REGION_EXPR;
region.table_name=region_table;
region.expr_rule.district=NULL;
@@ -28,9 +97,8 @@ int test_add_expr_command_copy(Maat_feather_t feather,const char* region_table,i
region.expr_rule.expr_type=EXPR_TYPE_AND;
region.expr_rule.match_method=MATCH_METHOD_SUB;
region.expr_rule.hex_bin=UNCASE_PLAIN;
Maat_command_raw_set_region(feather, MAAT_OP_ADD, &region, g2c->group_id);
Maat_command_batch_set_region(batch, MAAT_OP_ADD, &region, g2c.group_id);
return 0;
}
void wait_for_cmd_effective_copy(Maat_feather_t feather, long long version_before)
{
@@ -63,7 +131,7 @@ protected:
int scan_interval_ms=500;
int effective_interval_ms=0;
logger=MESA_create_runtime_log_handle("test_maat_redis.log",0);
logger=MESA_create_runtime_log_handle("maat_perf_test.log",0);
_shared_feather=Maat_feather(g_iThreadNum, table_info_path, logger);
Maat_set_feather_opt(_shared_feather,MAAT_OPT_INSTANCE_NAME,"perf", strlen("perf")+1);
@@ -96,83 +164,62 @@ void* MaatCMDPerfTest::logger;
//Following tests must be coded/tested at last, for they stalled the maat update thread and interrupt other tests.
TEST_F(MaatCMDPerfTest, SetExpr200K)
{
const int CMD_EXPR_NUM=200*1000;
const char* table_name="HTTP_URL";
const int CMD_EXPR_NUM=1*1000*1000;
const int CMD_IP_NUM=1*1000*1000;
const char* expr_table_name="HTTP_URL";
const char* ip_table_name="IP_CONFIG";
const char* keywords1="Hiredis";
const char* keywords2="C Client";
char escape_buff1[256],escape_buff2[256];
char keywords[256];
int label_id=5210, config_id=0,ret=0, output_id_cnt=0;
char keyword_buf[128];
char src_ip_buff[32], dst_ip_buff[32];
int config_id=0, ret=0;
Maat_feather_t feather=MaatCMDPerfTest::_shared_feather;
long long version_before=0;
ret=Maat_read_state(feather,MAAT_STATE_VERSION, &version_before, sizeof(version_before));
Maat_str_escape(escape_buff1, sizeof(escape_buff1),keywords1);
Maat_str_escape(escape_buff2, sizeof(escape_buff2),keywords2);
snprintf(keywords,sizeof(keywords),"%s&%s",escape_buff1,escape_buff2);
config_id=(int)Maat_cmd_incrby(feather, "TEST_SEQ", CMD_EXPR_NUM);
ret=Maat_read_state(feather, MAAT_STATE_VERSION, &version_before, sizeof(version_before));
config_id=(int)Maat_cmd_incrby(feather, "TEST_SEQ", CMD_EXPR_NUM+CMD_IP_NUM);
int i=0;
struct Maat_command_batch* batch=NULL;
batch=Maat_command_batch_new(feather);
for(i=0; i<CMD_EXPR_NUM;i++)
{
test_add_expr_command_copy(feather,table_name,config_id-i, 0, label_id, keywords);
random_keyword_generate(keyword_buf, sizeof(keyword_buf));
test_add_expr_command_copy(batch, expr_table_name, config_id-i, keyword_buf);
}
struct Maat_rule_t rule;
memset(&rule,0,sizeof(rule));
for(i=0; i<CMD_EXPR_NUM;i++)
for(i=0; i<CMD_IP_NUM; i++)
{
memset(&rule,0,sizeof(rule));
rule.config_id=output_ids[i];
cmd=Maat_create_cmd(&rule, 0);
ret=Maat_cmd_append(feather, cmd, MAAT_OP_DEL);
EXPECT_EQ(ret, 0);
Maat_free_cmd(cmd);
random_ipv4_addr_generate(src_ip_buff, sizeof(src_ip_buff));
random_ipv4_addr_generate(dst_ip_buff, sizeof(dst_ip_buff));
test_add_ip_command(batch, ip_table_name, src_ip_buff, dst_ip_buff, config_id-CMD_EXPR_NUM-i);
}
ret=Maat_cmd_commit(feather);
EXPECT_EQ(ret, CMD_EXPR_NUM);
free(output_ids);
}
TEST_F(MaatCMDPerfTest, SetLinesOneMillion)
{
const int TEST_CMD_LINE_NUM=1000*1000;
Maat_feather_t feather=MaatCMDPerfTest::_shared_feather;
struct Maat_cmd_line **p_line=(struct Maat_cmd_line **)calloc(sizeof(struct Maat_cmd_line *), TEST_CMD_LINE_NUM);
struct Maat_cmd_line *line_rule=(struct Maat_cmd_line *)calloc(sizeof(struct Maat_cmd_line), TEST_CMD_LINE_NUM);
int i=0;
const char* line="1\t192.168.0.1\t4444444444\t1";
int seq=(int)Maat_cmd_incrby(feather,"TEST_PLUG_SEQ", TEST_CMD_LINE_NUM);
for(i=0;i<TEST_CMD_LINE_NUM;i++)
{
line_rule[i].label_id=0;
line_rule[i].rule_id=seq-i;
line_rule[i].table_name="QD_ENTRY_INFO";
line_rule[i].table_line=line;
// asprintf(&(line_rule[i].table_line),"1\t192.168.0.1\t%d\t1",100+i);
line_rule[i].expire_after=0;
p_line[i]=line_rule+i;
}
long long version_before=0;
Maat_read_state(feather,MAAT_STATE_VERSION, &version_before, sizeof(version_before));
Maat_cmd_set_lines(feather,(const struct Maat_cmd_line **)p_line,TEST_CMD_LINE_NUM, MAAT_OP_ADD);
Maat_command_batch_commit(batch);
wait_for_cmd_effective_copy(feather, version_before);
for(i=0;i<TEST_CMD_LINE_NUM;i++)
{
line_rule[i].table_line=NULL;
}
Maat_cmd_set_lines(feather, (const struct Maat_cmd_line **)p_line,TEST_CMD_LINE_NUM, MAAT_OP_DEL);
free(p_line);
free(line_rule);
struct Maat_rule_t result;
scan_status_t mid=NULL;
int table_id=0;
table_id=Maat_table_register(feather, expr_table_name);
ASSERT_GT(table_id, 0);
memset(&result, 0, sizeof(result));
ret=Maat_full_scan_string(feather, table_id, CHARSET_GBK, keyword_buf, strlen(keyword_buf),
&result, NULL, 1,
&mid, 0);
EXPECT_EQ(ret, 1);
Maat_clean_status(&mid);
struct ipaddr ipv4_addr;
struct stream_tuple4_v4 v4_addr;
ipv4_addr_set_copy(&ipv4_addr, &v4_addr, src_ip_buff, 50001, dst_ip_buff, 80);
table_id=Maat_table_register(feather, ip_table_name);
ASSERT_GT(table_id, 0);
memset(&result, 0, sizeof(result));
ret=Maat_scan_proto_addr(feather, table_id, &ipv4_addr, 6, &result, 1, &mid, 0);
EXPECT_EQ(ret, 1);
Maat_clean_status(&mid);
return;
}

View File

@@ -2076,7 +2076,7 @@ Maat_feather_t MaatCmdTest::_shared_feather;
void* MaatCmdTest::logger;
int MaatCmdTest::linger_timeout;
int test_add_expr_command(Maat_feather_t feather,const char* region_table,int config_id, int timeout,int label_id, const char* keywords)
int test_add_expr_command(struct Maat_command_batch* batch, Maat_feather_t feather, const char* region_table, int config_id, int timeout, int label_id, const char* keywords)
{
char huge_serv_def[1024*2];
memset(huge_serv_def,'s',sizeof(huge_serv_def)-1);
@@ -2085,11 +2085,11 @@ int test_add_expr_command(Maat_feather_t feather,const char* region_table,int co
memset(&compile, 0, sizeof(compile));
compile.config_id=config_id;
strcpy(compile.service_defined, "maat_command");
Maat_command_raw_set_compile(feather, MAAT_OP_ADD, &compile, "COMPILE", huge_serv_def, 1, label_id, timeout);
Maat_command_batch_set_compile(batch, MAAT_OP_ADD, &compile, "COMPILE", huge_serv_def, 1, label_id, timeout);
struct Maat_cmd_region region;
memset(&region,0,sizeof(region));
region.region_id=Maat_cmd_get_new_region_id(feather);
region.region_id=Maat_command_get_new_region_id(feather);
region.region_type=REGION_EXPR;
region.table_name=region_table;
region.expr_rule.district=NULL;
@@ -2100,15 +2100,24 @@ int test_add_expr_command(Maat_feather_t feather,const char* region_table,int co
struct Maat_cmd_group2compile g2c;
memset(&g2c, 0, sizeof(g2c));
g2c.group_id=Maat_cmd_get_new_group_id(feather);
g2c.group_id=Maat_command_get_new_group_id(feather);;
g2c.table_name="GROUP2COMPILE";
g2c.compile_id=config_id;
g2c.clause_index=1;
Maat_command_raw_set_group2compile(feather, MAAT_OP_ADD, &g2c);
Maat_command_raw_set_region(feather, MAAT_OP_ADD, &region, g2c.group_id);
Maat_command_batch_set_group2compile(batch, MAAT_OP_ADD, &g2c);
Maat_command_batch_set_region(batch, MAAT_OP_ADD, &region, g2c.group_id);
return 0;
}
int test_add_expr_command_simple(Maat_feather_t feather, const char* region_table, int config_id, int timeout, int label_id, const char* keywords)
{
struct Maat_command_batch* batch=NULL;
batch=Maat_command_batch_new(feather);
test_add_expr_command(batch, feather, region_table, config_id, timeout, label_id, keywords);
Maat_command_batch_commit(batch);
return 0;
}
int del_command(Maat_feather_t feather, int config_id)
{
int ret=0;
@@ -2133,20 +2142,21 @@ TEST_F(MaatCmdTest, SetIP)
compile.config_id=config_id;
strcpy(compile.service_defined, "maat_command");
struct Maat_command_batch* batch=NULL;
batch=Maat_command_batch_new(feather);
//MUST acqire by function, because Maat_cmd_t has some hidden members.
Maat_command_raw_set_compile(feather, MAAT_OP_ADD, &compile, "COMPILE", NULL, 1, 0, timeout);
Maat_command_batch_set_compile(batch, MAAT_OP_ADD, &compile, "COMPILE", NULL, 1, 0, timeout);
struct Maat_cmd_group2compile g2c;
memset(&g2c, 0, sizeof(g2c));
g2c.group_id=Maat_cmd_get_new_group_id(feather);
g2c.group_id=Maat_command_get_new_group_id(feather);
g2c.compile_id=compile.config_id;
g2c.clause_index=1;
g2c.table_name="GROUP2COMPILE";
Maat_command_raw_set_group2compile(feather, MAAT_OP_ADD, &g2c);
Maat_command_batch_set_group2compile(batch, MAAT_OP_ADD, &g2c);
ret=Maat_read_state(feather,MAAT_STATE_VERSION, &version_before, sizeof(version_before));
EXPECT_EQ(ret, 0);
struct Maat_cmd_region region;
@@ -2165,9 +2175,14 @@ TEST_F(MaatCmdTest, SetIP)
region.ip_rule.dst_port=80;
region.ip_rule.mask_dst_port=65535;
region.ip_rule.protocol=0;//means any protocol should hit.
ret=Maat_command_raw_set_region(feather, MAAT_OP_ADD, &region, g2c.group_id);
ret=Maat_command_batch_set_region(batch, MAAT_OP_ADD, &region, g2c.group_id);
EXPECT_GE(ret, 0);
ret=Maat_read_state(feather,MAAT_STATE_VERSION, &version_before, sizeof(version_before));
EXPECT_EQ(ret, 0);
Maat_command_batch_commit(batch);
wait_for_cmd_effective(feather, version_before);
struct ipaddr ipv4_addr;
@@ -2221,7 +2236,7 @@ TEST_F(MaatCmdTest, SetExpr)
struct Maat_rule_t result;
int timeout=0;//seconds
int label_id=5210;
long long version_before=0,version_after=0;
long long version_before=0;
Maat_feather_t feather=MaatCmdTest::_shared_feather;
Maat_str_escape(escape_buff1, sizeof(escape_buff1),keywords1);
@@ -2230,16 +2245,17 @@ TEST_F(MaatCmdTest, SetExpr)
config_id=(int)Maat_cmd_incrby(feather, "TEST_SEQ", 2);
ret=Maat_read_state(feather,MAAT_STATE_VERSION, &version_before, sizeof(version_before));
test_add_expr_command(feather,table_name,config_id-1, 0, label_id, keywords);
test_add_expr_command(feather,table_name,config_id, 0, label_id, keywords);
struct Maat_command_batch* batch=NULL;
batch=Maat_command_batch_new(feather);
usleep(WAIT_FOR_EFFECTIVE_US);//waiting for commands go into effect
test_add_expr_command(batch, feather, table_name, config_id-1, 0, label_id, keywords);
test_add_expr_command(batch, feather, table_name, config_id, 0, label_id, keywords);
ret=Maat_read_state(feather,MAAT_STATE_VERSION, &version_before, sizeof(version_before));
Maat_command_batch_commit(batch);
ret=Maat_read_state(feather,MAAT_STATE_VERSION, &version_after, sizeof(version_after));
EXPECT_EQ(ret, 0);
EXPECT_GT(version_after, version_before);
wait_for_cmd_effective(feather, version_before);
table_id=Maat_table_register(feather,table_name);
table_id=Maat_table_register(feather, table_name);
ASSERT_GT(table_id, 0);
memset(&result, 0, sizeof(result));
ret=Maat_full_scan_string(feather, table_id,CHARSET_GBK, scan_data, strlen(scan_data),
@@ -2268,7 +2284,9 @@ TEST_F(MaatCmdTest, SetExpr)
timeout=1;
config_id=(int)Maat_cmd_incrby(feather, "TEST_SEQ", 1);
test_add_expr_command(feather,table_name,config_id, timeout, label_id, keywords);
batch=Maat_command_batch_new(feather);
test_add_expr_command(batch, feather, table_name, config_id, timeout, label_id, keywords);
Maat_command_batch_commit(batch);
usleep(timeout*1000*1000+WAIT_FOR_EFFECTIVE_US);
ret=Maat_full_scan_string(feather, table_id,CHARSET_GBK, scan_data, strlen(scan_data),
@@ -2293,7 +2311,8 @@ TEST_F(MaatCmdTest, RuleIDRecycle)
int rule_id=(int)Maat_cmd_incrby(feather, "TEST_SEQ", 1);
int label_id=5211, ret=0;
test_add_expr_command(feather,table_name,rule_id, 0, label_id, keywords);
test_add_expr_command_simple(feather,table_name,rule_id, 0, label_id, keywords);
usleep(WAIT_FOR_EFFECTIVE_US);//waiting for commands go into effect
@@ -2312,7 +2331,7 @@ TEST_F(MaatCmdTest, RuleIDRecycle)
Maat_clean_status(&mid);
EXPECT_EQ(ret, -2);
test_add_expr_command(feather,table_name,rule_id, 0, label_id, keywords);
test_add_expr_command_simple(feather,table_name,rule_id, 0, label_id, keywords);
usleep(WAIT_FOR_EFFECTIVE_US);//waiting for commands go into effect
memset(&result, 0, sizeof(result));
@@ -2343,12 +2362,16 @@ TEST_F(MaatCmdTest, ReturnRuleIDWithDescendingOrder)
int rule_id=(int)Maat_cmd_incrby(feather, "TEST_SEQ", repeat_times);
int label_id=5211, ret=0;
struct Maat_command_batch* batch=NULL;
batch=Maat_command_batch_new(feather);
for(i=0; i<repeat_times; i++)
{
//add in ascending order
expect_ruleid[i]=rule_id+1-repeat_times+i;
test_add_expr_command(feather,table_name,rule_id+1-repeat_times+i, 0, label_id, keywords);
test_add_expr_command(batch, feather, table_name,rule_id+1-repeat_times+i, 0, label_id, keywords);
}
Maat_command_batch_commit(batch);
usleep(WAIT_FOR_EFFECTIVE_US);//waiting for commands go into effect
memset(&result, 0, sizeof(result));
ret=Maat_full_scan_string(feather, table_id,CHARSET_GBK, scan_data, strlen(scan_data),
@@ -2395,7 +2418,7 @@ TEST_F(MaatCmdTest, SubGroup)
//group1->compile1
memset(&group1, 0, sizeof(group1));
group1.group_id=Maat_cmd_get_new_group_id(feather);
group1.group_id=Maat_command_get_new_group_id(feather);
group1.table_name=g2c_tn;
group1.compile_id=compile1.config_id;
group1.clause_index=1;
@@ -2412,7 +2435,7 @@ TEST_F(MaatCmdTest, SubGroup)
\__compile2
*/
memset(&group2, 0, sizeof(group2));
group2.group_id=Maat_cmd_get_new_group_id(feather);
group2.group_id=Maat_command_get_new_group_id(feather);
group2.table_name=g2g_tn;
group2.superior_group_id=group1.group_id;
@@ -2424,13 +2447,13 @@ TEST_F(MaatCmdTest, SubGroup)
\_compile2
*/
memset(&region1, 0, sizeof(region1));
region1.region_id=Maat_cmd_get_new_region_id(feather);
region1.region_id=Maat_command_get_new_region_id(feather);
region1.region_type=REGION_EXPR;
region1.table_name=table_name;
region1.expr_rule.keywords=keyword1;
region1.expr_rule.expr_type=EXPR_TYPE_AND;
Maat_command_raw_set_region(feather, MAAT_OP_ADD, &region1, group2.group_id);
sleep(1);
sleep(4);
struct Maat_rule_t result[4];
memset(&result, 0, sizeof(result));
@@ -2491,13 +2514,13 @@ TEST_F(MaatCmdTest, SubGroup)
*/
memset(&group3, 0, sizeof(group3));
group3.group_id=Maat_cmd_get_new_group_id(feather);
group3.group_id=Maat_command_get_new_group_id(feather);
group3.superior_group_id=group1.group_id;
group3.table_name=g2g_tn;
Maat_command_raw_set_group2group(feather, MAAT_OP_ADD, &group3);
memset(&region2, 0, sizeof(region2));
region2.region_id=Maat_cmd_get_new_region_id(feather);
region2.region_id=Maat_command_get_new_region_id(feather);
region2.region_type=REGION_EXPR;
region2.table_name=table_name;
region2.expr_rule.keywords=keyword2;
@@ -2562,7 +2585,7 @@ TEST_F(MaatCmdTest, RefGroup)
//group1->compile1
memset(&group1, 0, sizeof(group1));
group1.group_id=Maat_cmd_get_new_group_id(feather);
group1.group_id=Maat_command_get_new_group_id(feather);
group1.table_name=g2c_tn;
group1.compile_id=compile1.config_id;
Maat_command_raw_set_group2compile(feather, MAAT_OP_ADD, &group1);
@@ -2571,7 +2594,7 @@ TEST_F(MaatCmdTest, RefGroup)
//region1->group1->compile1
memset(&region1, 0, sizeof(region1));
region1.region_id=Maat_cmd_get_new_region_id(feather);
region1.region_id=Maat_command_get_new_region_id(feather);
region1.region_type=REGION_EXPR;
region1.table_name=table_name;
region1.expr_rule.keywords=keyword1;
@@ -2589,12 +2612,12 @@ TEST_F(MaatCmdTest, RefGroup)
// /
// region2->group2
memset(&group2, 0, sizeof(group2));
group2.group_id=Maat_cmd_get_new_group_id(feather);
group2.group_id=Maat_command_get_new_group_id(feather);
group2.table_name=g2c_tn;
group2.compile_id=compile1.config_id;
memset(&region2, 0, sizeof(region2));
region2.region_id=Maat_cmd_get_new_region_id(feather);
region2.region_id=Maat_command_get_new_region_id(feather);
region2.region_type=REGION_EXPR;
region2.table_name=table_name;
region2.expr_rule.keywords=keyword2;
@@ -2644,7 +2667,7 @@ TEST_F(MaatCmdTest, VirtualTable)
//group1->compile1
memset(&group1, 0, sizeof(group1));
group1.group_id=Maat_cmd_get_new_group_id(feather);
group1.group_id=Maat_command_get_new_group_id(feather);
group1.table_name=g2c_tn;
group1.virtual_table_name="HTTP_REQUEST_HEADER";
group1.compile_id=compile1.config_id;
@@ -2654,7 +2677,7 @@ TEST_F(MaatCmdTest, VirtualTable)
//region1->group1->compile1
memset(&region1, 0, sizeof(region1));
region1.region_id=Maat_cmd_get_new_region_id(feather);
region1.region_id=Maat_command_get_new_region_id(feather);
region1.region_type=REGION_EXPR;
region1.table_name=region_table_name;
region1.expr_rule.district="User-Agent";
@@ -2666,7 +2689,7 @@ TEST_F(MaatCmdTest, VirtualTable)
// /
// group2-/
memset(&group2, 0, sizeof(group2));
group2.group_id=Maat_cmd_get_new_group_id(feather);
group2.group_id=Maat_command_get_new_group_id(feather);
group2.table_name=g2c_tn;
group2.virtual_table_name="HTTP_RESPONSE_HEADER";
group2.compile_id=compile1.config_id;
@@ -2679,7 +2702,7 @@ TEST_F(MaatCmdTest, VirtualTable)
// region2->group2-/
memset(&region2, 0, sizeof(region2));
region2.region_id=Maat_cmd_get_new_region_id(feather);
region2.region_id=Maat_command_get_new_region_id(feather);
region2.region_type=REGION_EXPR;
region2.table_name=region_table_name;
region2.expr_rule.district="Cookie";
@@ -3087,7 +3110,7 @@ TEST_F(MaatCmdTest, HitPath)
//group1->compile1
memset(&group1, 0, sizeof(group1));
group1.group_id=Maat_cmd_get_new_group_id(feather);
group1.group_id=Maat_command_get_new_group_id(feather);
group1.table_name=g2c_tn;
group1.virtual_table_name="HTTP_REQUEST_HEADER";
group1.compile_id=compile1.config_id;
@@ -3098,7 +3121,7 @@ TEST_F(MaatCmdTest, HitPath)
//region1->group1->compile1
memset(&region1, 0, sizeof(region1));
region1.region_id=Maat_cmd_get_new_region_id(feather);
region1.region_id=Maat_command_get_new_region_id(feather);
region1.region_type=REGION_EXPR;
region1.table_name=table_http_sig;
region1.expr_rule.district="URL";
@@ -3112,7 +3135,7 @@ TEST_F(MaatCmdTest, HitPath)
// group21/
memset(&group21, 0, sizeof(group21));
group21.group_id=Maat_cmd_get_new_group_id(feather);
group21.group_id=Maat_command_get_new_group_id(feather);
group21.table_name=g2c_tn;
group21.virtual_table_name="HTTP_RESPONSE_HEADER";
group21.compile_id=compile1.config_id;
@@ -3125,7 +3148,7 @@ TEST_F(MaatCmdTest, HitPath)
// group2->group21/
memset(&group2, 0, sizeof(group2));
group2.group_id=Maat_cmd_get_new_group_id(feather);
group2.group_id=Maat_command_get_new_group_id(feather);
group2.table_name=g2g_tn;
group2.superior_group_id=group21.group_id;
Maat_command_raw_set_group2group(feather, MAAT_OP_ADD, &group2);
@@ -3137,7 +3160,7 @@ TEST_F(MaatCmdTest, HitPath)
//region2->group2->group21/
memset(&region2, 0, sizeof(region2));
region2.region_id=Maat_cmd_get_new_region_id(feather);
region2.region_id=Maat_command_get_new_region_id(feather);
region2.region_type=REGION_EXPR;
region2.table_name=table_http_sig;
region2.expr_rule.district="Cookie";
@@ -3147,7 +3170,7 @@ TEST_F(MaatCmdTest, HitPath)
//region3->group3, group3 is not referenced by any compile.
memset(&region3, 0, sizeof(region3));
region3.region_id=Maat_cmd_get_new_region_id(feather);
region3.region_id=Maat_command_get_new_region_id(feather);
region3.region_type=REGION_IP;
region3.table_name=table_ip;
region3.ip_rule.addr_type=ADDR_TYPE_IPv4;
@@ -3163,20 +3186,20 @@ TEST_F(MaatCmdTest, HitPath)
region3.ip_rule.mask_dst_port=65535;
region3.ip_rule.protocol=0;//means any protocol should hit.
group3.group_id=Maat_cmd_get_new_group_id(feather);
group3.group_id=Maat_command_get_new_group_id(feather);
Maat_command_raw_set_region(feather, MAAT_OP_ADD, &region3, group3.group_id);
char temp[1024]={0};
//region4->group4, group4 is not referenced by any compile.
memset(&region4, 0, sizeof(region4));
region4.region_id=Maat_cmd_get_new_region_id(feather);
region4.region_id=Maat_command_get_new_region_id(feather);
region4.region_type=REGION_EXPR;
region4.table_name=table_keywords;
region4.expr_rule.district=NULL;
region4.expr_rule.keywords= Maat_str_escape(temp, sizeof(temp), "a finite or infinite");
region4.expr_rule.expr_type=EXPR_TYPE_STRING;
group4.group_id=Maat_cmd_get_new_group_id(feather);
group4.group_id=Maat_command_get_new_group_id(feather);
Maat_command_raw_set_region(feather, MAAT_OP_ADD, &region4, group4.group_id);