comparison uwsgi.t @ 168:e9133938a5d3

Tests: add uwsgi tests.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 19 Aug 2011 14:30:11 +0400
parents
children c8169c827d18
comparison
equal deleted inserted replaced
167:b8fdbc918280 168:e9133938a5d3
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
29 daemon off;
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
65 ###############################################################################
66
67 like(http_get('/'), qr/SEE-THIS/, 'uwsgi request');
68 unlike(http_head('/head'), qr/SEE-THIS/, 'no data in HEAD');
69
70 SKIP: {
71 skip 'unsafe', 1 unless $ENV{TEST_NGINX_UNSAFE};
72 local $TODO = 'not yet';
73
74 like(http_get_headers('/headers'), qr/SEE-THIS/,
75 'uwsgi request with many ignored headers');
76
77 }
78
79 ###############################################################################
80
81 sub http_get_headers {
82 my ($url, %extra) = @_;
83 return http(<<EOF, %extra);
84 GET $url HTTP/1.0
85 Host: localhost
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 X-Blah: ignored header
103 X-Blah: ignored header
104 X-Blah: ignored header
105
106 EOF
107 }
108
109 ###############################################################################