From 5e6abc20637c269128339ff1a9e5b18cdf2375a8 Mon Sep 17 00:00:00 2001 From: MasterKenway Date: Tue, 7 Sep 2021 17:18:19 +0800 Subject: [PATCH] fix: integrate test --- igt/Makefile | 1 + pkg/filter/http/grpcproxy/grpc.go | 15 ++++++++++++++- samples/http/grpc/pixiu/conf.yaml | 4 ++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/igt/Makefile b/igt/Makefile index b6f9534bd..bb64db99a 100644 --- a/igt/Makefile +++ b/igt/Makefile @@ -91,6 +91,7 @@ config: $(info > Setting up config files) @mkdir -p $(OUT_DIR)/server @mkdir -p $(OUT_DIR)/pixiuconf + @mkdir -p $(OUT_DIR)/proto @-test -f $(PROJECT_DIR)/server/profiles/dev/log.yml && cat $(PROJECT_DIR)/server/profiles/dev/log.yml | sed "s#\$$HOST_IP#$(DOCKER_HOST_IP)#g" > $(OUT_DIR)/server/log.yml && echo " > $(OUT_DIR)/conf/log.yml" @-test -f $(PROJECT_DIR)/server/profiles/dev/server.yml && cat $(PROJECT_DIR)/server/profiles/dev/server.yml | sed "s#\$$HOST_IP#$(DOCKER_HOST_IP)#g" > $(OUT_DIR)/server/server.yml && echo " > $(OUT_DIR)/conf/server.yml" @-test -f $(PROJECT_DIR)/pixiu/api_config.yaml && cat $(PROJECT_DIR)/pixiu/api_config.yaml | sed "s#\$$HOST_IP#$(DOCKER_HOST_IP)#g" > $(OUT_DIR)/pixiuconf/api_config.yaml && echo " > $(OUT_DIR)/pixiuconf/api_config.yaml" diff --git a/pkg/filter/http/grpcproxy/grpc.go b/pkg/filter/http/grpcproxy/grpc.go index 58e76fcfb..7f33a8c2c 100644 --- a/pkg/filter/http/grpcproxy/grpc.go +++ b/pkg/filter/http/grpcproxy/grpc.go @@ -23,6 +23,8 @@ import ( "io" "io/ioutil" stdHttp "net/http" + "os" + "path/filepath" "strings" "sync" ) @@ -324,8 +326,19 @@ func (f *Filter) Config() interface{} { func (f *Filter) Apply() error { gc := f.cfg + + cur := gc.Path + if len(cur) != 0 && cur[0] != '/' { + ex, err := os.Executable() + if err != nil { + return err + } + cur = filepath.Dir(ex) + "/" + gc.Path + } + + logger.Infof("%s load proto files from %s", loggerHeader, cur) fileLists := make([]string, 0) - items, err := ioutil.ReadDir(gc.Path) + items, err := ioutil.ReadDir(cur) if err != nil { return err } diff --git a/samples/http/grpc/pixiu/conf.yaml b/samples/http/grpc/pixiu/conf.yaml index 19e3ec9bf..c69b99b07 100644 --- a/samples/http/grpc/pixiu/conf.yaml +++ b/samples/http/grpc/pixiu/conf.yaml @@ -43,10 +43,10 @@ static_resources: http_filters: - name: dgp.filter.http.apiconfig config: - path: /mnt/d/WorkSpace/GoLandProjects/dubbo-go-pixiu/samples/http/grpc/pixiu/api_config.yaml + path: $PROJECT_DIR/pixiu/api_config.yaml - name: dgp.filter.http.grpcproxy config: - path: /mnt/d/WorkSpace/GoLandProjects/dubbo-go-pixiu/samples/http/grpc/proto + path: $PROJECT_DIR/proto - name: dgp.filter.http.response config: server_name: "test-http-grpc"