From 8371049b002dc6302a5b1eb2b1fd6f252f10992f Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Wed, 29 May 2024 18:17:56 +0200 Subject: [PATCH 1/7] fix tests: add expectations for tracing headers --- tests/rate_limited.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/rate_limited.rs b/tests/rate_limited.rs index 7376598b..53c7675e 100644 --- a/tests/rate_limited.rs +++ b/tests/rate_limited.rs @@ -57,6 +57,12 @@ fn it_loads() { module .call_proxy_on_request_headers(http_context, 0, false) .expect_log(Some(LogLevel::Info), Some("on_http_request_headers #2")) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("traceparent")) + .returning(None) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("tracestate")) + .returning(None) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("baggage")) + .returning(None) .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some(":authority")) .returning(Some("cars.toystore.com")) .expect_log( @@ -155,6 +161,12 @@ fn it_limits() { module .call_proxy_on_request_headers(http_context, 0, false) .expect_log(Some(LogLevel::Info), Some("on_http_request_headers #2")) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("traceparent")) + .returning(None) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("tracestate")) + .returning(None) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("baggage")) + .returning(None) .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some(":authority")) .returning(Some("cars.toystore.com")) .expect_get_property(Some(vec!["request", "url_path"])) @@ -283,6 +295,12 @@ fn it_passes_additional_headers() { module .call_proxy_on_request_headers(http_context, 0, false) .expect_log(Some(LogLevel::Info), Some("on_http_request_headers #2")) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("traceparent")) + .returning(None) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("tracestate")) + .returning(None) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("baggage")) + .returning(None) .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some(":authority")) .returning(Some("cars.toystore.com")) .expect_get_property(Some(vec!["request", "url_path"])) @@ -405,6 +423,12 @@ fn it_rate_limits_with_empty_conditions() { module .call_proxy_on_request_headers(http_context, 0, false) .expect_log(Some(LogLevel::Info), Some("on_http_request_headers #2")) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("traceparent")) + .returning(None) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("tracestate")) + .returning(None) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("baggage")) + .returning(None) .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some(":authority")) .returning(Some("a.com")) .expect_grpc_call( @@ -506,6 +530,12 @@ fn it_does_not_rate_limits_when_selector_does_not_exist_and_misses_default_value module .call_proxy_on_request_headers(http_context, 0, false) .expect_log(Some(LogLevel::Info), Some("on_http_request_headers #2")) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("traceparent")) + .returning(None) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("tracestate")) + .returning(None) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("baggage")) + .returning(None) .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some(":authority")) .returning(Some("a.com")) .expect_get_property(Some(vec!["unknown", "path"])) From 4e5fe4c66e488b8cfe87864cdb8c8b78e1de4fb4 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Wed, 29 May 2024 18:21:37 +0200 Subject: [PATCH 2/7] GH actions: test workflow --- .github/workflows/tests.yaml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/tests.yaml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 00000000..3d447890 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,33 @@ +--- +name: Tests + +on: + push: + branches: + - '*' + pull_request: + branches: + - '*' + +jobs: + test: + name: Test Suite + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + target: wasm32-unknown-unknown + - uses: arduino/setup-protoc@v1 + with: + version: '3.x' + - uses: actions-rs/cargo@v1 + with: + command: build + args: --release --target wasm32-unknown-unknown + - uses: actions-rs/cargo@v1 + with: + command: test From 2285018697cf748aa44f7407c4e8ab428f757d71 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Wed, 29 May 2024 18:30:51 +0200 Subject: [PATCH 3/7] GH actions: move tests to it's own workflow --- .github/workflows/rust.yaml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index 065ac37a..97a449fe 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -30,27 +30,6 @@ jobs: with: command: check args: --release --target wasm32-unknown-unknown - test: - name: Test Suite - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - target: wasm32-unknown-unknown - - uses: arduino/setup-protoc@v1 - with: - version: '3.x' - - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --target wasm32-unknown-unknown - - uses: actions-rs/cargo@v1 - with: - command: test fmt: name: Rustfmt runs-on: ubuntu-latest From 95739d87b706a5cfce60562296faebfef4fd63ef Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Wed, 5 Jun 2024 17:53:36 +0200 Subject: [PATCH 4/7] bring latest fix from proxy-wasm-test-framework --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 1ff0afd9..a5ab73cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1088,7 +1088,7 @@ dependencies = [ [[package]] name = "proxy-wasm-test-framework" version = "0.1.0" -source = "git+https://github.com/Kuadrant/wasm-test-framework.git?branch=kuadrant#29d5ac35bb0c11c642e5fae3ca3f33d409505112" +source = "git+https://github.com/Kuadrant/wasm-test-framework.git?branch=kuadrant#63433eae9ef47f6297a30dc6bfe9f8fe6493a8e7" dependencies = [ "anyhow", "lazy_static", From 53ec46ce379bf48c38015810fb981abe5254ed90 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Mon, 3 Jun 2024 10:56:13 +0200 Subject: [PATCH 5/7] fix clippy --- src/filter/http_context.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/filter/http_context.rs b/src/filter/http_context.rs index ebb27f1a..62259b67 100644 --- a/src/filter/http_context.rs +++ b/src/filter/http_context.rs @@ -237,11 +237,11 @@ impl HttpContext for Filter { info!("on_http_request_headers #{}", self.context_id); for header in TracingHeader::all() { - match self.get_http_request_header_bytes(header.as_str()) { - Some(value) => self.tracing_headers.push((header, value)), - None => (), + if let Some(value) = self.get_http_request_header_bytes(header.as_str()) { + self.tracing_headers.push((header, value)) } } + match self .config .index From db05abb56a79e58870c1c44eddf07078f5facfdf Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Thu, 6 Jun 2024 11:50:56 +0200 Subject: [PATCH 6/7] Update .github/workflows/tests.yaml Co-authored-by: dd di cesare <4183971+didierofrivia@users.noreply.github.com> --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3d447890..81cfa566 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -4,7 +4,7 @@ name: Tests on: push: branches: - - '*' + - 'main' pull_request: branches: - '*' From d88ccde3e9a556399298691db00086e2abe578ac Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Thu, 6 Jun 2024 11:54:35 +0200 Subject: [PATCH 7/7] Update .github/workflows/rust.yaml --- .github/workflows/rust.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index 97a449fe..3569ca05 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -4,7 +4,7 @@ name: Rust on: push: branches: - - '*' + - 'main' pull_request: branches: - '*'