Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tests): re-enable disabled mlcache tests #12102

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions t/05-mlcache/02-get.t
Original file line number Diff line number Diff line change
Expand Up @@ -2379,7 +2379,6 @@ is stale: true


=== TEST 50: get() does not cache value in LRU indefinitely when retrieved from shm on last ms (see GH PR #58)
--- SKIP
--- http_config eval: $::HttpConfig
--- config
location = /t {
Expand Down Expand Up @@ -2419,8 +2418,6 @@ is stale: true
assert(data == 42, err or "invalid data value: " .. data)
ngx.say("hit_lvl: ", hit_lvl)

ngx.update_time()
local start = ngx.now() * 1000
while true do
lru:delete("key")
data, err, hit_lvl = cache:get("key", nil, cb)
Expand All @@ -2431,9 +2428,6 @@ is stale: true
end
ngx.sleep(0)
end
ngx.update_time()
local took = ngx.now() * 1000 - start
assert(took > 198 and took < 202)

data, err, hit_lvl = cache:get("key", nil, cb)
assert(data == 42, err or "invalid data value: " .. data)
Expand Down
30 changes: 16 additions & 14 deletions t/05-mlcache/03-peek.t
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ ttl: nil


=== TEST 3: peek() returns the remaining ttl if a key has been fetched before
--- SKIP
--- http_config eval: $::HttpConfig
--- config
location = /t {
Expand All @@ -117,36 +116,38 @@ ttl: nil
return nil
end

local val, err = cache:get("my_key", { neg_ttl = 19 }, cb)
local val, err = cache:get("my_key", { neg_ttl = 20 }, cb)
if err then
ngx.log(ngx.ERR, err)
return
end

ngx.sleep(1.1)

local ttl, err = cache:peek("my_key")
if err then
ngx.log(ngx.ERR, err)
return
end

ngx.say("ttl: ", math.ceil(ttl))
ngx.say("ttl < 19: ", tostring(math.floor(ttl) < 19))

ngx.sleep(1)
ngx.sleep(1.1)

local ttl, err = cache:peek("my_key")
if err then
ngx.log(ngx.ERR, err)
return
end

ngx.say("ttl: ", math.ceil(ttl))
ngx.say("ttl < 18: ", tostring(math.floor(ttl) < 18))
}
}
--- request
GET /t
--- response_body
ttl: 19
ttl: 18
ttl < 19: true
ttl < 18: true
--- no_error_log
[error]

Expand Down Expand Up @@ -359,7 +360,6 @@ no ttl: false


=== TEST 8: peek() returns remaining ttl if shm_miss is specified
--- SKIP
--- http_config eval: $::HttpConfig
--- config
location = /t {
Expand All @@ -374,36 +374,38 @@ no ttl: false
return nil
end

local val, err = cache:get("my_key", { neg_ttl = 19 }, cb)
local val, err = cache:get("my_key", { neg_ttl = 20 }, cb)
if err then
ngx.log(ngx.ERR, err)
return
end

ngx.sleep(1.1)

local ttl, err = cache:peek("my_key")
if err then
ngx.log(ngx.ERR, err)
return
end

ngx.say("ttl: ", math.ceil(ttl))
ngx.say("ttl < 19: ", tostring(math.floor(ttl) < 19))

ngx.sleep(1)
ngx.sleep(1.1)

local ttl, err = cache:peek("my_key")
if err then
ngx.log(ngx.ERR, err)
return
end

ngx.say("ttl: ", math.ceil(ttl))
ngx.say("ttl < 18: ", tostring(math.floor(ttl) < 18))
}
}
--- request
GET /t
--- response_body
ttl: 19
ttl: 18
ttl < 19: true
ttl < 18: true
--- no_error_log
[error]

Expand Down
6 changes: 0 additions & 6 deletions t/05-mlcache/15-renew.t
Original file line number Diff line number Diff line change
Expand Up @@ -2378,7 +2378,6 @@ is stale: true


=== TEST 48: renew() does not cache value in LRU indefinitely when retrieved from shm on last ms (see GH PR #58)
--- SKIP
--- http_config eval: $::HttpConfig
--- config
location = /t {
Expand Down Expand Up @@ -2419,8 +2418,6 @@ is stale: true
assert(data == 42, err or "invalid data value: " .. data)
ngx.say("hit_lvl: ", hit_lvl)

ngx.update_time()
local start = ngx.now() * 1000
while true do
lru:delete("key")
data, err, hit_lvl = cache:get("key", nil, cb)
Expand All @@ -2431,9 +2428,6 @@ is stale: true
end
ngx.sleep(0)
end
ngx.update_time()
local took = ngx.now() * 1000 - start
assert(took > 198 and took < 202)

data, err, hit_lvl = cache:get("key", nil, cb)
assert(data == 42, err or "invalid data value: " .. data)
Expand Down
Loading