Mercurial > hg > nginx-tests
annotate not_modified_finalize.t @ 1282:fd281e3a3df5
Tests: better test names in h2_server_push.t.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 12 Feb 2018 14:46:40 +0300 |
parents | 2978c5212045 |
children | fc3722dd8862 |
rev | line source |
---|---|
1096
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for not modified filter and filter finalization. |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 BEGIN { use FindBin; chdir($FindBin::Bin); } |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 use lib 'lib'; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use Test::Nginx qw/ :DEFAULT :gzip /; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 ############################################################################### |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 select STDERR; $| = 1; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 select STDOUT; $| = 1; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(1) |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 ->write_file_expand('nginx.conf', <<'EOF'); |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 %%TEST_GLOBALS%% |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 daemon off; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 events { |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 } |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 http { |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 %%TEST_GLOBALS_HTTP%% |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 proxy_cache_path %%TESTDIR%%/cache keys_zone=cache:1m; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 server { |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 listen 127.0.0.1:8080; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 server_name localhost; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 error_page 412 /error412.html; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 location / { |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 proxy_pass http://127.0.0.1:8081; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 proxy_cache cache; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 proxy_cache_lock on; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 } |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 location /error412 { |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 } |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 } |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 server { |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 listen 127.0.0.1:8081; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 server_name localhost; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 } |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 } |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 EOF |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 $t->write_file('t.html', 'test file'); |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 $t->write_file('error412.html', 'error412'); |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 $t->run(); |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 ############################################################################### |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 # we trigger filter finalization in not modified filter by using |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 # the If-Unmodified-Since/If-Match header; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 # with cache enabled and updating bit set, this currently results in |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 # "stalled cache updating" alerts |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 like(http_match_get('/t.html'), qr//, 'request 412'); |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 $t->todo_alerts(); |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 ############################################################################### |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 sub http_match_get { |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 my ($url, %extra) = @_; |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 return http(<<EOF, %extra); |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 GET $url HTTP/1.0 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 Host: localhost |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 If-Match: tt |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 EOF |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 } |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 |
2978c5212045
Tests: filter finalization in not modified filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 ############################################################################### |