Skip to content

Commit

Permalink
init resty-events in init_worker
Browse files Browse the repository at this point in the history
  • Loading branch information
locao committed Jun 10, 2022
1 parent 2e26c30 commit 68ec2cd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
10 changes: 8 additions & 2 deletions t/with_resty-events/03-get_target_status.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ our $HttpConfig = qq{
lua_package_path "$pwd/lib/?.lua;;";
lua_shared_dict test_shm 8m;

init_worker_by_lua_block {
local we = require "resty.events.compat"
assert(we.configure({
listening = "unix:$ENV{TEST_NGINX_SERVROOT}/worker_events.sock"
}))
assert(we.configured())
}

server {
server_name kong_worker_events;
listen unix:$ENV{TEST_NGINX_SERVROOT}/worker_events.sock;
Expand Down Expand Up @@ -43,8 +51,6 @@ qq{
--- config
location = /t {
content_by_lua_block {
local we = require "resty.events.compat"
assert(we.configure({ unique_timeout = 5, broker_id = 0, listening = "unix:" .. ngx.config.prefix() .. "worker_events.sock" }))
local healthcheck = require("resty.healthcheck")
local checker = healthcheck.new({
name = "testing",
Expand Down
14 changes: 10 additions & 4 deletions t/with_resty-events/03-get_target_status_with_sleeps.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ our $HttpConfig = qq{
lua_package_path "$pwd/lib/?.lua;;";
lua_shared_dict test_shm 8m;

init_worker_by_lua_block {
local we = require "resty.events.compat"
assert(we.configure({
unique_timeout = 5,
broker_id = 0,
listening = "unix:$ENV{TEST_NGINX_SERVROOT}/worker_events.sock"
}))
assert(we.configured())
}

server {
server_name kong_worker_events;
listen unix:$ENV{TEST_NGINX_SERVROOT}/worker_events.sock;
Expand Down Expand Up @@ -43,10 +53,6 @@ qq{
--- config
location = /t {
content_by_lua_block {
ngx.sleep(0.1)

local we = require "resty.events.compat"
assert(we.configure({ unique_timeout = 5, broker_id = 0, listening = "unix:" .. ngx.config.prefix() .. "worker_events.sock" }))
local healthcheck = require("resty.healthcheck")
local checker = healthcheck.new({
name = "testing",
Expand Down
16 changes: 8 additions & 8 deletions t/with_resty-events/04-report_success.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ our $HttpConfig = qq{
lua_package_path "$pwd/lib/?.lua;;";
lua_shared_dict test_shm 8m;

init_worker_by_lua_block {
local we = require "resty.events.compat"
assert(we.configure({
listening = "unix:$ENV{TEST_NGINX_SERVROOT}/worker_events.sock"
}))
assert(we.configured())
}

server {
server_name kong_worker_events;
listen unix:$ENV{TEST_NGINX_SERVROOT}/worker_events.sock;
Expand Down Expand Up @@ -45,8 +53,6 @@ qq{
--- config
location = /t {
content_by_lua_block {
local we = require "resty.events.compat"
assert(we.configure({ unique_timeout = 5, broker_id = 0, listening = "unix:" .. ngx.config.prefix() .. "worker_events.sock" }))
local healthcheck = require("resty.healthcheck")
local checker = healthcheck.new({
name = "testing",
Expand Down Expand Up @@ -121,8 +127,6 @@ qq{
--- config
location = /t {
content_by_lua_block {
local we = require "resty.events.compat"
assert(we.configure({ unique_timeout = 5, broker_id = 0, listening = "unix:" .. ngx.config.prefix() .. "worker_events.sock" }))
local healthcheck = require("resty.healthcheck")
local checker = healthcheck.new({
name = "testing",
Expand Down Expand Up @@ -196,8 +200,6 @@ qq{
--- config
location = /t {
content_by_lua_block {
local we = require "resty.events.compat"
assert(we.configure({ unique_timeout = 5, broker_id = 0, listening = "unix:" .. ngx.config.prefix() .. "worker_events.sock" }))
local healthcheck = require("resty.healthcheck")
local checker = healthcheck.new({
name = "testing",
Expand Down Expand Up @@ -261,8 +263,6 @@ qq{
--- config
location = /t {
content_by_lua_block {
local we = require "resty.events.compat"
assert(we.configure({ unique_timeout = 5, broker_id = 0, listening = "unix:" .. ngx.config.prefix() .. "worker_events.sock" }))
local healthcheck = require("resty.healthcheck")
local checker = healthcheck.new({
name = "testing",
Expand Down

0 comments on commit 68ec2cd

Please sign in to comment.