This is an automated email from the ASF dual-hosted git repository.
baoyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 2880f0622 fix: resolve flaky test cases causing CI instability (#13158)
2880f0622 is described below
commit 2880f062207841a3c1d110a3264414559b5fd9dd
Author: Shreemaan Abhishek <[email protected]>
AuthorDate: Wed Apr 8 15:50:57 2026 +0545
fix: resolve flaky test cases causing CI instability (#13158)
---
t/core/config_etcd.t | 7 ++-----
t/node/upstream-domain.t | 29 ++++++++++++++++++++++-------
t/plugin/request-id.t | 18 ++++++++++++++----
t/plugin/sls-logger.t | 1 +
t/xrpc/redis.t | 2 +-
5 files changed, 40 insertions(+), 17 deletions(-)
diff --git a/t/core/config_etcd.t b/t/core/config_etcd.t
index 918ae7f37..918bdd8ce 100644
--- a/t/core/config_etcd.t
+++ b/t/core/config_etcd.t
@@ -561,8 +561,5 @@ GET /t
passed
--- grep_error_log eval
qr/etcd watch timeout, upgrade revision to/
---- grep_error_log_out
-etcd watch timeout, upgrade revision to
-etcd watch timeout, upgrade revision to
-etcd watch timeout, upgrade revision to
-etcd watch timeout, upgrade revision to
+--- grep_error_log_out eval
+qr/(etcd watch timeout, upgrade revision to\n){2,}/
diff --git a/t/node/upstream-domain.t b/t/node/upstream-domain.t
index 24048467f..78aa4af2b 100644
--- a/t/node/upstream-domain.t
+++ b/t/node/upstream-domain.t
@@ -356,19 +356,34 @@ passed
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
- local bodys = {}
- for i = 1, 3 do
- local _, _, body = t('/server_port', ngx.HTTP_GET)
- bodys[i] = body
+ -- warmup request to trigger DNS resolution for domain-based node
+ t('/server_port', ngx.HTTP_GET)
+ ngx.sleep(0.1)
+
+ local count = {}
+ local unexpected = 0
+ for i = 1, 18 do
+ local code, _, body = t('/server_port', ngx.HTTP_GET)
+ if code ~= 200 or (body ~= "1980" and body ~= "1981") then
+ unexpected = unexpected + 1
+ else
+ count[body] = (count[body] or 0) + 1
+ end
end
- table.sort(bodys)
- ngx.say(table.concat(bodys, ", "))
+ local c1981 = count["1981"] or 0
+ local c1980 = count["1980"] or 0
+ -- weight ratio is 2:1 (1981:1980), expect ~12:6 out of 18
+ -- after DNS warmup, distribution should approximate 2:1
+ local ratio_ok = unexpected == 0
+ and math.abs(c1981 - 2 * c1980) <= 4
+ and c1980 >= 4
+ ngx.say(ratio_ok)
}
}
--- request
GET /t
--- response_body
-1980, 1981, 1981
+true
diff --git a/t/plugin/request-id.t b/t/plugin/request-id.t
index c90baa250..4c8cc1e60 100644
--- a/t/plugin/request-id.t
+++ b/t/plugin/request-id.t
@@ -138,6 +138,7 @@ request header present
local http = require "resty.http"
local t = {}
local ids = {}
+ local found_dup = false
for i = 1, 180 do
local th = assert(ngx.thread.spawn(function()
local httpc = http.new()
@@ -161,7 +162,7 @@ request header present
end
if ids[id] == true then
- ngx.say("ids not unique")
+ found_dup = true
return
end
ids[id] = true
@@ -172,7 +173,11 @@ request header present
ngx.thread.wait(th)
end
- ngx.say("true")
+ if found_dup then
+ ngx.say("ids not unique")
+ else
+ ngx.say("true")
+ end
}
}
--- wait: 5
@@ -468,6 +473,7 @@ X-Request-ID: 123
if code >= 300 then
ngx.say("algorithm nanoid is error")
end
+ local found_dup = false
for i = 1, 180 do
local th = assert(ngx.thread.spawn(function()
local httpc = http.new()
@@ -489,7 +495,7 @@ X-Request-ID: 123
return -- ignore if the data is not synced yet.
end
if ids[id] == true then
- ngx.say("ids not unique")
+ found_dup = true
return
end
ids[id] = true
@@ -499,7 +505,11 @@ X-Request-ID: 123
for i, th in ipairs(v) do
ngx.thread.wait(th)
end
- ngx.say("true")
+ if found_dup then
+ ngx.say("ids not unique")
+ else
+ ngx.say("true")
+ end
}
}
--- wait: 5
diff --git a/t/plugin/sls-logger.t b/t/plugin/sls-logger.t
index e60582050..febbea289 100644
--- a/t/plugin/sls-logger.t
+++ b/t/plugin/sls-logger.t
@@ -522,6 +522,7 @@ failed to check the configuration of plugin sls-logger
ngx.say(err)
return
end
+ ngx.sleep(0.5)
ngx.say("done")
}
}
diff --git a/t/xrpc/redis.t b/t/xrpc/redis.t
index afb2f40e6..cb438c1cc 100644
--- a/t/xrpc/redis.t
+++ b/t/xrpc/redis.t
@@ -549,7 +549,7 @@ passed
return
end
local now = ngx.now()
- if math.ceil((now - start) * 1000) < 60 then
+ if math.ceil((now - start) * 1000) < 55 then
ngx.say("del b ", now, " ", start)
return
end