dyrnq commented on PR #8928:
URL: https://github.com/apache/apisix/pull/8928#issuecomment-1445900176

   @Fabriceli 
   I have unit test completed on my pc use flow test case, I have push the 
code. Please help checks.
   
   ```bash
   === TEST 16: prepare nodes with consul health check
   --- config
   location /v1/agent {
       proxy_pass http://127.0.0.1:8500;
   }
   --- request eval
   [
       "PUT /v1/agent/service/deregister/service_a1",
       "PUT /v1/agent/service/deregister/service_a2",
       "PUT /v1/agent/service/deregister/service_b1",
       "PUT /v1/agent/service/deregister/service_b2",
       "PUT /v1/agent/service/register\n" . "{\"Checks\": [{\"http\": 
\"http://baidu.com\",\"interval\": 
\"1s\"}],\"ID\":\"service_a1\",\"Name\":\"service_a\",\"Tags\":[\"primary\",\"v1\"],\"Address\":\"127.0.0.1\",\"Port\":30511,\"Meta\":{\"service_a_version\":\"4.0\"},\"EnableTagOverride\":false,\"Weights\":{\"Passing\":10,\"Warning\":1}}",
       "PUT /v1/agent/service/register\n" . "{\"Checks\": [{\"http\": 
\"http://127.0.0.1:8002\",\"interval\": 
\"1s\"}],\"ID\":\"service_b1\",\"Name\":\"service_b\",\"Tags\":[\"primary\",\"v1\"],\"Address\":\"127.0.0.1\",\"Port\":8002,\"Meta\":{\"service_b_version\":\"4.1\"},\"EnableTagOverride\":false,\"Weights\":{\"Passing\":10,\"Warning\":1}}",
   ]
   --- response_body eval
   --- error_code eval
   [200, 200, 200, 200, 200, 200]
   
   
   === TEST 17: show dump services with consul health check
   --- yaml_config
   apisix:
     node_listen: 1984
     enable_control: true
   discovery:
     consul:
       servers:
         - "http://127.0.0.1:8500";
       dump:
         path: "consul.dump"
         load_on_init: false
   --- config
       location /t {
           content_by_lua_block {
               local json = require("toolkit.json")
               local t = require("lib.test_admin")
               ngx.sleep(2)
   
               local code, body, res = 
t.test('/v1/discovery/consul/show_dump_file',
                   ngx.HTTP_GET)
               local entity = json.decode(res)
               ngx.say(json.encode(entity.services))
           }
       }
   --- timeout: 3
   --- request
   GET /t
   --- response_body
   {"service_a":[{"host":"127.0.0.1","port":30511,"weight":1}]}
   ```
   ```
   prove -v -I. -Itest-nginx/inc -Itest-nginx/lib -r t/discovery/consul_dump2.t
   
   
   t/discovery/consul_dump2.t .. 
   ok 1 - t/discovery/consul_dump2.t TEST 16: prepare nodes with consul health 
check - status code ok
   ok 2 - t/discovery/consul_dump2.t TEST 16: prepare nodes with consul health 
check - pattern "[error]" does not match a line in error.log (req 0)
   ok 3 - t/discovery/consul_dump2.t TEST 16: prepare nodes with consul health 
check - status code ok
   ok 4 - t/discovery/consul_dump2.t TEST 16: prepare nodes with consul health 
check - pattern "[error]" does not match a line in error.log (req 0)
   ok 5 - t/discovery/consul_dump2.t TEST 16: prepare nodes with consul health 
check - status code ok
   ok 6 - t/discovery/consul_dump2.t TEST 16: prepare nodes with consul health 
check - pattern "[error]" does not match a line in error.log (req 0)
   ok 7 - t/discovery/consul_dump2.t TEST 16: prepare nodes with consul health 
check - status code ok
   ok 8 - t/discovery/consul_dump2.t TEST 16: prepare nodes with consul health 
check - pattern "[error]" does not match a line in error.log (req 0)
   ok 9 - t/discovery/consul_dump2.t TEST 16: prepare nodes with consul health 
check - status code ok
   ok 10 - t/discovery/consul_dump2.t TEST 16: prepare nodes with consul health 
check - pattern "[error]" does not match a line in error.log (req 0)
   ok 11 - t/discovery/consul_dump2.t TEST 16: prepare nodes with consul health 
check - status code ok
   ok 12 - t/discovery/consul_dump2.t TEST 16: prepare nodes with consul health 
check - pattern "[error]" does not match a line in error.log (req 0)
   ok 13 - t/discovery/consul_dump2.t TEST 17: show dump services with consul 
health check - status code ok
   ok 14 - t/discovery/consul_dump2.t TEST 17: show dump services with consul 
health check - response_body - response is expected (repeated req 0, req 0)
   ok 15 - t/discovery/consul_dump2.t TEST 17: show dump services with consul 
health check - pattern "[error]" does not match a line in error.log (req 0)
   1..15
   ok
   All tests successful.
   Files=1, Tests=15,  3 wallclock secs ( 0.02 usr  0.00 sys +  0.28 cusr  0.06 
csys =  0.36 CPU)
   Result: PASS
   
   ```
   
   
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to