diff options
| author | root <[email protected]> | 2024-01-09 08:20:21 +0000 |
|---|---|---|
| committer | root <[email protected]> | 2024-01-09 08:20:21 +0000 |
| commit | 5f4d71b683d3d460bb0785a9426a4f12c81d99c9 (patch) | |
| tree | ad90f13e0866045d6a7afe5aa45f5ecad71b1c9d /shaping/test/gtest_shaper.cpp | |
| parent | 7c599b8c88ecc009651062eddbff0b07909b8928 (diff) | |
TSG-18176:对于一个session,当同一个profile多次作为primary profile出现时,按规则匹配顺序,只执行匹配的第一条rule,使用被执行的rule配置的fair-factor。
当同一个profile作为borrow多次出现时,暂时忽略此情况不处理
Diffstat (limited to 'shaping/test/gtest_shaper.cpp')
| -rw-r--r-- | shaping/test/gtest_shaper.cpp | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/shaping/test/gtest_shaper.cpp b/shaping/test/gtest_shaper.cpp index b129c25..d72a410 100644 --- a/shaping/test/gtest_shaper.cpp +++ b/shaping/test/gtest_shaper.cpp @@ -1655,6 +1655,62 @@ TEST(two_sessions, priority_block_borrow) /*session1 match rule1 rule1: + profile_a + rule2: + profile_a + + profile_a(id 0): limit 1000 +*/ +TEST(single_session, dup_primary_profile)//dup primary profile, just process the first rule and ignore others +{ + struct stub_pkt_queue expec_tx_queue; + struct stub_pkt_queue *actual_tx_queue; + struct shaping_ctx *ctx = NULL; + struct shaping_flow *sf = NULL; + long long rule_ids[] = {1, 2}; + int profile_nums[] = {1, 1}; + int prioritys[] = {1, 2}; + int profile_id[][MAX_REF_PROFILE] = {{0}, {0}}; + + + TAILQ_INIT(&expec_tx_queue); + stub_init(); + + ctx = shaping_engine_init(); + ASSERT_TRUE(ctx != NULL); + sf = shaping_flow_new(&ctx->thread_ctx[0]); + ASSERT_TRUE(sf != NULL); + + stub_set_matched_shaping_rules(2, rule_ids, prioritys, profile_nums, profile_id); + + stub_set_token_bucket_avl_per_sec(0, 1000, SHAPING_DIR_OUT); + actual_tx_queue = stub_get_tx_queue(); + shaper_rules_update(&ctx->thread_ctx[0], sf, rule_ids, 2); + + /*******send packets***********/ + send_packets(&ctx->thread_ctx[0], sf, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue, 2, 0); + ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10)); + ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue)); + + while (!TAILQ_EMPTY(&expec_tx_queue)) {//last 90 packets + stub_refresh_token_bucket(0); + for (int i = 0; i < 20; i++) { + 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, actual_tx_queue, 10)); + ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue)); + } + + shaping_flow_free(&ctx->thread_ctx[0], sf); + fieldstat_global_disable_prometheus_endpoint(); + shaper_thread_resource_clear(); + shaping_engine_destroy(ctx); + stub_clear_matched_shaping_rules(); +} + +/*session1 match rule1 + rule1: profile: limit 1000*/ TEST(statistics, udp_drop_pkt) { @@ -1821,6 +1877,6 @@ TEST(statistics, udp_queueing_pkt) int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); - //testing::GTEST_FLAG(filter) = "two_sessions.priority_block_borrow"; + //testing::GTEST_FLAG(filter) = "single_session.dup_primary_profile"; return RUN_ALL_TESTS(); }
\ No newline at end of file |
