From fa4109181712fcef2aa2ab91e3f68eee8e2b15ad Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Mon, 1 Apr 2024 23:13:25 -0700 Subject: [PATCH] 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. --- nginx/t/stream_js.t | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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'); -- 2.47.3