Mercurial > hg > nginx-tests
annotate uwsgi.t @ 251:df984d23f9d1
Tests: improve fastcgi keepalive tests.
On some platforms fastcgi_keepalive.t tests failed due to problems in
handling of data split into multiple packets. Harden tests to fail
on all platforms by adding more sleeps, and mark them as TODO till
underlying problems are fixed.
Additionally, add some padding testing.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 25 Jan 2013 20:53:53 +0400 |
parents | 6a0d934950bc |
children | 98f3a8568b0c |
rev | line source |
---|---|
168 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Test for uwsgi backend. | |
6 | |
7 ############################################################################### | |
8 | |
9 use warnings; | |
10 use strict; | |
11 | |
12 use Test::More; | |
13 | |
14 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
15 | |
16 use lib 'lib'; | |
17 use Test::Nginx; | |
18 | |
19 ############################################################################### | |
20 | |
21 select STDERR; $| = 1; | |
22 select STDOUT; $| = 1; | |
23 | |
24 my $t = Test::Nginx->new()->has(qw/http uwsgi/)->has_daemon('uwsgi')->plan(3) | |
25 ->write_file_expand('nginx.conf', <<'EOF'); | |
26 | |
27 %%TEST_GLOBALS%% | |
28 | |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
241
diff
changeset
|
29 daemon off; |
168 | 30 |
31 events { | |
32 } | |
33 | |
34 http { | |
35 %%TEST_GLOBALS_HTTP%% | |
36 | |
37 server { | |
38 listen 127.0.0.1:8080; | |
39 server_name localhost; | |
40 | |
41 location / { | |
42 uwsgi_pass 127.0.0.1:8081; | |
43 uwsgi_param SERVER_PROTOCOL $server_protocol; | |
44 uwsgi_param HTTP_X_BLAH "blah"; | |
45 } | |
46 } | |
47 } | |
48 | |
49 EOF | |
50 | |
51 $t->write_file('uwsgi_test_app.py', <<END); | |
52 | |
53 def application(env, start_response): | |
54 start_response('200 OK', [('Content-Type','text/plain')]) | |
55 return "SEE-THIS" | |
56 | |
57 END | |
58 | |
59 $t->run_daemon('uwsgi', '--socket', '127.0.0.1:8081', | |
60 '--wsgi-file', $t->testdir() . '/uwsgi_test_app.py', | |
61 '--logto', $t->testdir() . '/uwsgi_log'); | |
62 | |
63 $t->run(); | |
64 | |
174
c8169c827d18
Tests: use waitoforsocket() as uwsgi startup may take a while.
Maxim Dounin <mdounin@mdounin.ru>
parents:
168
diff
changeset
|
65 $t->waitforsocket('127.0.0.1:8081') |
c8169c827d18
Tests: use waitoforsocket() as uwsgi startup may take a while.
Maxim Dounin <mdounin@mdounin.ru>
parents:
168
diff
changeset
|
66 or die "Can't start uwsgi"; |
c8169c827d18
Tests: use waitoforsocket() as uwsgi startup may take a while.
Maxim Dounin <mdounin@mdounin.ru>
parents:
168
diff
changeset
|
67 |
168 | 68 ############################################################################### |
69 | |
70 like(http_get('/'), qr/SEE-THIS/, 'uwsgi request'); | |
71 unlike(http_head('/head'), qr/SEE-THIS/, 'no data in HEAD'); | |
72 | |
73 like(http_get_headers('/headers'), qr/SEE-THIS/, | |
74 'uwsgi request with many ignored headers'); | |
75 | |
76 ############################################################################### | |
77 | |
78 sub http_get_headers { | |
79 my ($url, %extra) = @_; | |
80 return http(<<EOF, %extra); | |
81 GET $url HTTP/1.0 | |
82 Host: localhost | |
83 X-Blah: ignored header | |
84 X-Blah: ignored header | |
85 X-Blah: ignored header | |
86 X-Blah: ignored header | |
87 X-Blah: ignored header | |
88 X-Blah: ignored header | |
89 X-Blah: ignored header | |
90 X-Blah: ignored header | |
91 X-Blah: ignored header | |
92 X-Blah: ignored header | |
93 X-Blah: ignored header | |
94 X-Blah: ignored header | |
95 X-Blah: ignored header | |
96 X-Blah: ignored header | |
97 X-Blah: ignored header | |
98 X-Blah: ignored header | |
99 X-Blah: ignored header | |
100 X-Blah: ignored header | |
101 X-Blah: ignored header | |
102 | |
103 EOF | |
104 } | |
105 | |
106 ############################################################################### |