Mercurial > hg > nginx-tests
comparison stub_status.t @ 599:868ff7169ec8
Tests: fixed stub_status tests, notably on freebsd.
Added delay for state tests to keep correct request order.
Made sure to process pipelined requests.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Tue, 02 Jun 2015 12:11:14 +0300 |
parents | 66f4d8cb719e |
children | 3832869ba854 |
comparison
equal
deleted
inserted
replaced
598:153969b53780 | 599:868ff7169ec8 |
---|---|
71 is($status{'writing'}, 1, 'first response'); | 71 is($status{'writing'}, 1, 'first response'); |
72 is($status{'reading'}, 0, 'not reading'); | 72 is($status{'reading'}, 0, 'not reading'); |
73 | 73 |
74 # pipelined requests | 74 # pipelined requests |
75 | 75 |
76 my $s = http(<<EOF, start => 1); | 76 my $s = http(<<EOF); |
77 GET / HTTP/1.1 | 77 GET / HTTP/1.1 |
78 Host: localhost | 78 Host: localhost |
79 | 79 |
80 GET / HTTP/1.1 | 80 GET / HTTP/1.1 |
81 Host: localhost | 81 Host: localhost |
82 Connection: close | |
82 | 83 |
83 EOF | 84 EOF |
84 | 85 |
85 %status = status('/stub'); | 86 %status = status('/stub'); |
86 is($status{'requests'}, 5, 'requests increased by 2'); | 87 is($status{'requests'}, 5, 'requests increased by 2'); |
87 is($status{'accepts'}, 4, 'accepts increased by 1'); | 88 is($status{'accepts'}, 4, 'accepts increased by 1'); |
88 | |
89 $s->close(); | |
90 | 89 |
91 # states | 90 # states |
92 | 91 |
93 $s = http('', start => 1); | 92 $s = http('', start => 1); |
94 | 93 |
96 is($status{'active'}, 2, 'active'); | 95 is($status{'active'}, 2, 'active'); |
97 is($status{'waiting'}, 1, 'waiting state'); | 96 is($status{'waiting'}, 1, 'waiting state'); |
98 is($status{'reading'}, 0, 'waiting state - not reading'); | 97 is($status{'reading'}, 0, 'waiting state - not reading'); |
99 is($status{'writing'}, 1, 'waiting state - not writing'); | 98 is($status{'writing'}, 1, 'waiting state - not writing'); |
100 | 99 |
101 http(<<EOF, start => 1, socket => $s); | 100 http(<<EOF, start => 1, socket => $s, sleep => 0.2); |
102 GET /rate HTTP/1.0 | 101 GET /rate HTTP/1.0 |
103 EOF | 102 EOF |
104 | 103 |
105 %status = status('/stub'); | 104 %status = status('/stub'); |
106 is($status{'waiting'}, 0, 'reading state - not waiting'); | 105 is($status{'waiting'}, 0, 'reading state - not waiting'); |
107 is($status{'reading'}, 1, 'reading state'); | 106 is($status{'reading'}, 1, 'reading state'); |
108 is($status{'writing'}, 1, 'reading state - not writing'); | 107 is($status{'writing'}, 1, 'reading state - not writing'); |
109 | 108 |
110 http(<<EOF, start => 1, socket => $s); | 109 http(<<EOF, start => 1, socket => $s, sleep => 0.2); |
111 Host: localhost | 110 Host: localhost |
112 | 111 |
113 EOF | 112 EOF |
114 | 113 |
115 %status = status('/stub'); | 114 %status = status('/stub'); |