Skip to content

fix: support extra_lua_path in test framework#13476

Open
mikyll wants to merge 3 commits into
apache:masterfrom
mikyll:fix_issue_12389
Open

fix: support extra_lua_path in test framework#13476
mikyll wants to merge 3 commits into
apache:masterfrom
mikyll:fix_issue_12389

Conversation

@mikyll
Copy link
Copy Markdown
Contributor

@mikyll mikyll commented Jun 4, 2026

This PR was "forked" from #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):

    --- extra_lua_path: /custom/path/?.lua
    --- extra_lua_cpath: /custom/path/?.so
    
  2. Automatic parsing from config.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 1: Test title
Test description
--- extra_lua_path: /path/to/my-custom-plugin/?.lua
--- config
[...]

Which issue(s) this PR fixes:

Fixes #12389

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list 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.

mikyll and others added 3 commits June 4, 2026 14:57
Co-authored-by: inkyu <87048860+grapestore@users.noreply.github.com>
Co-authored-by: inkyu <87048860+grapestore@users.noreply.github.com>
Co-authored-by: inkyu <87048860+grapestore@users.noreply.github.com>
@mikyll mikyll changed the title Fix issue 12389 fix: support extra_lua_path in test framework Jun 4, 2026
@mikyll mikyll marked this pull request as ready for review June 4, 2026 13:30
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: cannot set apisix.extra_lua_path in tests via yaml_config or extra_yaml_config

1 participant