From b7e37c858e06f05f6394bd8ce9b2b402f53eb766 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Tue, 10 Sep 2024 14:42:32 +0200 Subject: [PATCH 1/2] add debug log for get_property call Signed-off-by: Eguzki Astiz Lezaun --- src/policy.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/policy.rs b/src/policy.rs index 7b894c16..8fcd141f 100644 --- a/src/policy.rs +++ b/src/policy.rs @@ -82,6 +82,10 @@ impl Policy { fn pattern_expression_applies(&self, filter: &Filter, p_e: &PatternExpression) -> bool { let attribute_path = p_e.path(); + debug!( + "#{} get_property: selector: {} path: {:?}", + filter.context_id, p_e.selector, attribute_path + ); let attribute_value = match filter.get_property(attribute_path) { None => { debug!( @@ -127,6 +131,10 @@ impl Policy { }; let attribute_path = selector_item.path(); + debug!( + "#{} get_property: selector: {} path: {:?}", + filter.context_id, selector_item.selector, attribute_path + ); let value = match filter.get_property(attribute_path.tokens()) { None => { debug!( From cb43003157d09f667866936d9122113b3f19a721 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Tue, 10 Sep 2024 18:00:03 +0200 Subject: [PATCH 2/2] fix tests due to new logs being added Signed-off-by: Eguzki Astiz Lezaun --- tests/rate_limited.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/rate_limited.rs b/tests/rate_limited.rs index 1578afa7..44bfec3c 100644 --- a/tests/rate_limited.rs +++ b/tests/rate_limited.rs @@ -179,6 +179,18 @@ fn it_limits() { Some(LogLevel::Debug), Some("#2 ratelimitpolicy selected some-name"), ) + .expect_log( + Some(LogLevel::Debug), + Some("#2 get_property: selector: request.url_path path: [\"request\", \"url_path\"]"), + ) + .expect_log( + Some(LogLevel::Debug), + Some("#2 get_property: selector: request.host path: [\"request\", \"host\"]"), + ) + .expect_log( + Some(LogLevel::Debug), + Some("#2 get_property: selector: request.method path: [\"request\", \"method\"]"), + ) .expect_grpc_call( Some("limitador-cluster"), Some("envoy.service.ratelimit.v3.RateLimitService"), @@ -317,6 +329,18 @@ fn it_passes_additional_headers() { Some(LogLevel::Debug), Some("#2 ratelimitpolicy selected some-name"), ) + .expect_log( + Some(LogLevel::Debug), + Some("#2 get_property: selector: request.url_path path: [\"request\", \"url_path\"]"), + ) + .expect_log( + Some(LogLevel::Debug), + Some("#2 get_property: selector: request.host path: [\"request\", \"host\"]"), + ) + .expect_log( + Some(LogLevel::Debug), + Some("#2 get_property: selector: request.method path: [\"request\", \"method\"]"), + ) .expect_grpc_call( Some("limitador-cluster"), Some("envoy.service.ratelimit.v3.RateLimitService"), @@ -556,6 +580,10 @@ fn it_does_not_rate_limits_when_selector_does_not_exist_and_misses_default_value Some(LogLevel::Debug), Some("#2 ratelimitpolicy selected some-name"), ) + .expect_log( + Some(LogLevel::Debug), + Some("#2 get_property: selector: unknown.path path: Path { tokens: [\"unknown\", \"path\"] }"), + ) .expect_log( Some(LogLevel::Debug), Some("#2 build_single_descriptor: selector not found: unknown.path"),