Skip to content

Conversation

@grapestore
Copy link

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.

Previously, while APISIX runtime supported apisix.extra_lua_path in config.yaml to 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:

  • 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

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.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Nov 19, 2025
Copy link
Contributor

@Baoyuantop Baoyuantop left a 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

@Baoyuantop
Copy link
Contributor

Hi @grapestore, you can merge the latest main branch to make CI pass.

inkyu.bae added 4 commits November 20, 2025 19:17
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
@grapestore grapestore force-pushed the fix/extra-lua-path-in-tests branch from 2b64c82 to 9c80b2c Compare November 20, 2025 10:17
@grapestore
Copy link
Author

I’ve updated my branch to follow the latest master branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

2 participants