-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix: support extra_lua_path in test framework #12759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Baoyuantop
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codes LGTM, please fix the failed CI
|
Hi @grapestore, you can merge the latest main branch to make CI pass. |
Add support for setting custom Lua paths in test files through
two complementary methods:
1. Block definitions (preferred):
--- extra_lua_path: /custom/path/?.lua
--- extra_lua_cpath: /custom/path/?.so
2. YAML configuration parsing:
--- extra_yaml_config
apisix:
extra_lua_path: "/custom/path/?.lua"
The implementation prepends custom paths to lua_package_path and
lua_package_cpath, aligning test behavior with APISIX runtime where
extra_lua_path allows loading custom plugins from specified directories.
Block definitions take precedence when both methods are used, ensuring
explicit test configuration overrides YAML settings.
Added comprehensive test suite (t/admin/extra-lua-path.t) covering:
- Path addition via block definitions
- YAML configuration parsing
- Simultaneous lua_path and lua_cpath configuration
- Correct path prepending behavior
- Precedence rules between methods
This enables testing custom plugins in custom directories without
modifying core APISIX paths.
Fixes apache#12389
2b64c82 to
9c80b2c
Compare
|
I’ve updated my branch to follow the latest master branch |
|
Could you please take a look? |
membphis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need a real case to cover this case
Description
This PR adds support for setting custom Lua paths (
extra_lua_pathandextra_lua_cpath) in test files, aligning the test framework behavior with APISIX runtime configuration.Previously, while APISIX runtime supported
apisix.extra_lua_pathinconfig.yamlto load custom plugins from specified directories, the test framework (t/APISIX.pm) did not respect this configuration. This made it impossible to write tests for custom plugins located in custom directories.This PR implements two complementary methods for setting custom Lua paths in tests:
Method 1: Block definitions (preferred)
--- extra_lua_path: /custom/path/?.lua
--- extra_lua_cpath: /custom/path/?.soMethod 2: Automatic parsing from extra_yaml_config
--- extra_yaml_config
apisix:
extra_lua_path: "/custom/path/?.lua"
extra_lua_cpath: "/custom/path/?.so"The implementation:
lua_package_pathandlua_package_cpath(matching runtime behavior)Which issue(s) this PR fixes:
Fixes #12389
Checklist
Test Coverage:
Added comprehensive test suite in
t/admin/extra-lua-path.tcovering:Backward Compatibility:
This change is fully backward compatible. It only adds new optional block definitions (
extra_lua_path,extra_lua_cpath) and parsing logic for existingextra_yaml_config. All existing tests continue to work without modification.