Skip to content

Conversation

@Aias00
Copy link

@Aias00 Aias00 commented Jan 19, 2026

What type of PR is this?
add unit tests for Lua HTTP filter translation within the xDS translator.

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Release Notes: Yes/No

…ranslator.

Signed-off-by: liuhy <liuhongyu@apache.org>
@Aias00 Aias00 requested a review from a team as a code owner January 19, 2026 10:36
Copilot AI review requested due to automatic review settings January 19, 2026 10:36
@netlify
Copy link

netlify bot commented Jan 19, 2026

Deploy Preview for cerulean-figolla-1f9435 canceled.

Name Link
🔨 Latest commit b89fe62
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/696e1195e5cf130007a4e61a

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive unit tests for the Lua HTTP filter translation functionality within the xDS translator. The tests ensure that Lua filters are properly configured and integrated into Envoy's HTTP Connection Manager.

Changes:

  • Added 729 lines of unit tests for Lua filter translation
  • Includes tests for HCM patching, filter building, route patching, and integration scenarios
  • Covers edge cases like nil inputs, empty filters, duplicates, and validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 284 to 296
name: "empty lua code",
lua: ir.Lua{
Name: "empty-lua",
Code: ptr.To(""),
},
wantErr: false,
validate: func(t *testing.T, filter *hcmv3.HttpFilter) {
luaConfig := &luafilterv3.Lua{}
err := filter.GetTypedConfig().UnmarshalTo(luaConfig)
require.NoError(t, err)
assert.Equal(t, "", luaConfig.DefaultSourceCode.GetInlineString())
},
},
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test case "empty lua code" tests a scenario where the Lua code pointer is set to an empty string. However, based on the implementation in buildHCMLuaFilter (line 71 in lua.go), the code dereferences the pointer with *lua.Code without checking if it's nil. This test should also include a case where lua.Code is nil to ensure that buildHCMLuaFilter handles or properly errors on nil Code pointers, which would be a more realistic edge case.

Copilot uses AI. Check for mistakes.
Comment on lines +636 to +644
// Verify the per-route config
filterConfig := route.TypedPerFilterConfig[filterName]
require.NotNil(t, filterConfig)

// The config should be an empty Any (filter is just enabled)
routeFilterConfig := &routev3.FilterConfig{}
err = filterConfig.UnmarshalTo(routeFilterConfig)
require.NoError(t, err)
assert.NotNil(t, routeFilterConfig.Config)
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The integration test doesn't verify the actual behavior when the filter is enabled on a route. The test validates that the filter configuration is added to TypedPerFilterConfig, but doesn't verify that the configuration can be successfully unmarshaled or that it has the expected structure. Consider adding validation that the routev3.FilterConfig can be unmarshaled and contains the expected empty Any config.

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.88%. Comparing base (844be64) to head (b89fe62).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7988      +/-   ##
==========================================
+ Coverage   72.86%   72.88%   +0.02%     
==========================================
  Files         237      237              
  Lines       35536    35536              
==========================================
+ Hits        25894    25902       +8     
+ Misses       7799     7798       -1     
+ Partials     1843     1836       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…ter test assertions.

Signed-off-by: liuhy <liuhongyu@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant