Skip to content

Instantly share code, notes, and snippets.

@wanghuizzz
Last active April 17, 2020 04:44
Show Gist options
  • Save wanghuizzz/61e4da9279a635471d8cd31253d4c99d to your computer and use it in GitHub Desktop.
Save wanghuizzz/61e4da9279a635471d8cd31253d4c99d to your computer and use it in GitHub Desktop.
no-memory-test.t
=== TEST 93: no memory test
--- http_config
lua_shared_dict dogs 1m;
--- config
location = /test {
content_by_lua '
local dogs = ngx.shared.dogs
local value_small = string.rep("1", 32)
local value_large = string.rep("1", 128)
local ok, err
for i = 1, 30000 do
ok, err = dogs:add(i, value_small)
if not ok then
ngx.log(ngx.ERR, "failed add ,err = "..err)
end
end
for i = 30001, 30002 do
ok, err = dogs:add(i, value_large)
if not ok then
ngx.log(ngx.ERR, "failed add ,err = "..err)
end
end
';
}
--- request
GET /test
--- error_log
failed add ,err = no memory
=== TEST 94: no memory test
--- http_config
lua_shared_dict dogs 1m;
--- config
location = /test {
content_by_lua '
local dogs = ngx.shared.dogs
local value_small = string.rep("1", 32)
local value_large = string.rep("1", 128)
local ok, err
for i = 1, 30000 do
ok, err = dogs:add(i, value_large)
if not ok then
ngx.log(ngx.ERR, "failed add ,err = "..err)
end
end
for i = 30001, 30002 do
ok, err = dogs:add(i, value_large)
if not ok then
ngx.log(ngx.ERR, "failed add ,err = "..err)
end
end
';
}
--- request
GET /test
--- no_error_log
[error]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment