From: Dmitry Volyntsev Date: Tue, 2 Apr 2024 06:13:25 +0000 (-0700) Subject: Tests: adapt stream_js.t to nginx changes. X-Git-Tag: 0.8.4~8 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=fa4109181712fcef2aa2ab91e3f68eee8e2b15ad;p=njs.git Tests: adapt stream_js.t to nginx changes. Make the test more robust against changes in nginx, specifically cf890df37bb6 (Stream: socket peek in preread phase). The filter callbacks may be called multiple times by nginx and the exact number is not specified. The new test avoids relying on the exact number of calls from nginx. --- diff --git a/nginx/t/stream_js.t b/nginx/t/stream_js.t index 8bf0dd37..ed80be65 100644 --- a/nginx/t/stream_js.t +++ b/nginx/t/stream_js.t @@ -227,9 +227,10 @@ $t->write_file('test.js', < { if (!res || res[res.length - 1] != v) res += v }; function access_step(s) { - res += '1'; + step(1); setTimeout(function() { if (s.remoteAddress.match('127.0.0.1')) { @@ -240,8 +241,8 @@ $t->write_file('test.js', <= 3) { + step(2); + if (data.length > 0) { s.done(); } }); @@ -249,18 +250,18 @@ $t->write_file('test.js', <read(), 'variable=127.0.0.1', is(stream('127.0.0.1:' . port(8083))->read(), '', 'stream js unknown function'); is(stream('127.0.0.1:' . port(8084))->read(), 'sess_unk=undefined', 's.unk'); -is(stream('127.0.0.1:' . port(8086))->io('0'), '0122345', +is(stream('127.0.0.1:' . port(8086))->io('0'), '012345', 'async handlers order'); is(stream('127.0.0.1:' . port(8087))->io('#'), 'OK', 'access_undecided'); is(stream('127.0.0.1:' . port(8088))->io('#'), 'OK', 'access_allow');