-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(env): Add test for a lot readers
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# vim:set ft= ts=4 sw=4 et: | ||
|
||
use Test::Nginx::Socket::Lua; | ||
use Cwd qw(cwd); | ||
|
||
repeat_each(2); | ||
|
||
plan tests => repeat_each() * blocks() * 5; | ||
|
||
my $pwd = cwd(); | ||
|
||
our $MainConfig = qq{ | ||
lmdb_environment_path /tmp/test.mdb; | ||
lmdb_map_size 5m; | ||
}; | ||
|
||
our $HttpConfig = qq{ | ||
lua_package_path "$pwd/lib/?.lua;;"; | ||
init_worker_by_lua_block { | ||
local lmdb_set = require("resty.lmdb").set | ||
lmdb_set("worker" .. ngx.worker.id(), tostring(ngx.worker.id())) | ||
} | ||
}; | ||
|
||
no_long_string(); | ||
#no_diff(); | ||
|
||
master_process_enabled('on'); | ||
workers(200); | ||
|
||
run_tests(); | ||
|
||
__DATA__ | ||
|
||
=== TEST 1: simple set() / get() | ||
--- http_config eval: $::HttpConfig | ||
--- main_config eval: $::MainConfig | ||
--- config | ||
location = /t { | ||
content_by_lua_block { | ||
local l = require("resty.lmdb") | ||
ngx.say(l.set("test", "value")) | ||
ngx.say(l.get("test")) | ||
ngx.say(l.get("test_not_exist")) | ||
} | ||
} | ||
--- request | ||
GET /t | ||
--- response_body | ||
true | ||
value | ||
nil | ||
--- no_error_log | ||
[error] | ||
[warn] | ||
[crit] |