File tree Expand file tree Collapse file tree 1 file changed +44
-1
lines changed Expand file tree Collapse file tree 1 file changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ use Test::Nginx::Socket::Lua;
8
8
9
9
# repeat_each(2);
10
10
11
- plan tests => repeat_each() * 36 ;
11
+ plan tests => repeat_each() * 39 ;
12
12
13
13
# no_diff();
14
14
no_long_string();
@@ -1203,3 +1203,46 @@ failed to safe set baz: no memory
1203
1203
--- no_error_log
1204
1204
[error]
1205
1205
1206
+
1207
+
1208
+ === TEST 10: fuzz testing
1209
+ --- http_config
1210
+ lua_shared_dict dogs 200k;
1211
+ --- config
1212
+ location = /t {
1213
+ content_by_lua '
1214
+ local rand = math.random
1215
+ local dogs = ngx.shared.dogs
1216
+ local maxsz = 9000
1217
+ local maxkeyidx = 30
1218
+ local rep = string.rep
1219
+
1220
+ math.randomseed(ngx.time())
1221
+ for i = 1, 30000 do
1222
+ local key = "mylittlekey" .. rand(maxkeyidx)
1223
+ local ok, err = dogs:get(key)
1224
+ if not ok or rand() > 0.6 then
1225
+ sz = rand(maxsz)
1226
+ val = rep("a", sz)
1227
+ local ok, err, forcible = dogs:set(key, val)
1228
+ if err then
1229
+ ngx.log(ngx.ERR, "failed to set key: ", err)
1230
+ -- return
1231
+ end
1232
+ if forcible then
1233
+ -- error("forcible")
1234
+ end
1235
+ end
1236
+ end
1237
+ ngx.say("ok")
1238
+ ';
1239
+ }
1240
+ --- request
1241
+ GET /t
1242
+ --- response_body
1243
+ ok
1244
+
1245
+ --- no_error_log
1246
+ [error]
1247
+ --- timeout: 30
1248
+
You can’t perform that action at this time.
0 commit comments