annotate stream_js_send.t @ 1851:0351dee227a8

Tests: unbreak tests with dynamic certificates on stable. In 74cffa9d4c43, ticket based session reuse is enabled in addition to using a shared SSL session cache. This changed how a session can be resumed in a different server: - for a session ID based resumption, it is resumed in the same context - when using session tickets, a key name is also checked for matching - with a ticket callback, this is skipped in favor of callback's logic This makes 'session id context match' tests fail with session tickets on stable since ticket key names are unique in distinct SSL contexts. On the other hand, tests pass on 1.23.2+ due to automatic ticket keys rotation that installs ticket callback, and using a common shared SSL session cache.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 28 Mar 2023 01:36:32 +0400
parents 520fb74cce4c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1793
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
2
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
3 # (C) Dmitry Volyntsev
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
5
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
6 # Tests for s.send() in stream njs module.
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
7
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
8 ###############################################################################
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
9
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
10 use warnings;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
11 use strict;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
12
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
13 use Test::More;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
14
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
16
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
17 use lib 'lib';
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
19 use Test::Nginx::Stream qw/ stream /;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
20
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
21 ###############################################################################
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
22
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
23 select STDERR; $| = 1;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
24 select STDOUT; $| = 1;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
25
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
26 my $t = Test::Nginx->new()->has(qw/http stream/)
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
27 ->write_file_expand('nginx.conf', <<'EOF');
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
28
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
29 %%TEST_GLOBALS%%
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
30
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
31 daemon off;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
32
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
33 events {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
34 }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
35
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
36 http {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
37 %%TEST_GLOBALS_HTTP%%
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
38
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
39 js_import test.js;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
40
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
41 server {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
42 listen 127.0.0.1:8080;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
43 server_name localhost;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
44
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
45 location /njs {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
46 js_content test.njs;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
47 }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
48 }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
49 }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
50
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
51 stream {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
52 %%TEST_GLOBALS_STREAM%%
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
53
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
54 js_import test.js;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
55
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
56 server {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
57 listen 127.0.0.1:8081;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
58 js_filter test.filter;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
59 proxy_pass 127.0.0.1:8090;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
60 }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
61
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
62 server {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
63 listen 127.0.0.1:8082;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
64 js_filter test.filter_direct;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
65 proxy_pass 127.0.0.1:8090;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
66 }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
67 }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
68
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
69 EOF
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
70
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
71 $t->write_file('test.js', <<EOF);
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
72 function test_njs(r) {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
73 r.return(200, njs.version);
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
74 }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
75
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
76 function filter(s) {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
77 s.on("upload", async (data, flags) => {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
78 s.send("__HANDSHAKE__", flags);
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
79
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
80 const p = new Promise((resolve, reject) => {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
81 s.on("download", (data, flags) => {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
82 s.off("download");
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
83 resolve(data);
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
84 });
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
85 });
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
86
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
87 s.off("upload");
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
88
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
89 const handshakeResponse = await p;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
90 if (handshakeResponse != '__HANDSHAKE_RESPONSE__') {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
91 throw `Handshake failed: \${handshakeResponse}`;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
92 }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
93
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
94 s.send(data, flags);
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
95 });
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
96 }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
97
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
98 function filter_direct(s) {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
99 s.on("upload", async (data, flags) => {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
100 s.sendUpstream("__HANDSHAKE__", flags);
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
101
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
102 const p = new Promise((resolve, reject) => {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
103 s.on("download", (data, flags) => {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
104 s.off("download");
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
105 resolve(data);
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
106 });
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
107 });
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
108
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
109 s.off("upload");
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
110
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
111 const handshakeResponse = await p;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
112 if (handshakeResponse != '__HANDSHAKE_RESPONSE__') {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
113 throw `Handshake failed: \${handshakeResponse}`;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
114 }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
115
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
116 s.sendDownstream('xxx', flags);
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
117 s.sendUpstream(data, flags);
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
118 });
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
119 }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
120
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
121 export default {njs:test_njs, filter, filter_direct};
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
122
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
123 EOF
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
124
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
125 $t->run_daemon(\&stream_daemon, port(8090));
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
126 $t->try_run('no stream njs available')->plan(2);
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
127 $t->waitforsocket('127.0.0.1:' . port(8090));
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
128
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
129 ###############################################################################
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
130
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
131 is(stream('127.0.0.1:' . port(8081))->io('abc'), 'ABC',
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
132 'async filter');;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
133 is(stream('127.0.0.1:' . port(8082))->io('abc'), 'xxxABC',
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
134 'async filter direct');
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
135
1811
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
136 $t->stop();
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
137
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
138 ###############################################################################
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
139
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
140 sub has_version {
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
141 my $need = shift;
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
142
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
143 http_get('/njs') =~ /^([.0-9]+)$/m;
1793
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
144
1811
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
145 my @v = split(/\./, $1);
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
146 my ($n, $v);
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
147
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
148 for $n (split(/\./, $need)) {
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
149 $v = shift @v || 0;
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
150 return 0 if $n > $v;
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
151 return 1 if $v > $n;
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
152 }
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
153
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
154 return 1;
520fb74cce4c Tests: improved njs version check to account multi digit versions.
Dmitry Volyntsev <xeioex@nginx.com>
parents: 1793
diff changeset
155 }
1793
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
156
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
157 ###############################################################################
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
158
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
159 sub stream_daemon {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
160 my $server = IO::Socket::INET->new(
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
161 Proto => 'tcp',
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
162 LocalAddr => '127.0.0.1:' . port(8090),
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
163 Listen => 5,
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
164 Reuse => 1
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
165 )
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
166 or die "Can't create listening socket: $!\n";
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
167
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
168 local $SIG{PIPE} = 'IGNORE';
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
169
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
170 while (my $client = $server->accept()) {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
171 $client->autoflush(1);
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
172
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
173 log2c("(new connection $client)");
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
174
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
175 $client->sysread(my $buffer, 65536) or next;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
176
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
177 log2i("$client $buffer");
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
178
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
179 if ($buffer ne "__HANDSHAKE__") {
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
180 $buffer = "__HANDSHAKE_INVALID__";
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
181 log2o("$client $buffer");
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
182 $client->syswrite($buffer);
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
183
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
184 close $client;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
185 }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
186
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
187 $buffer = "__HANDSHAKE_RESPONSE__";
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
188 log2o("$client $buffer");
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
189 $client->syswrite($buffer);
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
190
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
191 $client->sysread($buffer, 65536) or next;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
192
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
193 $buffer = uc($buffer);
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
194 log2o("$client $buffer");
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
195 $client->syswrite($buffer);
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
196
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
197 close $client;
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
198 }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
199 }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
200
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
201 sub log2i { Test::Nginx::log_core('|| <<', @_); }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
202 sub log2o { Test::Nginx::log_core('|| >>', @_); }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
203 sub log2c { Test::Nginx::log_core('||', @_); }
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
204
261967d85363 Tests: added js tests for s.send() in async context.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
diff changeset
205 ###############################################################################