You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by me...@apache.org on 2020/03/14 07:41:08 UTC

[incubator-apisix] branch master updated: bugfix: 'required' should same level as `properties`, added test case. (#1261)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 8e8ec23  bugfix: 'required' should same level as `properties`, added test case. (#1261)
8e8ec23 is described below

commit 8e8ec23539a7f36ad4d7630adee31525d68e93c4
Author: YuanSheng Wang <me...@gmail.com>
AuthorDate: Sat Mar 14 15:41:02 2020 +0800

    bugfix: 'required' should same level as `properties`, added test case. (#1261)
    
    * travis: use golang binary file directly.
---
 .travis/linux_openresty_runner.sh     | 19 ++++++-------------
 .travis/linux_tengine_runner.sh       | 12 ++++--------
 lua/apisix/plugins/grpc-transcode.lua | 33 +++++++++++++++------------------
 t/plugin/grpc-transcode.t             | 34 ++++++++++++++++++++++++++++++++++
 4 files changed, 59 insertions(+), 39 deletions(-)

diff --git a/.travis/linux_openresty_runner.sh b/.travis/linux_openresty_runner.sh
index 201e36d..502d61e 100755
--- a/.travis/linux_openresty_runner.sh
+++ b/.travis/linux_openresty_runner.sh
@@ -72,16 +72,12 @@ do_install() {
 
     ls -l ./
     if [ ! -f "build-cache/grpc_server_example" ]; then
-        sudo apt-get install golang
-        git clone https://github.com/iresty/grpc_server_example.git grpc_server_example
-        cd grpc_server_example/
-        go build -o grpc_server_example main.go
-        mv grpc_server_example ../build-cache/
-        cd ..
+        wget https://github.com/iresty/grpc_server_example/releases/download/20200314/grpc_server_example-amd64.tar.gz
+        tar -xvf grpc_server_example-amd64.tar.gz
+        mv grpc_server_example build-cache/
     fi
 
     if [ ! -f "build-cache/proto/helloworld.proto" ]; then
-
         if [ ! -f "grpc_server_example/main.go" ]; then
             git clone https://github.com/iresty/grpc_server_example.git grpc_server_example
         fi
@@ -92,12 +88,9 @@ do_install() {
     fi
 
     if [ ! -f "build-cache/grpcurl" ]; then
-        sudo apt-get install golang
-        git clone https://github.com/fullstorydev/grpcurl.git grpcurl
-        cd grpcurl
-        go build -o grpcurl  ./cmd/grpcurl
-        mv grpcurl ../build-cache/
-        cd ..
+        wget https://github.com/api7/grpcurl/releases/download/20200314/grpcurl-amd64.tar.gz
+        tar -xvf grpcurl-amd64.tar.gz
+        mv grpcurl build-cache/
     fi
 }
 
diff --git a/.travis/linux_tengine_runner.sh b/.travis/linux_tengine_runner.sh
index ea0552f..3a35c5c 100755
--- a/.travis/linux_tengine_runner.sh
+++ b/.travis/linux_tengine_runner.sh
@@ -223,15 +223,11 @@ do_install() {
     cp .travis/ASF* .travis/openwhisk-utilities/scancode/
 
     ls -l ./
-    if [ ! -f "build-cache/grpc_server_example" ]; then
-        sudo apt-get install golang
-
-        git clone https://github.com/iresty/grpc_server_example.git grpc_server_example
 
-        cd grpc_server_example/
-        go build -o grpc_server_example main.go
-        mv grpc_server_example ../build-cache/
-        cd ..
+    if [ ! -f "build-cache/grpc_server_example" ]; then
+        wget https://github.com/iresty/grpc_server_example/releases/download/20200314/grpc_server_example-amd64.tar.gz
+        tar -xvf grpc_server_example-amd64.tar.gz
+        mv grpc_server_example build-cache/
     fi
 }
 
diff --git a/lua/apisix/plugins/grpc-transcode.lua b/lua/apisix/plugins/grpc-transcode.lua
index 21c8f42..daf4856 100644
--- a/lua/apisix/plugins/grpc-transcode.lua
+++ b/lua/apisix/plugins/grpc-transcode.lua
@@ -17,35 +17,30 @@
 local ngx         = ngx
 local core        = require("apisix.core")
 local schema_def  = require("apisix.schema_def")
-local plugin_name = "grpc-transcode"
 local proto       = require("apisix.plugins.grpc-transcode.proto")
 local request     = require("apisix.plugins.grpc-transcode.request")
 local response    = require("apisix.plugins.grpc-transcode.response")
 
 
+local plugin_name = "grpc-transcode"
+
 local pb_option_def = {
     {   description = "enum as result",
         type = "string",
-        enum = {"int64_as_number",
-              "int64_as_string",
-              "int64_as_hexstring"},
+        enum = {"int64_as_number", "int64_as_string", "int64_as_hexstring"},
     },
     {   description = "int64 as result",
         type = "string",
-        enum = {"ienum_as_name",
-                "enum_as_value"},
+        enum = {"ienum_as_name", "enum_as_value"},
     },
     {   description ="default values option",
         type = "string",
-        enum = {"auto_default_values",
-                "no_default_values",
-                "use_default_values",
-                "use_default_metatable"},
+        enum = {"auto_default_values", "no_default_values",
+                "use_default_values", "use_default_metatable"},
     },
     {   description = "hooks option",
         type = "string",
-        enum = {"enable_hooks",
-                "disable_hooks" },
+        enum = {"enable_hooks", "disable_hooks" },
     },
 }
 
@@ -66,12 +61,14 @@ local schema = {
             type        = "number",
             default     = 0
         },
-        pb_option = { type = "array",
-                      items = { type="string", anyOf = pb_option_def },
-                      minItems = 1,
-                    },
-    requried = { "proto_id", "service", "method" },
-    additionalProperties = true }
+        pb_option = {
+            type = "array",
+            items = { type="string", anyOf = pb_option_def },
+            minItems = 1,
+        },
+        additionalProperties = true,
+    },
+    required = { "proto_id", "service", "method" },
 }
 
 local status_rel = {
diff --git a/t/plugin/grpc-transcode.t b/t/plugin/grpc-transcode.t
index 807305c..92a760c 100644
--- a/t/plugin/grpc-transcode.t
+++ b/t/plugin/grpc-transcode.t
@@ -427,3 +427,37 @@ passed
 --- request
 GET /grpc_delay?name=apisix
 --- error_code: 504
+
+
+
+=== TEST 15: set routes: missing method
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "uri": "/grpctest",
+                    "plugins": {
+                        "grpc-transcode": {
+                            "proto_id": "1",
+                            "service": "helloworld.Greeter"
+                        }
+                    }
+                }]]
+            )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.print(body)
+        }
+    }
+--- request
+GET /t
+--- error_code: 400
+--- response_body
+{"error_msg":"failed to check the configuration of plugin grpc-transcode err: property \"method\" is required"}
+--- no_error_log
+[error]