@@ -4,7 +4,7 @@ use Test::Nginx::Socket::Lua;
4
4
5
5
repeat_each(2 );
6
6
7
- plan tests => repeat_each() * 155 ;
7
+ plan tests => repeat_each() * 163 ;
8
8
9
9
# $ENV{LUA_PATH} = $ENV{HOME} . '/work/JSON4Lua-0.9.30/json/?.lua';
10
10
@@ -1244,3 +1244,133 @@ qr/\[alert\] \S+ lua_code_cache is off; this will hurt performance/,
1244
1244
" decrementing the reference count for Lua VM: 1 " ,
1245
1245
" lua close the global Lua VM" ,
1246
1246
]
1247
+
1248
+
1249
+
1250
+ === TEST 32: make sure inline code keys are correct
1251
+ GitHub issue #1428
1252
+ --- config
1253
+ include ../html/a/proxy.conf;
1254
+ include ../html/b/proxy.conf;
1255
+ include ../html/c/proxy.conf;
1256
+
1257
+ location /t {
1258
+ echo_location / a/ ;
1259
+ echo_location / b/ ;
1260
+ echo_location / a/ ;
1261
+ echo_location / c/ ;
1262
+ }
1263
+
1264
+ --- user_files
1265
+ >>> a/proxy.conf
1266
+ location /a/ {
1267
+ content_by_lua_block { ngx. say (" /a/ is called" ) }
1268
+ }
1269
+
1270
+ >>> b/proxy.conf
1271
+ location /b/ {
1272
+ content_by_lua_block { ngx. say (" /b/ is called" ) }
1273
+ }
1274
+
1275
+ >>> c/proxy.conf
1276
+ location /c/ {
1277
+ content_by_lua_block { ngx. say (" /b/ is called" ) }
1278
+ }
1279
+
1280
+ --- request
1281
+ GET /t
1282
+ --- response_body
1283
+ /a/ is called
1284
+ /b/ is called
1285
+ /a/ is called
1286
+ /b/ is called
1287
+ --- grep_error_log eval: qr/looking up Lua code cache with key '.*?'/
1288
+ --- grep_error_log_out eval
1289
+ [
1290
+ " looking up Lua code cache with key ' =content_by_lua(proxy.conf:2)nhli_3c7137b8371d10bc148c8f8bb3042ee6'
1291
+ looking up Lua code cache with key ' =content_by_lua(proxy.conf:2)nhli_1dfe09105792ef65c8d576cc486d5e04'
1292
+ looking up Lua code cache with key ' =content_by_lua(proxy.conf:2)nhli_3c7137b8371d10bc148c8f8bb3042ee6'
1293
+ looking up Lua code cache with key ' =content_by_lua(proxy.conf:2)nhli_1dfe09105792ef65c8d576cc486d5e04'
1294
+ " ,
1295
+ " looking up Lua code cache with key ' =content_by_lua(proxy.conf:2)nhli_3c7137b8371d10bc148c8f8bb3042ee6'
1296
+ looking up Lua code cache with key ' =content_by_lua(proxy.conf:2)nhli_1dfe09105792ef65c8d576cc486d5e04'
1297
+ looking up Lua code cache with key ' =content_by_lua(proxy.conf:2)nhli_3c7137b8371d10bc148c8f8bb3042ee6'
1298
+ looking up Lua code cache with key ' =content_by_lua(proxy.conf:2)nhli_1dfe09105792ef65c8d576cc486d5e04'
1299
+ looking up Lua code cache with key ' =content_by_lua(proxy.conf:2)nhli_3c7137b8371d10bc148c8f8bb3042ee6'
1300
+ looking up Lua code cache with key ' =content_by_lua(proxy.conf:2)nhli_1dfe09105792ef65c8d576cc486d5e04'
1301
+ looking up Lua code cache with key ' =content_by_lua(proxy.conf:2)nhli_3c7137b8371d10bc148c8f8bb3042ee6'
1302
+ looking up Lua code cache with key ' =content_by_lua(proxy.conf:2)nhli_1dfe09105792ef65c8d576cc486d5e04'
1303
+ " ]
1304
+ --- log_level: debug
1305
+ --- no_error_log
1306
+ [error]
1307
+
1308
+
1309
+
1310
+ === TEST 33: make sure Lua code file keys are correct
1311
+ GitHub issue #1428
1312
+ --- config
1313
+ include ../html/a/proxy.conf;
1314
+ include ../html/b/proxy.conf;
1315
+ include ../html/c/proxy.conf;
1316
+
1317
+ location /t {
1318
+ echo_location / a/ ;
1319
+ echo_location / b/ ;
1320
+ echo_location / a/ ;
1321
+ echo_location / c/ ;
1322
+ }
1323
+
1324
+ --- user_files
1325
+ >>> a.lua
1326
+ ngx.say(" /a / is called" )
1327
+
1328
+ >>> b.lua
1329
+ ngx.say(" /b / is called" )
1330
+
1331
+ >>> c.lua
1332
+ ngx.say(" /b / is called" )
1333
+
1334
+ >>> a/proxy.conf
1335
+ location /a/ {
1336
+ content_by_lua_file html/ a. lua;
1337
+ }
1338
+
1339
+ >>> b/proxy.conf
1340
+ location /b/ {
1341
+ content_by_lua_file html/ b. lua;
1342
+ }
1343
+
1344
+ >>> c/proxy.conf
1345
+ location /c/ {
1346
+ content_by_lua_file html/ c. lua;
1347
+ }
1348
+
1349
+ --- request
1350
+ GET /t
1351
+ --- response_body
1352
+ /a/ is called
1353
+ /b/ is called
1354
+ /a/ is called
1355
+ /b/ is called
1356
+ --- grep_error_log eval: qr/looking up Lua code cache with key '.*?'/
1357
+ --- grep_error_log_out eval
1358
+ [
1359
+ " looking up Lua code cache with key ' nhlf_48a9a7def61143c003a7de1644e026e4'
1360
+ looking up Lua code cache with key ' nhlf_68f5f4e946c3efd1cc206452b807e8b6'
1361
+ looking up Lua code cache with key ' nhlf_48a9a7def61143c003a7de1644e026e4'
1362
+ looking up Lua code cache with key ' nhlf_042c9b3a136fbacbbd0e4b9ad10896b7'
1363
+ " ,
1364
+ " looking up Lua code cache with key ' nhlf_48a9a7def61143c003a7de1644e026e4'
1365
+ looking up Lua code cache with key ' nhlf_68f5f4e946c3efd1cc206452b807e8b6'
1366
+ looking up Lua code cache with key ' nhlf_48a9a7def61143c003a7de1644e026e4'
1367
+ looking up Lua code cache with key ' nhlf_042c9b3a136fbacbbd0e4b9ad10896b7'
1368
+ looking up Lua code cache with key ' nhlf_48a9a7def61143c003a7de1644e026e4'
1369
+ looking up Lua code cache with key ' nhlf_68f5f4e946c3efd1cc206452b807e8b6'
1370
+ looking up Lua code cache with key ' nhlf_48a9a7def61143c003a7de1644e026e4'
1371
+ looking up Lua code cache with key ' nhlf_042c9b3a136fbacbbd0e4b9ad10896b7'
1372
+ "
1373
+ ]
1374
+ --- log_level: debug
1375
+ --- no_error_log
1376
+ [error]
0 commit comments