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/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 319c3eb  test: make ci stable (#3329)
319c3eb is described below

commit 319c3ebefd22cd2949b84d97d196fd2a80630d38
Author: 罗泽轩 <spacewander...@gmail.com>
AuthorDate: Wed Jan 20 01:58:44 2021 -0600

    test: make ci stable (#3329)
---
 apisix/http/service.lua   |  2 +-
 apisix/router.lua         |  2 +-
 apisix/upstream.lua       |  2 +-
 t/admin/plugin-metadata.t | 16 +++++++++++++++-
 t/admin/upstream.t        | 29 ++++++++++++++--------------
 t/admin/upstream2.t       | 16 ++++++++--------
 t/node/upstream.t         | 49 +++++++----------------------------------------
 7 files changed, 48 insertions(+), 68 deletions(-)

diff --git a/apisix/http/service.lua b/apisix/http/service.lua
index 2872ef0..0e36f9a 100644
--- a/apisix/http/service.lua
+++ b/apisix/http/service.lua
@@ -85,7 +85,7 @@ local function filter(service)
         service.value.upstream.nodes = new_nodes
     end
 
-    core.log.info("filter service: ", core.json.delay_encode(service))
+    core.log.info("filter service: ", core.json.delay_encode(service, true))
 end
 
 
diff --git a/apisix/router.lua b/apisix/router.lua
index 1012a15..51f03bd 100644
--- a/apisix/router.lua
+++ b/apisix/router.lua
@@ -70,7 +70,7 @@ local function filter(route)
         route.value.upstream.nodes = new_nodes
     end
 
-    core.log.info("filter route: ", core.json.delay_encode(route))
+    core.log.info("filter route: ", core.json.delay_encode(route, true))
 end
 
 
diff --git a/apisix/upstream.lua b/apisix/upstream.lua
index da19e45..c0c0889 100644
--- a/apisix/upstream.lua
+++ b/apisix/upstream.lua
@@ -237,7 +237,7 @@ function _M.init_worker()
                     upstream.value.nodes = new_nodes
                 end
 
-                core.log.info("filter upstream: ", 
core.json.delay_encode(upstream))
+                core.log.info("filter upstream: ", 
core.json.delay_encode(upstream, true))
             end,
         })
     if not upstreams then
diff --git a/t/admin/plugin-metadata.t b/t/admin/plugin-metadata.t
index e157971..df3dd24 100644
--- a/t/admin/plugin-metadata.t
+++ b/t/admin/plugin-metadata.t
@@ -330,8 +330,22 @@ passed
 
 
 === TEST 10: hit prometheus route
