Skip to content

Commit e51bf67

Browse files
fix: include stream plugins in ci (#12844)
* fix: enable stream plugins Signed-off-by: Abhishek Choudhary <[email protected]> * fix Signed-off-by: Abhishek Choudhary <[email protected]> * lim conn Signed-off-by: Abhishek Choudhary <[email protected]> * f Signed-off-by: Abhishek Choudhary <[email protected]> * fix Signed-off-by: Abhishek Choudhary <[email protected]> * f Signed-off-by: Nic <[email protected]> * f Signed-off-by: Nic <[email protected]> --------- Signed-off-by: Abhishek Choudhary <[email protected]> Signed-off-by: Nic <[email protected]> Co-authored-by: Nic <[email protected]>
1 parent 2335e92 commit e51bf67

File tree

5 files changed

+35
-14
lines changed

5 files changed

+35
-14
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- lua-resty-events
3434
test_dir:
3535
- t/plugin/[a-k]*
36-
- t/plugin/[l-z]*
36+
- t/stream-plugin t/plugin/[l-z]*
3737
- t/admin t/cli t/config-center-yaml t/control t/core t/debug t/discovery t/error_page t/http3/admin t/misc
3838
- t/node t/pubsub t/router t/script t/secret t/stream-node t/utils t/wasm t/xds-library t/xrpc
3939

apisix/plugins/limit-conn/init.lua

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,9 @@ local _M = {}
4141

4242

4343
local function create_limit_obj(conf)
44-
if conf.policy == "local" then
45-
core.log.info("create new limit-conn plugin instance")
46-
return limit_conn_new(shdict_name, conf.conn, conf.burst,
47-
conf.default_conn_delay)
48-
elseif conf.policy == "redis" then
44+
core.log.info("create new limit-conn plugin instance")
4945

46+
if conf.policy == "redis" then
5047
core.log.info("create new limit-conn redis plugin instance")
5148

5249
return redis_single_new("plugin-limit-conn", conf, conf.conn, conf.burst,
@@ -59,7 +56,9 @@ local function create_limit_obj(conf)
5956
return redis_cluster_new("plugin-limit-conn", conf, conf.conn, conf.burst,
6057
conf.default_conn_delay)
6158
else
62-
return nil, "policy enum not match"
59+
core.log.info("create new limit-conn plugin instance")
60+
return limit_conn_new(shdict_name, conf.conn, conf.burst,
61+
conf.default_conn_delay)
6362
end
6463
end
6564

t/stream-plugin/mqtt-proxy2.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ passed
7474
"\x10\x0f\x00\x04\x4d\x51\x54\x54\x04\x02\x00\x3c\x00\x03\x66\x6f\x6f"
7575
--- error_log
7676
failed to parse domain: loc, error:
77-
--- timeout: 10
77+
--- timeout: 25
7878

7979

8080

@@ -109,6 +109,7 @@ failed to parse domain: loc, error:
109109
}
110110
--- request
111111
GET /t
112+
--- error_code: 201
112113
--- response_body
113114
passed
114115

t/stream-plugin/prometheus.t

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ BEGIN {
2222
$ENV{TEST_NGINX_USE_HUP} = 1;
2323
undef $ENV{TEST_NGINX_USE_STAP};
2424
}
25+
# because nginx-lua-prometheus uses a timer to periodically synchronize lua module variables to
26+
# shared dict, and all test cases in this test file use HUP to reload nginx in order to retain
27+
# the data in the shared dict, it is necessary to increase the value of TEST_NGINX_SLEEP to
28+
# avoid losing prometheus data due to worker exits.
29+
$ENV{TEST_NGINX_SLEEP} = 1;
2530
}
2631

2732
use t::APISIX;
@@ -136,8 +141,25 @@ Received unexpected MQTT packet type+flags
136141
137142
138143
=== TEST 5: fetch the prometheus metric data
144+
--- config
145+
location /t {
146+
content_by_lua_block {
147+
local t = require("lib.test_admin").test
148+
local core = require("apisix.core")
149+
local http = require("resty.http")
150+
151+
ngx.sleep(2) -- wait for the metrics to be updated
152+
local httpc = http.new()
153+
local res, err = httpc:request_uri("http://127.0.0.1:1984/apisix/prometheus/metrics")
154+
if not res then
155+
ngx.say(err)
156+
return
157+
end
158+
ngx.say(res.body)
159+
}
160+
}
139161
--- request
140-
GET /apisix/prometheus/metrics
162+
GET /t
141163
--- response_body eval
142164
qr/apisix_stream_connection_total\{route="mqtt"\} 2/
143165
@@ -147,12 +169,12 @@ qr/apisix_stream_connection_total\{route="mqtt"\} 2/
147169
--- request
148170
GET /apisix/prometheus/metrics
149171
--- response_body eval
150-
qr/apisix_nginx_http_current_connections\{state="active"\} 1/
172+
qr/apisix_nginx_http_current_connections\{state="active".*\} \d+/
151173
152174
153175
154176
=== TEST 7: contains basic metrics
155177
--- request
156178
GET /apisix/prometheus/metrics
157179
--- response_body eval
158-
qr/apisix_node_info\{hostname="[^"]+"\}/
180+
qr/apisix_node_info\{hostname="[^"]+".*\}/

t/stream-plugin/syslog.t

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ mmm
149149
hello world
150150
--- wait: 0.5
151151
--- error_log eval
152-
qr/message received:.*\"client_ip\\"\:\\"127.0.0.1\\"/
152+
qr/message received:.*"client_ip":"127.0.0.1"/
153153
154154
155155
@@ -373,8 +373,7 @@ sending a batch logs to 127.0.0.1:5045
373373
"127.0.0.1:1995": 1
374374
},
375375
"type": "roundrobin"
376-
},
377-
"uri": "/hello"
376+
}
378377
}]]
379378
)
380379

0 commit comments

Comments
 (0)