annotate js_async.t @ 1427:eb1d883305ea

Tests: avoid edge cases in upstream random two test. Unavailable servers contribute to the number of attempts, if selected, before the balancer would fall back to the default round-robin method. This means that it's quite possible to get server with more connections. To facilitate with selecting two alive servers, down server was removed from the upstream configuration at the cost of slightly worse coverage.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 10 Jan 2019 17:42:34 +0300
parents f168fc46c7a4
children 9d8b100a6ce3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1304
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
2
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
3 # (C) Dmitry Volyntsev
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
5
1375
f168fc46c7a4 Tests: renamed JavaScript to njs.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1304
diff changeset
6 # Async tests for http njs module.
1304
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
7
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
8 ###############################################################################
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
9
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
10 use warnings;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
11 use strict;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
12
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
13 use Test::More;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
14
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
16
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
17 use lib 'lib';
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
19
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
20 ###############################################################################
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
21
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
22 select STDERR; $| = 1;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
23 select STDOUT; $| = 1;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
24
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
25 my $t = Test::Nginx->new()->has(qw/http rewrite/)
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
26 ->write_file_expand('nginx.conf', <<'EOF');
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
27
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
28 %%TEST_GLOBALS%%
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
29
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
30 daemon off;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
31
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
32 events {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
33 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
34
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
35 http {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
36 %%TEST_GLOBALS_HTTP%%
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
37
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
38 js_set $test_async set_timeout;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
39 js_set $context_var context_var;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
40
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
41 js_include test.js;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
42
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
43 server {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
44 listen 127.0.0.1:8080;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
45 server_name localhost;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
46
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
47 location /async_var {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
48 return 200 $test_async;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
49 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
50
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
51 location /shared_ctx {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
52 add_header H $context_var;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
53 js_content shared_ctx;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
54 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
55
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
56 location /set_timeout {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
57 js_content set_timeout;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
58 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
59
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
60 location /set_timeout_many {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
61 js_content set_timeout_many;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
62 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
63
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
64 location /set_timeout_data {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
65 postpone_output 0;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
66 js_content set_timeout_data;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
67 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
68
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
69 location /limit_rate {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
70 postpone_output 0;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
71 sendfile_max_chunk 5;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
72 js_content limit_rate;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
73 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
74 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
75 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
76
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
77 EOF
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
78
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
79 $t->write_file('test.js', <<EOF);
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
80 function set_timeout(req, res) {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
81 var timerId = setTimeout(timeout_cb_r, 5, req, res, 0);
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
82 clearTimeout(timerId);
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
83 setTimeout(timeout_cb_r, 5, req, res, 0)
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
84 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
85
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
86 function set_timeout_data(req, res) {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
87 setTimeout(timeout_cb_data, 5, req, res, 0);
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
88 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
89
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
90 function set_timeout_many(req, res) {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
91 for (var i = 0; i < 5; i++) {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
92 setTimeout(timeout_cb_empty, 5, req, i);
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
93 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
94
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
95 setTimeout(timeout_cb_reply, 10, res);
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
96 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
97
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
98 function timeout_cb_r(req, res, cnt) {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
99 if (cnt == 10) {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
100 res.status = 200;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
101 res.contentType = 'foo';
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
102 res.sendHeader();
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
103 res.finish();
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
104
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
105 } else {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
106 setTimeout(timeout_cb_r, 5, req, res, ++cnt);
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
107 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
108 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
109
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
110 function timeout_cb_empty(req, arg) {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
111 req.log("timeout_cb_empty" + arg);
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
112 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
113
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
114 function timeout_cb_reply(res) {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
115 res.status = 200;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
116 res.contentType = 'reply';
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
117 res.sendHeader();
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
118 res.finish();
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
119 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
120
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
121 function timeout_cb_data(req, res, counter) {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
122 if (counter == 0) {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
123 req.log("timeout_cb_data: init");
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
124 res.status = 200;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
125 res.sendHeader();
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
126 setTimeout(timeout_cb_data, 5, req, res, ++counter);
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
127
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
128 } else if (counter == 10) {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
129 req.log("timeout_cb_data: finish");
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
130 res.finish();
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
131
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
132 } else {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
133 res.send("" + counter);
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
134 setTimeout(timeout_cb_data, 5, req, res, ++counter);
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
135 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
136 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
137
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
138 var js_;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
139 function context_var() {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
140 return js_;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
141 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
142
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
143 function shared_ctx(req, res) {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
144 js_ = req.variables.arg_a;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
145
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
146 res.status = 200;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
147 res.sendHeader();
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
148 res.finish();
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
149 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
150
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
151 function limit_rate_cb(res) {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
152 res.finish();
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
153 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
154
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
155 function limit_rate(req, res) {
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
156 res.status = 200;
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
157 res.sendHeader();
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
158 res.send("AAAAA".repeat(10))
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
159 setTimeout(limit_rate_cb, 1000, res);
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
160 }
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
161
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
162 EOF
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
163
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
164 $t->try_run('no njs available')->plan(7);
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
165
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
166 ###############################################################################
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
167
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
168 like(http_get('/set_timeout'), qr/Content-Type: foo/, 'setTimeout');
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
169 like(http_get('/set_timeout_many'), qr/Content-Type: reply/, 'setTimeout many');
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
170 like(http_get('/set_timeout_data'), qr/123456789/, 'setTimeout data');
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
171 like(http_get('/shared_ctx?a=xxx'), qr/H: xxx/, 'shared context');
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
172 like(http_get('/limit_rate'), qr/A{50}/, 'limit_rate');
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
173
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
174 http_get('/async_var');
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
175
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
176 $t->stop();
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
177
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
178 ok(index($t->read_file('error.log'), 'pending events') > 0,
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
179 'pending js events');
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
180 ok(index($t->read_file('error.log'), 'async operation inside') > 0,
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
181 'async op in var handler');
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
182
25de201c8a0d Tests: added njs async tests.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
183 ###############################################################################