Mercurial > hg > nginx-tests
annotate uwsgi.t @ 540:481d705b8610
Tests: SSL support in mail backends.
Socket is now embedded into every mail module.
Socket methods are wrapped where appropriate.
The new "SSL" extra flag specifies to accept connection over SSL.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 03 Apr 2015 00:11:38 +0300 |
parents | 98f3a8568b0c |
children | dc2f8aac0553 |
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 | |
363
98f3a8568b0c
Tests: try to load python plugin if uwsgi has no wsgi option.
Sergey Budnevitch <sb@waeme.net>
parents:
249
diff
changeset
|
59 my $uwsgihelp = `uwsgi -h`; |
98f3a8568b0c
Tests: try to load python plugin if uwsgi has no wsgi option.
Sergey Budnevitch <sb@waeme.net>
parents:
249
diff
changeset
|
60 my @uwsgiopts = (); |
98f3a8568b0c
Tests: try to load python plugin if uwsgi has no wsgi option.
Sergey Budnevitch <sb@waeme.net>
parents:
249
diff
changeset
|
61 |
98f3a8568b0c
Tests: try to load python plugin if uwsgi has no wsgi option.
Sergey Budnevitch <sb@waeme.net>
parents:
249
diff
changeset
|
62 if ($uwsgihelp !~ /--wsgi-file/) { |
98f3a8568b0c
Tests: try to load python plugin if uwsgi has no wsgi option.
Sergey Budnevitch <sb@waeme.net>
parents:
249
diff
changeset
|
63 # uwsgi has no python support, maybe plugin load is necessary |
98f3a8568b0c
Tests: try to load python plugin if uwsgi has no wsgi option.
Sergey Budnevitch <sb@waeme.net>
parents:
249
diff
changeset
|
64 push @uwsgiopts, '--plugin', 'python'; |
98f3a8568b0c
Tests: try to load python plugin if uwsgi has no wsgi option.
Sergey Budnevitch <sb@waeme.net>
parents:
249
diff
changeset
|
65 } |
98f3a8568b0c
Tests: try to load python plugin if uwsgi has no wsgi option.
Sergey Budnevitch <sb@waeme.net>
parents:
249
diff
changeset
|
66 |
98f3a8568b0c
Tests: try to load python plugin if uwsgi has no wsgi option.
Sergey Budnevitch <sb@waeme.net>
parents:
249
diff
changeset
|
67 $t->run_daemon('uwsgi', '--socket', '127.0.0.1:8081', @uwsgiopts, |
168 | 68 '--wsgi-file', $t->testdir() . '/uwsgi_test_app.py', |
69 '--logto', $t->testdir() . '/uwsgi_log'); | |
70 | |
71 $t->run(); | |
72 | |
174
c8169c827d18
Tests: use waitoforsocket() as uwsgi startup may take a while.
Maxim Dounin <mdounin@mdounin.ru>
parents:
168
diff
changeset
|
73 $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
|
74 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
|
75 |
168 | 76 ############################################################################### |
77 | |
78 like(http_get('/'), qr/SEE-THIS/, 'uwsgi request'); | |
79 unlike(http_head('/head'), qr/SEE-THIS/, 'no data in HEAD'); | |
80 | |
81 like(http_get_headers('/headers'), qr/SEE-THIS/, | |
82 'uwsgi request with many ignored headers'); | |
83 | |
84 ############################################################################### | |
85 | |
86 sub http_get_headers { | |
87 my ($url, %extra) = @_; | |
88 return http(<<EOF, %extra); | |
89 GET $url HTTP/1.0 | |
90 Host: localhost | |
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 X-Blah: ignored header | |
103 X-Blah: ignored header | |
104 X-Blah: ignored header | |
105 X-Blah: ignored header | |
106 X-Blah: ignored header | |
107 X-Blah: ignored header | |
108 X-Blah: ignored header | |
109 X-Blah: ignored header | |
110 | |
111 EOF | |
112 } | |
113 | |
114 ############################################################################### |