~yozik04/nginx/rtmp

« back to all changes in this revision

Viewing changes to debian/modules/nginx-lua/t/033-ctx.t

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-02-15 03:05:42 UTC
  • mfrom: (4.3.10 sid)
  • Revision ID: package-import@ubuntu.com-20140215030542-71ubtowl24vf7nfn
Tags: 1.4.5-1ubuntu1
* Resynchronise with Debian (LP: #1280511).  Remaining changes:
  - debian/patches/ubuntu-branding.patch:
    + Add Ubuntu branding to server_tokens.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# vim:set ft= ts=4 sw=4 et fdm=marker:
2
2
use lib 'lib';
3
 
use Test::Nginx::Socket;
 
3
use Test::Nginx::Socket::Lua;
4
4
 
5
5
#worker_connections(1014);
6
6
#master_on();
10
10
repeat_each(2);
11
11
#repeat_each(1);
12
12
 
13
 
plan tests => repeat_each() * (blocks() * 3 + 1);
 
13
plan tests => repeat_each() * (blocks() * 3 + 7);
14
14
 
15
15
#no_diff();
16
16
#no_long_string();
210
210
--- no_error_log
211
211
[error]
212
212
 
 
213
 
 
214
 
 
215
=== TEST 9: ngx.ctx leaks with ngx.exec + log_by_lua
 
216
--- config
 
217
    location = /t {
 
218
        content_by_lua '
 
219
            ngx.ctx.foo = 32;
 
220
            ngx.exec("/f")
 
221
        ';
 
222
        log_by_lua 'ngx.log(ngx.WARN, "ctx.foo = ", ngx.ctx.foo)';
 
223
    }
 
224
    location = /f {
 
225
        content_by_lua '
 
226
            ngx.say(ngx.ctx.foo)
 
227
        ';
 
228
    }
 
229
--- request
 
230
GET /t
 
231
--- response_body
 
232
nil
 
233
--- no_error_log
 
234
[error]
 
235
ctx.foo = 
 
236
 
 
237
 
 
238
 
 
239
=== TEST 10: memory leaks with ngx.ctx + ngx.req.set_uri + log_by_lua
 
240
--- config
 
241
    location = /t {
 
242
        rewrite_by_lua '
 
243
            ngx.ctx.foo = 32;
 
244
            ngx.req.set_uri("/f", true)
 
245
        ';
 
246
        log_by_lua 'ngx.log(ngx.WARN, "ctx.foo = ", ngx.ctx.foo)';
 
247
    }
 
248
    location = /f {
 
249
        content_by_lua '
 
250
            ngx.say(ngx.ctx.foo)
 
251
        ';
 
252
    }
 
253
--- request
 
254
GET /t
 
255
--- response_body
 
256
nil
 
257
--- no_error_log
 
258
[error]
 
259
ctx.foo = 
 
260
 
 
261
 
 
262
 
 
263
=== TEST 11: ngx.ctx + ngx.exit(ngx.ERROR) + log_by_lua
 
264
--- config
 
265
    location = /t {
 
266
        rewrite_by_lua '
 
267
            ngx.ctx.foo = 32;
 
268
            ngx.exit(ngx.ERROR)
 
269
        ';
 
270
        log_by_lua 'ngx.log(ngx.WARN, "ngx.ctx = ", ngx.ctx.foo)';
 
271
    }
 
272
--- request
 
273
GET /t
 
274
--- ignore_response
 
275
--- no_error_log
 
276
[error]
 
277
--- error_log
 
278
ngx.ctx = 32
 
279
 
 
280
 
 
281
 
 
282
=== TEST 12: ngx.ctx + ngx.exit(200) + log_by_lua
 
283
--- config
 
284
    location = /t {
 
285
        rewrite_by_lua '
 
286
            ngx.ctx.foo = 32;
 
287
            ngx.say(ngx.ctx.foo)
 
288
            ngx.exit(200)
 
289
        ';
 
290
        log_by_lua 'ngx.log(ngx.WARN, "ctx.foo = ", ngx.ctx.foo)';
 
291
    }
 
292
--- request
 
293
GET /t
 
294
--- response_body
 
295
32
 
296
--- no_error_log
 
297
[error]
 
298
--- error_log
 
299
ctx.foo = 32
 
300
 
 
301
 
 
302
 
 
303
=== TEST 13: ngx.ctx + ngx.redirect + log_by_lua
 
304
--- config
 
305
    location = /t {
 
306
        rewrite_by_lua '
 
307
            ngx.ctx.foo = 32;
 
308
            ngx.redirect("/f")
 
309
        ';
 
310
        log_by_lua 'ngx.log(ngx.WARN, "ngx.ctx.foo = ", 32)';
 
311
    }
 
312
--- request
 
313
GET /t
 
314
--- response_body_like: 302 Found
 
315
--- error_code: 302
 
316
--- error_log
 
317
ctx.foo = 32
 
318
--- no_error_log
 
319
[error]
 
320
 
 
321
 
 
322
 
 
323
=== TEST 14: set ngx.ctx before internal redirects performed by other nginx modules
 
324
--- config
 
325
    location = /t {
 
326
        rewrite_by_lua '
 
327
            ngx.ctx.foo = "hello world";
 
328
        ';
 
329
        echo_exec /foo;
 
330
    }
 
331
 
 
332
    location = /foo {
 
333
        echo hello;
 
334
    }
 
335
--- request
 
336
GET /t
 
337
--- response_body
 
338
hello
 
339
--- no_error_log
 
340
[error]
 
341
--- log_level: debug
 
342
--- error_log
 
343
lua release ngx.ctx at ref
 
344
 
 
345
 
 
346
 
 
347
=== TEST 15: set ngx.ctx before internal redirects performed by other nginx modules (with log_by_lua)
 
348
--- config
 
349
    location = /t {
 
350
        rewrite_by_lua '
 
351
            ngx.ctx.foo = "hello world";
 
352
        ';
 
353
        echo_exec /foo;
 
354
    }
 
355
 
 
356
    location = /foo {
 
357
        echo hello;
 
358
        log_by_lua return;
 
359
    }
 
360
--- request
 
361
GET /t
 
362
--- response_body
 
363
hello
 
364
--- no_error_log
 
365
[error]
 
366
--- log_level: debug
 
367
--- error_log
 
368
lua release ngx.ctx at ref
 
369
 
 
370
 
 
371
 
 
372
=== TEST 16: set ngx.ctx before simple uri rewrite performed by other nginx modules
 
373
--- config
 
374
    location = /t {
 
375
        set_by_lua $a 'ngx.ctx.foo = "hello world"; return 1';
 
376
        rewrite ^ /foo last;
 
377
        echo blah;
 
378
    }
 
379
 
 
380
    location = /foo {
 
381
        echo foo;
 
382
    }
 
383
--- request
 
384
GET /t
 
385
--- response_body
 
386
foo
 
387
--- no_error_log
 
388
[error]
 
389
--- log_level: debug
 
390
--- error_log
 
391
lua release ngx.ctx at ref
 
392