monkeyDluffy6017 commented on issue #8880:
URL: https://github.com/apache/apisix/issues/8880#issuecomment-1437819727

   I test `key-auth` and `traffic-split`,  the two plugins could work together, 
are there any other prlblems?
   ```
   === TEST 1: add consumer with username and plugins
   --- config
       location /t {
           content_by_lua_block {
               local t = require("lib.test_admin").test
               local code, body = t('/apisix/admin/consumers',
                   ngx.HTTP_PUT,
                   [[{
                       "username": "jack",
                       "plugins": {
                           "key-auth": {
                               "key": "auth-one"
                           }
                       }
                   }]]
                   )
   
               if code >= 300 then
                   ngx.status = code
               end
               ngx.say(body)
           }
       }
   --- request
   GET /t
   --- response_body
   passed
   
   
   
   === TEST 2: mock Grayscale Release
   --- config
       location /t {
           content_by_lua_block {
               local t = require("lib.test_admin").test
               local json = require("toolkit.json")
   
               local data = {
                   uri = "/server_port",
                   plugins = {
                       ["key-auth"] = {},
                       ["traffic-split"] = {
                           rules = {{
                               weighted_upstreams = {
                                   {
                                       upstream = {
                                           name = "upstream_A",
                                           type = "roundrobin",
                                           nodes = {["127.0.0.1:1981"] = 1}
                                       },
                                       weight = 2
                                   },
                                   {
                                       weight = 1
                                   }
                               }
                           }}
                       }
                   },
                   upstream = {
                       type = "roundrobin",
                       nodes = {["127.0.0.1:1980"] = 1}
                   }
               }
   
               local code, body = t('/apisix/admin/routes/1',
                   ngx.HTTP_PUT,
                   json.encode(data)
               )
               if code >= 300 then
                   ngx.status = code
               end
               ngx.say(body)
           }
       }
   --- request
   GET /t
   --- response_body
   passed
   
   
   
   === TEST 3: 2/3 request traffic hits the upstream of the plugin, 1/3 request 
traffic hits the upstream of `route`
   --- config
   location /t {
       content_by_lua_block {
           local t = require("lib.test_admin").test
           local bodys = {}
           for i = 1, 6 do
               local _, _, body = t('/server_port', ngx.HTTP_GET, nil, nil, 
{apikey = "auth-one"})
               bodys[i] = body
           end
           table.sort(bodys)
           ngx.say(table.concat(bodys, ", "))
       }
   }
   --- request
   GET /t
   --- response_body
   1980, 1980, 1981, 1981, 1981, 1981
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to