+--- config
+    location /t {
+        content_by_lua_block {
+            ngx.sleep(1) -- wait for data synced
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/prometheus/metrics',
+                ngx.HTTP_GET)
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
 --- request
-GET /apisix/prometheus/metrics
+GET /t
 --- error_code: 403
 
 
diff --git a/t/admin/upstream.t b/t/admin/upstream.t
index 453a301..15485af 100644
--- a/t/admin/upstream.t
+++ b/t/admin/upstream.t
@@ -26,13 +26,14 @@ run_tests;
 
 __DATA__
 
-=== TEST 1: set upstream(id: 1)
+=== TEST 1: set upstream (use an id can't be referred by other route
+so that we can delete it later)
 --- config
     location /t {
         content_by_lua_block {
             local t = require("lib.test_admin").test
             local etcd = require("apisix.core.etcd")
-            local code, body = t('/apisix/admin/upstreams/1',
+            local code, body = t('/apisix/admin/upstreams/admin_up',
                 ngx.HTTP_PUT,
                 [[{
                     "nodes": {
@@ -50,7 +51,7 @@ __DATA__
                             "type": "roundrobin",
                             "desc": "new upstream"
                         },
-                        "key": "/apisix/upstreams/1"
+                        "key": "/apisix/upstreams/admin_up"
                     },
                     "action": "set"
                 }]]
@@ -59,7 +60,7 @@ __DATA__
             ngx.status = code
             ngx.say(body)
 
-            local res = assert(etcd.get('/upstreams/1'))
+            local res = assert(etcd.get('/upstreams/admin_up'))
             local create_time = res.body.node.value.create_time
             assert(create_time ~= nil, "create_time is nil")
             local update_time = res.body.node.value.update_time
@@ -75,12 +76,12 @@ passed
 
 
 
-=== TEST 2: get upstream(id: 1)
+=== TEST 2: get upstream
 --- config
     location /t {
         content_by_lua_block {
             local t = require("lib.test_admin").test
-            local code, body = t('/apisix/admin/upstreams/1',
+            local code, body = t('/apisix/admin/upstreams/admin_up',
                  ngx.HTTP_GET,
                  nil,
                 [[{
@@ -92,7 +93,7 @@ passed
                             "type": "roundrobin",
                             "desc": "new upstream"
                         },
-                        "key": "/apisix/upstreams/1"
+                        "key": "/apisix/upstreams/admin_up"
                     },
                     "action": "get"
                 }]]
@@ -111,12 +112,12 @@ passed
 
 
 
-=== TEST 3: delete upstream(id: 1)
+=== TEST 3: delete upstream
 --- config
     location /t {
         content_by_lua_block {
             local t = require("lib.test_admin").test
-            local code, message = t('/apisix/admin/upstreams/1',
+            local code, message = t('/apisix/admin/upstreams/admin_up',
                  ngx.HTTP_DELETE,
                  nil,
                  [[{
@@ -1911,12 +1912,12 @@ passed
 
 
 
-=== TEST 55: create upstream with create_time and update_time(id: 1)
+=== TEST 55: create upstream with create_time and update_time
 --- config
     location /t {
         content_by_lua_block {
             local t = require("lib.test_admin").test
-            local code, body = t('/apisix/admin/upstreams/1',
+            local code, body = 
t('/apisix/admin/upstreams/up_create_update_time',
                 ngx.HTTP_PUT,
                 [[{
                     "nodes": {
@@ -1936,7 +1937,7 @@ passed
                             "create_time": 1602883670,
                             "update_time": 1602893670
                         },
-                        "key": "/apisix/upstreams/1"
+                        "key": "/apisix/upstreams/up_create_update_time"
                     },
                     "action": "set"
                 }]]
@@ -1955,12 +1956,12 @@ passed
 
 
 
-=== TEST 56: delete test upstream(id: 1)
+=== TEST 56: delete test upstream
 --- config
     location /t {
         content_by_lua_block {
             local t = require("lib.test_admin").test
-            local code, message = t('/apisix/admin/upstreams/1',
+            local code, message = 
t('/apisix/admin/upstreams/up_create_update_time',
                  ngx.HTTP_DELETE,
                  nil,
                  [[{
diff --git a/t/admin/upstream2.t b/t/admin/upstream2.t
index b753383..f4e9366 100644
--- a/t/admin/upstream2.t
+++ b/t/admin/upstream2.t
@@ -78,7 +78,7 @@ __DATA__
         content_by_lua_block {
             local json = require("toolkit.json")
             local t = require("lib.test_admin").test
-            local code, message, res = t('/apisix/admin/upstreams/1',
+            local code, message, res = t('/apisix/admin/upstreams/unwanted',
                  ngx.HTTP_PUT,
                  [[{
                     "nodes": {
@@ -101,7 +101,7 @@ __DATA__
         }
     }
 --- response_body
-{"action":"set","node":{"key":"/apisix/upstreams/1","value":{"hash_on":"vars","id":"1","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","type":"roundrobin"}}}
+{"action":"set","node":{"key":"/apisix/upstreams/unwanted","value":{"hash_on":"vars","id":"unwanted","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","type":"roundrobin"}}}
 
 
 
@@ -111,7 +111,7 @@ __DATA__
         content_by_lua_block {
             local json = require("toolkit.json")
             local t = require("lib.test_admin").test
-            local code, message, res = t('/apisix/admin/upstreams/1',
+            local code, message, res = t('/apisix/admin/upstreams/unwanted',
                  ngx.HTTP_PATCH,
                  [[{
                     "nodes": {
@@ -134,7 +134,7 @@ __DATA__
         }
     }
 --- response_body
-{"action":"compareAndSwap","node":{"key":"/apisix/upstreams/1","value":{"hash_on":"vars","id":"1","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","type":"roundrobin"}}}
+{"action":"compareAndSwap","node":{"key":"/apisix/upstreams/unwanted","value":{"hash_on":"vars","id":"unwanted","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","type":"roundrobin"}}}
 
 
 
@@ -144,7 +144,7 @@ __DATA__
         content_by_lua_block {
             local json = require("toolkit.json")
             local t = require("lib.test_admin").test
-            local code, message, res = t('/apisix/admin/upstreams/1',
+            local code, message, res = t('/apisix/admin/upstreams/unwanted',
                  ngx.HTTP_GET
                 )
 
@@ -161,7 +161,7 @@ __DATA__
         }
     }
 --- response_body
-{"action":"get","count":"1","node":{"key":"/apisix/upstreams/1","value":{"hash_on":"vars","id":"1","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","type":"roundrobin"}}}
+{"action":"get","count":"1","node":{"key":"/apisix/upstreams/unwanted","value":{"hash_on":"vars","id":"unwanted","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","type":"roundrobin"}}}
 
 
 
@@ -171,7 +171,7 @@ __DATA__
         content_by_lua_block {
             local json = require("toolkit.json")
             local t = require("lib.test_admin").test
-            local code, message, res = t('/apisix/admin/upstreams/1',
+            local code, message, res = t('/apisix/admin/upstreams/unwanted',
                  ngx.HTTP_DELETE
                 )
 
@@ -186,7 +186,7 @@ __DATA__
         }
     }
 --- response_body
-{"action":"delete","deleted":"1","key":"/apisix/upstreams/1","node":{}}
+{"action":"delete","deleted":"1","key":"/apisix/upstreams/unwanted","node":{}}
 
 
 
diff --git a/t/node/upstream.t b/t/node/upstream.t
index 9acbb28..a2886a6 100644
--- a/t/node/upstream.t
+++ b/t/node/upstream.t
@@ -300,7 +300,7 @@ qr/"Host": "httpbin.org"/
 
 
 
-=== TEST 13: set upstream(id: 1, using `rewrite` mode to pass upstream host)
+=== TEST 13: set upstream(using `rewrite` mode to pass upstream host)
 --- config
     location /t {
         content_by_lua_block {
@@ -333,7 +333,7 @@ passed
 
 
 
-=== TEST 14: set route(id: 1, using `rewrite` mode to pass upstream host)
+=== TEST 14: set route(using `rewrite` mode to pass upstream host)
 --- config
     location /t {
         content_by_lua_block {
@@ -371,39 +371,12 @@ qr/host: httpbin.org/
 
 
 
-=== TEST 16: set route(upstream deleted)
---- 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": "/uri",
-                    "upstream_id": "1"
-                }]]
-                )
-
-            if code >= 300 then
-                ngx.status = code
-            end
-            ngx.say(body)
-        }
-    }
---- request
-GET /t
---- response_body
-passed
---- no_error_log
-[error]
-
-
-
-=== TEST 17: delete upstream
+=== TEST 16: delete upstream in used
 --- config
     location /t {
         content_by_lua_block {
             local t = require("lib.test_admin").test
+            ngx.sleep(0.5) -- wait for data synced
             local code, body = t('/apisix/admin/upstreams/1',
                 ngx.HTTP_DELETE
                 )
@@ -411,21 +384,13 @@ passed
             if code >= 300 then
                 ngx.status = code
             end
-            ngx.say(body)
+            ngx.print(body)
         }
     }
 --- request
 GET /t
+--- error_code: 400
 --- response_body
-passed
+{"error_msg":"can not delete this upstream, route [1] is still using it now"}
 --- no_error_log
 [error]
-
-
-
-=== TEST 18: hit route
---- request
-GET /uri
---- error_code: 502
---- error_log
-failed to find upstream by id: 1

Reply via email to