summaryrefslogtreecommitdiff
path: root/shaping/test/gtest_shaper.cpp
diff options
context:
space:
mode:
author刘畅 <[email protected]>2024-06-05 09:36:46 +0000
committer刘畅 <[email protected]>2024-06-05 09:36:46 +0000
commitf91407a5524365bb93dc6e8f96ef2b08ef3fe8a0 (patch)
treeea321ee2ec356db1ae52cdb562b90a45dfbf17a5 /shaping/test/gtest_shaper.cpp
parentdbb0f42537aee97e8f393f9f8a84856fb8aec5af (diff)
parentda691ef02580893d6539f39e7543443f427ef2a6 (diff)
Merge branch 'session_in_out_pkts_independent_queue' into 'rel'v3.1.37
TSG-19453: Session in out pkts independent queue See merge request tango/shaping-engine!97
Diffstat (limited to 'shaping/test/gtest_shaper.cpp')
-rw-r--r--shaping/test/gtest_shaper.cpp140
1 files changed, 64 insertions, 76 deletions
diff --git a/shaping/test/gtest_shaper.cpp b/shaping/test/gtest_shaper.cpp
index 905a4f8..78b8247 100644
--- a/shaping/test/gtest_shaper.cpp
+++ b/shaping/test/gtest_shaper.cpp
@@ -45,7 +45,7 @@ static struct stub_packet_node* packet_node_new(stub_packet *packet)
return pkt_node;
}
-static void send_packets(struct shaping_thread_ctx *ctx, struct shaping_flow *sf, int pkt_num, int pkt_len, unsigned char dir,
+static void send_packets(struct shaping_thread_ctx *ctx, struct shaping_flow *sf, int pkt_num, int pkt_len, enum shaping_packet_dir dir,
struct stub_pkt_queue *expec_tx_queue, int polling_times, int is_tcp_pure_control)
{
struct stub_packet_node *pkt_node;
@@ -250,12 +250,11 @@ TEST(single_session, udp_tx_in_order)
/**********send packets*********************/
- send_packets(&ctx->thread_ctx[0], sf, 101, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
/*******************************************/
//first 10 packets
ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10));
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 1));//async pass 1 packet
ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue));
while (!TAILQ_EMPTY(&expec_tx_queue)) {//last 90 delay packets
@@ -288,7 +287,7 @@ TEST(single_session, udp_tx_in_order)
stat_file = fopen(SHAPING_STAT_FILE_NAME, "r");
memset(line, 0, sizeof(line));
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));
- shaping_stat_judge(line, 0, 0, 1, 101, 10100, 0, 0, 171000, SHAPING_DIR_OUT, profile_type_primary);//max latency is last 10 pkts
+ shaping_stat_judge(line, 0, 0, 1, 100, 10000, 0, 0, 171000, SHAPING_DIR_OUT, profile_type_primary);//max latency is last 10 pkts
fclose(stat_file);
stat_file = fopen(SHAPING_STAT_FILE_NAME, "w");//clear stat file
fclose(stat_file);
@@ -297,7 +296,7 @@ TEST(single_session, udp_tx_in_order)
stat_file = fopen(SHAPING_GLOBAL_STAT_FILE_NAME, "r");
memset(line, 0, sizeof(line));
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));
- shaping_global_stat_judge(line, 101, 10100, 0, 0, 0, 0);
+ shaping_global_stat_judge(line, 100, 10000, 0, 0, 0, 0);
fclose(stat_file);
}
@@ -306,7 +305,8 @@ TEST(single_session, udp_tx_in_order)
profile: bidirectional limit 1000*/
TEST(bidirectional, udp_tx_in_order)
{
- struct stub_pkt_queue expec_tx_queue;
+ struct stub_pkt_queue expec_tx_queue_in;
+ struct stub_pkt_queue expec_tx_queue_out;
struct stub_pkt_queue *actual_tx_queue;
struct shaping_ctx *ctx = NULL;
struct shaping_flow *sf = NULL;
@@ -315,7 +315,8 @@ TEST(bidirectional, udp_tx_in_order)
int profile_num[] = {1};
int profile_id[][MAX_REF_PROFILE] = {{0}};
- TAILQ_INIT(&expec_tx_queue);
+ TAILQ_INIT(&expec_tx_queue_in);
+ TAILQ_INIT(&expec_tx_queue_out);
stub_init();
ctx = shaping_engine_init();
ASSERT_TRUE(ctx != NULL);
@@ -328,32 +329,32 @@ TEST(bidirectional, udp_tx_in_order)
shaper_rules_update(&ctx->thread_ctx[0], sf, rule_id, 1);
/*******send packets***********/
- send_packets(&ctx->thread_ctx[0], sf, 10, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
- send_packets(&ctx->thread_ctx[0], sf, 10, 100, SHAPING_DIR_IN, &expec_tx_queue, 1, 0);
- send_packets(&ctx->thread_ctx[0], sf, 10, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf, 10, 100, SHAPING_DIR_OUT, &expec_tx_queue_out, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf, 10, 100, SHAPING_DIR_IN, &expec_tx_queue_in, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf, 10, 100, SHAPING_DIR_OUT, &expec_tx_queue_out, 1, 0);
//first 10 out packets
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10));
+ ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue_out, actual_tx_queue, 10));
ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue));
stub_refresh_token_bucket(0);
- for (int i = 0; i < 11; i++) {//first polling just request token and don't send pkt
- polling_entry(ctx->thread_ctx[0].sp, ctx->thread_ctx[0].stat, &ctx->thread_ctx[0]);
- stub_curr_time_ns_inc(STUB_TIME_INC_FOR_PACKET);
- }
- //10 out packets
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10));
- ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue));
+ polling_entry(ctx->thread_ctx[0].sp, ctx->thread_ctx[0].stat, &ctx->thread_ctx[0]);
+ ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue_out, actual_tx_queue, 1));
- stub_refresh_token_bucket(0);
- for (int i = 0; i < 11; i++) {//first polling just request token and don't send pkt
+ while(!TAILQ_EMPTY(&expec_tx_queue_out)) {
+ stub_refresh_token_bucket(0);
polling_entry(ctx->thread_ctx[0].sp, ctx->thread_ctx[0].stat, &ctx->thread_ctx[0]);
- stub_curr_time_ns_inc(STUB_TIME_INC_FOR_PACKET);
+
+ ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue_in, actual_tx_queue, 1));
+ ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue_out, actual_tx_queue, 1));
}
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10));
+
+ polling_entry(ctx->thread_ctx[0].sp, ctx->thread_ctx[0].stat, &ctx->thread_ctx[0]);
+ ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue_in, actual_tx_queue, 1));
+
ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue));
- ASSERT_TRUE(TAILQ_EMPTY(&expec_tx_queue));
+ ASSERT_TRUE(TAILQ_EMPTY(&expec_tx_queue_in));
shaping_flow_free(&ctx->thread_ctx[0], sf);
fieldstat_global_disable_prometheus_endpoint();
@@ -393,12 +394,11 @@ TEST(max_min_host_fairness_profile, udp_tx_in_order)
/**********send packets*********************/
- send_packets(&ctx->thread_ctx[0], sf, 101, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
/*******************************************/
//first 10 packets
ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10));
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 1));//async pass 1 packet
ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue));
while (!TAILQ_EMPTY(&expec_tx_queue)) {//last 90 delay packets
@@ -431,7 +431,7 @@ TEST(max_min_host_fairness_profile, udp_tx_in_order)
stat_file = fopen(SHAPING_STAT_FILE_NAME, "r");
memset(line, 0, sizeof(line));
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));
- shaping_stat_judge(line, 0, 0, 1, 101, 10100, 0, 0, 172000, SHAPING_DIR_OUT, profile_type_primary);//max latency is last 10 pkts
+ shaping_stat_judge(line, 0, 0, 1, 100, 10000, 0, 0, 171000, SHAPING_DIR_OUT, profile_type_primary);//max latency is last 10 pkts
fclose(stat_file);
stat_file = fopen(SHAPING_STAT_FILE_NAME, "w");//clear stat file
fclose(stat_file);
@@ -440,7 +440,7 @@ TEST(max_min_host_fairness_profile, udp_tx_in_order)
stat_file = fopen(SHAPING_GLOBAL_STAT_FILE_NAME, "r");
memset(line, 0, sizeof(line));
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));
- shaping_global_stat_judge(line, 101, 10100, 0, 0, 0, 0);
+ shaping_global_stat_judge(line, 100, 10000, 0, 0, 0, 0);
fclose(stat_file);
}
@@ -473,12 +473,11 @@ TEST(single_session, tcp_tx_in_order)
shaper_rules_update(&ctx->thread_ctx[0], sf, rule_id, 1);
/*******send packets***********/
- send_packets(&ctx->thread_ctx[0], sf, 21, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf, 20, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
send_packets(&ctx->thread_ctx[0], sf, 10, 100, SHAPING_DIR_OUT, &expec_pure_ctl_tx_queue, 1, 1);
//first 10 packets
ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10));
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 1));//async pass 1 packet
//10 pure ctrl pkts
ASSERT_EQ(0, judge_packet_eq(&expec_pure_ctl_tx_queue, actual_tx_queue, 10));
ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue));
@@ -522,7 +521,7 @@ TEST(single_session, tcp_tx_in_order)
stat_file = fopen(SHAPING_STAT_FILE_NAME, "r");
memset(line, 0, sizeof(line));
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));
- shaping_stat_judge(line, 0, 0, 1, 21, 2100, 0, 10, 0, SHAPING_DIR_OUT, profile_type_primary);
+ shaping_stat_judge(line, 0, 0, 1, 20, 2000, 0, 10, 0, SHAPING_DIR_OUT, profile_type_primary);
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));
shaping_stat_judge(line, 0, 0, 1, 10, 1000, 0, 0, 31000, SHAPING_DIR_OUT, profile_type_primary);
@@ -538,7 +537,8 @@ TEST(single_session, tcp_tx_in_order)
direction OUT*/
TEST(single_session, udp_diff_direction)
{
- struct stub_pkt_queue expec_tx_queue;
+ struct stub_pkt_queue expec_tx_queue_in;
+ struct stub_pkt_queue expec_tx_queue_out;
struct stub_pkt_queue *actual_tx_queue;
struct shaping_ctx *ctx = NULL;
struct shaping_flow *sf = NULL;
@@ -547,7 +547,8 @@ TEST(single_session, udp_diff_direction)
int profile_num[] = {1};
int profile_id[][MAX_REF_PROFILE] = {{0}};
- TAILQ_INIT(&expec_tx_queue);
+ TAILQ_INIT(&expec_tx_queue_in);
+ TAILQ_INIT(&expec_tx_queue_out);
stub_init();
ctx = shaping_engine_init();
ASSERT_TRUE(ctx != NULL);
@@ -560,16 +561,17 @@ TEST(single_session, udp_diff_direction)
shaper_rules_update(&ctx->thread_ctx[0], sf, rule_id, 1);
/*******send packets***********/
- send_packets(&ctx->thread_ctx[0], sf, 10, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
- send_packets(&ctx->thread_ctx[0], sf, 10, 100, SHAPING_DIR_IN, &expec_tx_queue, 1, 0);
- send_packets(&ctx->thread_ctx[0], sf, 10, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
- send_packets(&ctx->thread_ctx[0], sf, 10, 100, SHAPING_DIR_IN, &expec_tx_queue, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf, 10, 100, SHAPING_DIR_OUT, &expec_tx_queue_out, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf, 10, 100, SHAPING_DIR_IN, &expec_tx_queue_in, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf, 10, 100, SHAPING_DIR_OUT, &expec_tx_queue_out, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf, 10, 100, SHAPING_DIR_IN, &expec_tx_queue_in, 1, 0);
//first 10 out packets
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10));
- //10 in pcakets without consume token
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10));
+ ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue_out, actual_tx_queue, 10));
+ //20 in pcakets without consume token
+ ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue_in, actual_tx_queue, 20));
+ ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue));
stub_refresh_token_bucket(0);
for (int i = 0; i < 22; i++) {//first polling just request token and don't send pkt
@@ -577,9 +579,7 @@ TEST(single_session, udp_diff_direction)
stub_curr_time_ns_inc(STUB_TIME_INC_FOR_PACKET);
}
//10 out packets
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10));
- //10 in packtets
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10));
+ ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue_out, actual_tx_queue, 10));
ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue));
shaping_flow_free(&ctx->thread_ctx[0], sf);
@@ -600,9 +600,9 @@ TEST(single_session, udp_diff_direction)
stat_file = fopen(SHAPING_STAT_FILE_NAME, "r");
memset(line, 0, sizeof(line));
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));
- shaping_stat_judge(line, 0, 0, 1, 20, 2000, 0, 0, 20000, SHAPING_DIR_OUT, profile_type_primary);
+ shaping_stat_judge(line, 0, 0, 1, 20, 2000, 0, 0, 21000, SHAPING_DIR_OUT, profile_type_primary);
- shaping_stat_judge(line, 0, 0, 1, 20, 2000, 0, 0, 20000, SHAPING_DIR_IN, profile_type_primary);
+ shaping_stat_judge(line, 0, 0, 1, 20, 2000, 0, 0, 0, SHAPING_DIR_IN, profile_type_primary);
fclose(stat_file);
stat_file = fopen(SHAPING_STAT_FILE_NAME, "w");//clear stat file
fclose(stat_file);
@@ -641,12 +641,11 @@ TEST(single_session, udp_multi_rules)
shaper_rules_update(&ctx->thread_ctx[0], sf, rule_id, 3);
/*******send packets***********/
- send_packets(&ctx->thread_ctx[0], sf, 101, 100, SHAPING_DIR_OUT, &expec_tx_queue, 5, 0);
+ send_packets(&ctx->thread_ctx[0], sf, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue, 5, 0);
//first 10 packets
ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10));
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 1));//async pass 1 packet
while (!TAILQ_EMPTY(&expec_tx_queue)) {//last 90 delay packets
stub_refresh_token_bucket(0);
@@ -679,13 +678,13 @@ TEST(single_session, udp_multi_rules)
stat_file = fopen(SHAPING_STAT_FILE_NAME, "r");
memset(line, 0, sizeof(line));
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));//profile_id 0
- shaping_stat_judge(line, 0, 0, 1, 101, 10100, 0, 0, 507000, SHAPING_DIR_OUT, profile_type_primary);
+ shaping_stat_judge(line, 0, 0, 1, 100, 10000, 0, 0, 507000, SHAPING_DIR_OUT, profile_type_primary);
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));//profile_id 1
- shaping_stat_judge(line, 1, 1, 1, 101, 10100, 0, 0, 1000, SHAPING_DIR_OUT, profile_type_primary);
+ shaping_stat_judge(line, 1, 1, 1, 100, 10000, 0, 0, 1000, SHAPING_DIR_OUT, profile_type_primary);
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));//profile_id 2
- shaping_stat_judge(line, 2, 2, 1, 101, 10100, 0, 0, 91000, SHAPING_DIR_OUT, profile_type_primary);//max latency is first queued pkt
+ shaping_stat_judge(line, 2, 2, 1, 100, 10000, 0, 0, 91000, SHAPING_DIR_OUT, profile_type_primary);//max latency is first queued pkt
fclose(stat_file);
stat_file = fopen(SHAPING_STAT_FILE_NAME, "w");//clear stat file
@@ -721,12 +720,11 @@ TEST(single_session, udp_borrow)
shaper_rules_update(&ctx->thread_ctx[0], sf, rule_id, 1);
/*******send packets***********/
- send_packets(&ctx->thread_ctx[0], sf, 101, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
//first 10 packets
ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10));
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 1));//async pass 1 packet
while (!TAILQ_EMPTY(&expec_tx_queue)) {//last 90 delay packets
stub_refresh_token_bucket(2);
@@ -758,7 +756,7 @@ TEST(single_session, udp_borrow)
shaping_stat_judge(line, 1, 1, 1, 0, 0, 0, 0, 171000, SHAPING_DIR_OUT, profile_type_primary);
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));//profile_id 2, borrow
- shaping_stat_judge(line, 1, 2, 2, 101, 10100, 0, 0, 0, SHAPING_DIR_OUT, profile_type_borrow);
+ shaping_stat_judge(line, 1, 2, 2, 100, 10000, 0, 0, 0, SHAPING_DIR_OUT, profile_type_borrow);
fclose(stat_file);
stat_file = fopen(SHAPING_STAT_FILE_NAME, "w");//clear stat file
@@ -797,12 +795,11 @@ TEST(single_session, udp_borrow_same_priority_9)
shaper_rules_update(&ctx->thread_ctx[0], sf, rule_id, 1);
/*******send packets***********/
- send_packets(&ctx->thread_ctx[0], sf, 101, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
//first 10 packets
ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10));
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 1));//async pass 1 packet
while (!TAILQ_EMPTY(&expec_tx_queue)) {//last 90 delay packets
stub_refresh_token_bucket(3);
@@ -839,7 +836,7 @@ TEST(single_session, udp_borrow_same_priority_9)
#endif
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));//profile_id 3, borrow
- shaping_stat_judge(line, 1, 3, 9, 101, 10100, 0, 0, 0, SHAPING_DIR_OUT, profile_type_borrow);
+ shaping_stat_judge(line, 1, 3, 9, 100, 10000, 0, 0, 0, SHAPING_DIR_OUT, profile_type_borrow);
fclose(stat_file);
stat_file = fopen(SHAPING_STAT_FILE_NAME, "w");//clear stat file
@@ -945,13 +942,12 @@ TEST(two_session_diff_priority_same_profile, udp_borrow_in_order)
/*******send packets***********/
- send_packets(&ctx->thread_ctx[0], sf1, 101, 100, SHAPING_DIR_OUT, &expec_tx_queue1, 1, 0);
- send_packets(&ctx->thread_ctx[0], sf2, 101, 100, SHAPING_DIR_OUT, &expec_tx_queue2, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf1, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue1, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf2, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue2, 1, 0);
//first 10 packets
ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue1, actual_tx_queue, 10));
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue1, actual_tx_queue, 1));//async pass 1 packet
ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue));
stub_refresh_token_bucket(2);
@@ -960,7 +956,6 @@ TEST(two_session_diff_priority_same_profile, udp_borrow_in_order)
stub_curr_time_ns_inc(STUB_TIME_INC_FOR_PACKET);
}
ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue2, actual_tx_queue, 10));
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue2, actual_tx_queue, 1));//async pass 1 packet
ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue));
while (!TAILQ_EMPTY(&expec_tx_queue2)) {
@@ -1003,13 +998,13 @@ TEST(two_session_diff_priority_same_profile, udp_borrow_in_order)
stat_file = fopen(SHAPING_STAT_FILE_NAME, "r");
memset(line, 0, sizeof(line));
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));//profile_id 1, primary
- shaping_stat_judge(line, 1, 1, 1, 0, 0, 0, 0, 1472000, SHAPING_DIR_OUT, profile_type_primary);
+ shaping_stat_judge(line, 1, 1, 1, 0, 0, 0, 0, 1471000, SHAPING_DIR_OUT, profile_type_primary);
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));//profile_id 2, borrow
- shaping_stat_judge(line, 1, 2, 2, 101, 10100, 0, 0, 0, SHAPING_DIR_OUT, profile_type_borrow);
+ shaping_stat_judge(line, 1, 2, 2, 100, 10000, 0, 0, 0, SHAPING_DIR_OUT, profile_type_borrow);
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));//profile_id 2, primary
- shaping_stat_judge(line, 2, 2, 1, 101, 10100, 0, 0, 191000, SHAPING_DIR_OUT, profile_type_primary);
+ shaping_stat_judge(line, 2, 2, 1, 100, 10000, 0, 0, 191000, SHAPING_DIR_OUT, profile_type_primary);
fclose(stat_file);
stat_file = fopen(SHAPING_STAT_FILE_NAME, "w");//clear stat file
@@ -1064,7 +1059,6 @@ TEST(two_session_diff_priority_same_profile, two_thread_udp_tx_in_order)
send_packets(&ctx->thread_ctx[0], sf1, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue1, 1, 0);
send_packets(&ctx->thread_ctx[1], sf2, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue2, 1, 0);
ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue1, actual_tx_queue, 10));
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue1, actual_tx_queue, 1));//async pass 1 packet
ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue));
shaper_stat_refresh(&ctx->thread_ctx[0], sf1, 1);//刷新线程0中的优先级队列长度到swarmkv中
@@ -1151,7 +1145,6 @@ TEST(two_session_diff_priority_same_profile, profile_timer_test)
send_packets(&ctx->thread_ctx[0], sf1, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue1, 1, 0);
send_packets(&ctx->thread_ctx[1], sf2, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue2, 1, 0);
ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue1, actual_tx_queue, 10));
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue1, actual_tx_queue, 1));//async pass 1 packet
ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue));
sleep(3);//wait profile timer to expire, to refresh priority queue_len to swarmkv
@@ -1259,7 +1252,6 @@ TEST(two_sessions, priority_non_block)
send_packets(&ctx->thread_ctx[0], sf1, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue1, 3, 0);//sf1 blocked by rule2(profile id 1), while rule3(profile id 0) still has 1000 token
send_packets(&ctx->thread_ctx[1], sf2, 10, 100, SHAPING_DIR_OUT, &expec_tx_queue2, 1, 0);
ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue1, actual_tx_queue, 10));//sf1 should send 10 pkts
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue1, actual_tx_queue, 1));//sf1 async pass 1 pkts
ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue2, actual_tx_queue, 10));//sf2 should send 10 pkts cause rule3(profile id 0) has 1000 token
ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue));
@@ -1334,7 +1326,6 @@ TEST(two_sessions, borrow_when_primary_profile_priority_blocked)
send_packets(&ctx->thread_ctx[0], sf1, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue1, 1, 0);
send_packets(&ctx->thread_ctx[1], sf2, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue2, 1, 0);
ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue1, actual_tx_queue, 10));
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue1, actual_tx_queue, 1));//async pass 1 packet
while (!TAILQ_EMPTY(&expec_tx_queue2)) {
stub_refresh_token_bucket(1);
@@ -1407,11 +1398,10 @@ TEST(two_sessions, primary_profile_priority_blocked_by_borrow_profile)
shaper_rules_update(&ctx->thread_ctx[1], sf2, rule_id2, 1);
/*******send packets***********/
- send_packets(&ctx->thread_ctx[0], sf1, 101, 100, SHAPING_DIR_OUT, &expec_tx_queue1, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf1, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue1, 1, 0);
send_packets(&ctx->thread_ctx[1], sf2, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue2, 1, 0);
ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue1, actual_tx_queue, 10));
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue1, actual_tx_queue, 1));//async pass 1 packet
ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue));
while (!TAILQ_EMPTY(&expec_tx_queue1)) {
@@ -1468,12 +1458,11 @@ TEST(statistics, udp_drop_pkt)
shaper_rules_update(&ctx->thread_ctx[0], sf, rule_id, 1);
/*******send packets***********/
- send_packets(&ctx->thread_ctx[0], sf, SHAPING_SESSION_QUEUE_LEN + 10 + 1, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf, SHAPING_SESSION_QUEUE_LEN + 10, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
send_packets(&ctx->thread_ctx[0], sf, 100, 100, SHAPING_DIR_OUT, NULL, 1, 0);//these 100 pkts will be dropped
//first 10 packets
ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10));
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 1));//async pass 1 packet
ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue));
while (!TAILQ_EMPTY(&expec_tx_queue)) {
@@ -1503,7 +1492,7 @@ TEST(statistics, udp_drop_pkt)
stat_file = fopen(SHAPING_STAT_FILE_NAME, "r");
memset(line, 0, sizeof(line));
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));
- shaping_stat_judge(line, 0, 0, 1, SHAPING_SESSION_QUEUE_LEN+10+1, (SHAPING_SESSION_QUEUE_LEN+10+1)*100, 100, 0, 228000, SHAPING_DIR_OUT, profile_type_primary);//every queued pkt's latency is max
+ shaping_stat_judge(line, 0, 0, 1, SHAPING_SESSION_QUEUE_LEN+10, (SHAPING_SESSION_QUEUE_LEN+10)*100, 100, 0, 228000, SHAPING_DIR_OUT, profile_type_primary);//every queued pkt's latency is max
fclose(stat_file);
stat_file = fopen(SHAPING_STAT_FILE_NAME, "w");//clear stat file
fclose(stat_file);
@@ -1512,7 +1501,7 @@ TEST(statistics, udp_drop_pkt)
stat_file = fopen(SHAPING_GLOBAL_STAT_FILE_NAME, "r");
memset(line, 0, sizeof(line));
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));
- shaping_global_stat_judge(line, SHAPING_SESSION_QUEUE_LEN+10+1, (SHAPING_SESSION_QUEUE_LEN+10+1)*100, 100, 10000, 0, 0);
+ shaping_global_stat_judge(line, SHAPING_SESSION_QUEUE_LEN+10, (SHAPING_SESSION_QUEUE_LEN+10)*100, 100, 10000, 0, 0);
fclose(stat_file);
}
@@ -1545,7 +1534,7 @@ TEST(statistics, udp_queueing_pkt)
shaper_rules_update(&ctx->thread_ctx[0], sf, rule_id, 1);
/*******send packets***********/
- send_packets(&ctx->thread_ctx[0], sf, 101, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
+ send_packets(&ctx->thread_ctx[0], sf, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue, 1, 0);
/***********send stat data here********************/
@@ -1558,12 +1547,11 @@ TEST(statistics, udp_queueing_pkt)
stat_file = fopen(SHAPING_GLOBAL_STAT_FILE_NAME, "r");
memset(line, 0, sizeof(line));
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));
- shaping_global_stat_judge(line, 11, 1100, 0, 0, 90, 9000);
+ shaping_global_stat_judge(line, 10, 1000, 0, 0, 90, 9000);
fclose(stat_file);
//first 10 packets
ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10));
- ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 1));//async pass 1 packet
ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue));
while (!TAILQ_EMPTY(&expec_tx_queue)) {//last 90 delay packets
@@ -1593,7 +1581,7 @@ TEST(statistics, udp_queueing_pkt)
memset(line, 0, sizeof(line));
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));//stat data first sent
- shaping_stat_judge(line, 0, 0, 1, 11, 1100, 0, 90, 0, SHAPING_DIR_OUT, profile_type_primary);
+ shaping_stat_judge(line, 0, 0, 1, 10, 1000, 0, 90, 0, SHAPING_DIR_OUT, profile_type_primary);
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));//stat data last sent
shaping_stat_judge(line, 0, 0, 1, 90, 9000, 0, 0, 90000, SHAPING_DIR_OUT, profile_type_primary);