comparison fastcgi.t @ 952:e9064d691790

Tests: converted tests to run in parallel.
author Andrey Zelenkov <zelenkov@nginx.com>
date Tue, 21 Jun 2016 16:39:13 +0300
parents eca9b1d19021
children 882267679006
comparison
equal deleted inserted replaced
951:9361c7eddfc1 952:e9064d691790
37 37
38 http { 38 http {
39 %%TEST_GLOBALS_HTTP%% 39 %%TEST_GLOBALS_HTTP%%
40 40
41 upstream u { 41 upstream u {
42 server 127.0.0.1:8081; 42 server 127.0.0.1:%%PORT_1%%;
43 } 43 }
44 44
45 server { 45 server {
46 listen 127.0.0.1:8080; 46 listen 127.0.0.1:%%PORT_0%%;
47 server_name localhost; 47 server_name localhost;
48 48
49 location / { 49 location / {
50 fastcgi_pass 127.0.0.1:8081; 50 fastcgi_pass 127.0.0.1:%%PORT_1%%;
51 fastcgi_param REQUEST_URI $request_uri; 51 fastcgi_param REQUEST_URI $request_uri;
52 } 52 }
53 53
54 location /var { 54 location /var {
55 fastcgi_pass $arg_b; 55 fastcgi_pass $arg_b;
59 } 59 }
60 60
61 EOF 61 EOF
62 62
63 $t->run_daemon(\&fastcgi_daemon); 63 $t->run_daemon(\&fastcgi_daemon);
64 $t->run()->waitforsocket('127.0.0.1:8081'); 64 $t->run()->waitforsocket('127.0.0.1:' . port(1));
65 65
66 ############################################################################### 66 ###############################################################################
67 67
68 like(http_get('/'), qr/SEE-THIS/, 'fastcgi request'); 68 like(http_get('/'), qr/SEE-THIS/, 'fastcgi request');
69 like(http_get('/redir'), qr/ 302 /, 'fastcgi redirect'); 69 like(http_get('/redir'), qr/ 302 /, 'fastcgi redirect');
71 71
72 unlike(http_head('/'), qr/SEE-THIS/, 'no data in HEAD'); 72 unlike(http_head('/'), qr/SEE-THIS/, 'no data in HEAD');
73 73
74 like(http_get('/stderr'), qr/SEE-THIS/, 'large stderr handled'); 74 like(http_get('/stderr'), qr/SEE-THIS/, 'large stderr handled');
75 75
76 like(http_get('/var?b=127.0.0.1:8081'), qr/SEE-THIS/, 'fastcgi with variables'); 76 like(http_get('/var?b=127.0.0.1:' . port(1)), qr/SEE-THIS/,
77 'fastcgi with variables');
77 like(http_get('/var?b=u'), qr/SEE-THIS/, 'fastcgi with variables to upstream'); 78 like(http_get('/var?b=u'), qr/SEE-THIS/, 'fastcgi with variables to upstream');
78 79
79 ############################################################################### 80 ###############################################################################
80 81
81 sub fastcgi_daemon { 82 sub fastcgi_daemon {
82 my $socket = FCGI::OpenSocket('127.0.0.1:8081', 5); 83 my $socket = FCGI::OpenSocket('127.0.0.1:' . port(1), 5);
83 my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV, 84 my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
84 $socket); 85 $socket);
85 86
86 my $count; 87 my $count;
87 while( $request->Accept() >= 0 ) { 88 while( $request->Accept() >= 0 ) {
90 if ($ENV{REQUEST_URI} eq '/stderr') { 91 if ($ENV{REQUEST_URI} eq '/stderr') {
91 warn "sample stderr text" x 512; 92 warn "sample stderr text" x 512;
92 } 93 }
93 94
94 print <<EOF; 95 print <<EOF;
95 Location: http://127.0.0.1:8080/redirect 96 Location: http://localhost/redirect
96 Content-Type: text/html 97 Content-Type: text/html
97 98
98 SEE-THIS 99 SEE-THIS
99 $count 100 $count
100 EOF 101 EOF