You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by me...@apache.org on 2020/09/06 04:10:50 UTC
[apisix] branch master updated: fix: log-rotate.t is unstable
(#2164)
This is an automated email from the ASF dual-hosted git repository.
membphis 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 d421683 fix: log-rotate.t is unstable (#2164)
d421683 is described below
commit d4216831e3c65ac26f4a600fa6b216471ecda6d7
Author: gy <gu...@163.com>
AuthorDate: Sun Sep 6 12:10:42 2020 +0800
fix: log-rotate.t is unstable (#2164)
fix #2138
---
t/plugin/log-rotate.t | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/t/plugin/log-rotate.t b/t/plugin/log-rotate.t
index 9896865..3cf08cb 100644
--- a/t/plugin/log-rotate.t
+++ b/t/plugin/log-rotate.t
@@ -51,17 +51,36 @@ __DATA__
content_by_lua_block {
ngx.log(ngx.ERR, "start xxxxxx")
ngx.sleep(2.5)
-
+ local has_split_access_file = false
+ local has_split_error_file = false
local lfs = require("lfs")
- for file in lfs.dir(ngx.config.prefix() .. "/logs/") do
- ngx.say(file)
+ for file_name in lfs.dir(ngx.config.prefix() .. "/logs/") do
+ if string.match(file_name, "__access.log$") then
+ has_split_access_file = true
+ end
+
+ if string.match(file_name, "__error.log$") then
+ local f = assert(io.open(ngx.config.prefix() .. "/logs/" .. file_name, "r"))
+ local content = f:read("*all")
+ f:close()
+ local index = string.find(content, "start xxxxxx")
+ if index then
+ has_split_error_file = true
+ end
+ end
end
+
+ if not has_split_error_file or not has_split_error_file then
+ ngx.status = 500
+ else
+ ngx.status = 200
+ end
}
}
--- request
GET /t
---- response_body_like eval
-qr/\_error\.log[\s\S]*\_access\.log/
+--- error_code eval
+[200]
--- no_error_log
[error]