feat: add new lua-resty-events as events implementation#10550
Conversation
f366245 to
7aea90c
Compare
| wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime-debug-centos7.sh" | ||
| wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" | ||
| #wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" | ||
| wget https://raw.githubusercontent.com/Sn0rt/apisix-build-tools/guohao/update-lua-resty-events/build-apisix-runtime.sh |
| chmod +x build-apisix-runtime.sh | ||
| ./build-apisix-runtime-debug-centos7.sh | ||
|
|
||
| # patch lua-resty-events |
There was a problem hiding this comment.
It is impossible to execute a reload without a transient interruption because the worker that was handling the unix socket connection is being restarted, and the other workers will not be able to connect to the broker over the unix socket again until the new worker that replaces it is up and running, so the logs will be some error level logs about connection closed, which will interrupt our tests, so we'll have to change the code here to warn level.
There is no need to apply this patch in production as it has no impact other than causing some error logs, when the worker is available, the worker and broker will reconnect, and event push will be available again.
| set_coredns | ||
| # run test cases | ||
| FLUSH_ETCD=1 prove --timer -Itest-nginx/lib -I./ -r ${TEST_FILE_SUB_DIR} | tee /tmp/test.result | ||
| FLUSH_ETCD=1 TEST_EVENTS_MODULE=lua-resty-worker-events prove --timer -Itest-nginx/lib -I./ -r ${TEST_FILE_SUB_DIR} | tee /tmp/test.result |
There was a problem hiding this comment.
I don’t quite understand this part. I see that the code already uses lua-resty-event as the default event library. Why do I need to specify this variable?
There was a problem hiding this comment.
First, this is the same logic executed in the other test scripts, with the difference that under ubuntu we are executing the tests for both event modules at the same time, where an environment variable controlled by GitHub workflow is used as input.
You can see the header of some of the test cases, some of the tests are related to the events library and because of the implementation of the library they have slightly different behaviors, such as proactive health checks, which use different test cases under different events modules.
If an events module is not explicitly configured, it will default to the value in config-default, which is lua-resty-events, so simultaneous testing is not possible.
But it looks like some of the logic can be ported to APISIX.pm, and I'll be making that change.
There was a problem hiding this comment.
Moved to lua-resty-events as the default test events module
| require "resty.core" | ||
|
|
||
| local events_sock_path = "$apisix_home/t/servroot/logs/stream_worker_events.sock" | ||
| if os.getenv("TEST_NGINX_USE_HUP") ~= "1" then |
There was a problem hiding this comment.
Why does the test case using the HUP signal need to remove the sock, and other cases do not need to remove the unix sock?
There was a problem hiding this comment.
Theoretically they will process properly, I can try. Maybe it's not necessary.
There was a problem hiding this comment.
Removed, it can work.
| create new checker: table | ||
| try to release checker: table | ||
| create new checker: table | ||
| --- no_error_log |
There was a problem hiding this comment.
This is the cost of the lua-resty-events library, whose events are asynchronous and delayed, so when the health checker is first created, the events are not communicated in a timely manner, so these error logs must appear.
There was a problem hiding this comment.
They should have no impact because the main use of the test is to test that when the service discovers a change in the node provided, the new checker is created correctly rather than as a result of a health check.
If you are concerned about this, we will have to follow the example of the passive health check tests by listing them as separate test files and skipping them when they are not needed.
Description
Provide lua-resty-events as a new implementation of the event system. It experimentally provides better performance and efficiency.
fix #10431
Checklist