You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2022/12/30 07:07:37 UTC

[apisix] branch master updated: fix: use absolute path as pubsub search path (#8562)

This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 21b50e519 fix: use absolute path as pubsub search path (#8562)
21b50e519 is described below

commit 21b50e51976297dc48df5911aa94f8285dd40987
Author: leslie <le...@apache.org>
AuthorDate: Fri Dec 30 15:07:31 2022 +0800

    fix: use absolute path as pubsub search path (#8562)
---
 apisix/core/pubsub.lua |  3 ++-
 t/pubsub/kafka.t       | 13 +++++++++++++
 t/pubsub/pubsub.t      | 13 +++++++++++++
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/apisix/core/pubsub.lua b/apisix/core/pubsub.lua
index 98db52cca..818cb8df0 100644
--- a/apisix/core/pubsub.lua
+++ b/apisix/core/pubsub.lua
@@ -23,6 +23,7 @@ local log          = require("apisix.core.log")
 local ws_server    = require("resty.websocket.server")
 local protoc       = require("protoc")
 local pb           = require("pb")
+local ngx          = ngx
 local setmetatable = setmetatable
 local pcall        = pcall
 local pairs        = pairs
@@ -42,7 +43,7 @@ local function init_pb_state()
     -- initialize protoc compiler
     protoc.reload()
     local pubsub_protoc = protoc.new()
-    pubsub_protoc:addpath("apisix/include/apisix/model")
+    pubsub_protoc:addpath(ngx.config.prefix() .. "apisix/include/apisix/model")
     local ok, err = pcall(pubsub_protoc.loadfile, pubsub_protoc, "pubsub.proto")
     if not ok then
         pubsub_protoc:reset()
diff --git a/t/pubsub/kafka.t b/t/pubsub/kafka.t
index fb480c890..b61af6f0c 100644
--- a/t/pubsub/kafka.t
+++ b/t/pubsub/kafka.t
@@ -14,20 +14,33 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+use Cwd qw(cwd);
 use t::APISIX 'no_plan';
 
 repeat_each(1);
 no_long_string();
 no_root_location();
 
+my $apisix_home = $ENV{APISIX_HOME} // cwd();
+
 add_block_preprocessor(sub {
     my ($block) = @_;
 
+    my $block_init = <<_EOC_;
+    `ln -sf $apisix_home/apisix $apisix_home/t/servroot/apisix`;
+_EOC_
+
+    $block->set_value("init", $block_init);
+
     if (!defined $block->request) {
         $block->set_value("request", "GET /t");
     }
 });
 
+add_test_cleanup_handler(sub {
+    `rm -f $apisix_home/t/servroot/apisix`;
+});
+
 run_tests();
 
 __DATA__
diff --git a/t/pubsub/pubsub.t b/t/pubsub/pubsub.t
index 2c6efed33..3e0dbaefb 100644
--- a/t/pubsub/pubsub.t
+++ b/t/pubsub/pubsub.t
@@ -14,20 +14,33 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+use Cwd qw(cwd);
 use t::APISIX 'no_plan';
 
 repeat_each(1);
 no_long_string();
 no_root_location();
 
+my $apisix_home = $ENV{APISIX_HOME} // cwd();
+
 add_block_preprocessor(sub {
     my ($block) = @_;
 
+    my $block_init = <<_EOC_;
+    `ln -sf $apisix_home/apisix $apisix_home/t/servroot/apisix`;
+_EOC_
+
+    $block->set_value("init", $block_init);
+
     if (!defined $block->request) {
         $block->set_value("request", "GET /t");
     }
 });
 
+add_test_cleanup_handler(sub {
+    `rm -f $apisix_home/t/servroot/apisix`;
+});
+
 run_tests();
 
 __DATA__