Skip to content

Commit

Permalink
test: reduce CI failure caused by flaky tests (#7085)
Browse files Browse the repository at this point in the history
This commit addresses the problem with these actions:
1. increase the rerun limit
2. make sure last reopen file is expired
3. increase redis delay to reduce the effect from the request latency
4. increase report time so the tcp-logger in prometheus test doesn't
   report to TCP receiver as we don't have such a TCP receiver.

Signed-off-by: spacewander <[email protected]>
  • Loading branch information
spacewander committed Jun 30, 2022
1 parent 8cdcea1 commit 6beeacc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ci/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ rerun_flaky_tests() {
local n_test
tests="$(awk '/^t\/.*.t\s+\(.+ Failed: .+\)/{ print $1 }' "$1")"
n_test="$(echo "$tests" | wc -l)"
if [ "$n_test" -gt 3 ]; then
if [ "$n_test" -gt 10 ]; then
# too many tests failed
exit 1
fi
Expand Down
2 changes: 2 additions & 0 deletions t/plugin/file-logger-reopen.t
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ file.log: No such file or directory
local code = t("/hello", ngx.HTTP_GET)
assert(io.open("file.log", 'r'))
os.remove("file.log")
ngx.sleep(0.01) -- make sure last reopen file is expired
local process = require "ngx.process"
local resty_signal = require "resty.signal"
Expand All @@ -135,6 +136,7 @@ file.log: No such file or directory
end
local code = t("/hello", ngx.HTTP_GET)
assert(code == 200)
-- file is reopened
local fd, err = io.open("file.log", 'r')
Expand Down
2 changes: 1 addition & 1 deletion t/plugin/prometheus2.t
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ qr/apisix_batch_process_entries\{name="http-logger",route_id="9",server_addr="12
"buffer_duration": 60,
"port": 1000,
"batch_max_size": 1000,
"inactive_timeout": 5,
"inactive_timeout": 60,
"tls": false,
"max_retry_count": 0
}
Expand Down
22 changes: 11 additions & 11 deletions t/xrpc/redis.t
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,9 @@ ok
name = "redis",
conf = {
faults = {
{delay = 0.03, key = "b", commands = {"del"}},
{delay = 0.02, key = "a", commands = {"mset"}},
{delay = 0.01, key = "b", commands = {"mset"}},
{delay = 0.06, key = "b", commands = {"del"}},
{delay = 0.04, key = "a", commands = {"mset"}},
{delay = 0.02, key = "b", commands = {"mset"}},
}
}
},
Expand Down Expand Up @@ -517,8 +517,8 @@ passed
return
end
local now = ngx.now()
if math.ceil((now - start) * 1000) < 20 then
ngx.say(now, " ", start)
if math.ceil((now - start) * 1000) < 40 then
ngx.say("mset a ", now, " ", start)
return
end
start = now
Expand All @@ -529,8 +529,8 @@ passed
return
end
local now = ngx.now()
if math.ceil((now - start) * 1000) < 10 or math.ceil((now - start) * 1000) > 15 then
ngx.say(now, " ", start)
if math.ceil((now - start) * 1000) < 20 or math.ceil((now - start) * 1000) > 35 then
ngx.say("mset b ", now, " ", start)
return
end
start = now
Expand All @@ -541,8 +541,8 @@ passed
return
end
local now = ngx.now()
if math.ceil((now - start) * 1000) > 5 then
ngx.say(now, " ", start)
if math.ceil((now - start) * 1000) > 20 then
ngx.say("mset mismatch ", now, " ", start)
return
end
start = now
Expand All @@ -553,8 +553,8 @@ passed
return
end
local now = ngx.now()
if math.ceil((now - start) * 1000) < 30 then
ngx.say(now, " ", start)
if math.ceil((now - start) * 1000) < 60 then
ngx.say("del b ", now, " ", start)
return
end
start = now
Expand Down

0 comments on commit 6beeacc

Please sign in to comment.