Skip to content

Commit

Permalink
chore(tests): re-enable disabled mlcache tests (#12102)
Browse files Browse the repository at this point in the history
### Summary

Some mlcache tests were disabled because of flakiness. This commit re-enables them
(hopefully this time without flakiness).

Signed-off-by: Aapo Talvensaari <aapo.talvensaari@gmail.com>
  • Loading branch information
bungle authored Dec 4, 2023
1 parent 9eb21f7 commit 22e0b13
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
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

0 comments on commit 22e0b13

Please sign in to comment.