mikyll opened a new pull request, #13476: URL: https://github.com/apache/apisix/pull/13476
This PR was "forked" from https://github.com/apache/apisix/pull/12759 due to inactivity 👀 ### Description This PR adds support for setting custom Lua paths (`extra_lua_path` and `extra_lua_cpath`) in test files, aligning the test framework behavior with APISIX runtime configuration. #### What Problem Solves Currently, you are not able to pass an extra Lua path to load custom plugins in APISIX testing framework. That makes it impossible to test custom plugins, without editing `APISIX.pm` or via other workarounds. Suppose we have a CI/CD pipeline to release our APISIX instance: - APISIX container with test-nginx framework - CI step to test custom plugins - mount custom plugins volume into the container - run tests Currently, the test framework overwrites the value of `extra_lua_path` of APISIX configuration. As a consequence, APISIX does never pick up the path of your custom plugins and cannot load them, making the tests fail. This change extends the test framework preprocessor in `t/APISIX.pm` to extract and prepend custom Lua paths from **block definitions** or **YAML configuration**. Two methods: 1. Block definitions (preferred): ```test --- extra_lua_path: /custom/path/?.lua --- extra_lua_cpath: /custom/path/?.so ``` 2. Automatic parsing from config.yaml: ```yaml apisix: extra_lua_path: "/custom/path/?.lua" extra_lua_cpath: "/custom/path/?.so" ``` ##### Implementation - Prepends custom paths to `lua_package_path` and `lua_package_cpath` (matching runtime behavior) - Block definitions take precedence when both methods are used - Enables testing custom plugins without modifying core APISIX paths ##### Example File `t/plugin/my-custom-plugin.t`: ```test === TEST 1: Test title Test description --- extra_lua_path: /path/to/my-custom-plugin/?.lua --- config [...] ``` #### Which issue(s) this PR fixes: Fixes #12389 ### Checklist - [x] I have explained the need for this PR and the problem it solves - [x] I have explained the changes or the new features added to this PR - [x] I have added tests corresponding to this change - [x] I have updated the documentation to reflect this change - [x] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first) **Test Coverage:** Added comprehensive test suite in `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 configuration methods **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 existing `extra_yaml_config`. All existing tests continue to work without modification. <!-- Note 1. Mark the PR as draft until it's ready to be reviewed. 2. Always add/update tests for any changes unless you have a good reason. 3. Always update the documentation to reflect the changes made in the PR. 4. Make a new commit to resolve conversations instead of `push -f`. 5. To resolve merge conflicts, merge master instead of rebasing. 6. Use "request review" to notify the reviewer after making changes. 7. Only a reviewer can mark a conversation as resolved. --> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
