Skip to content

Commit 9ba7eb7

Browse files
remove read after peek
1 parent c1965ad commit 9ba7eb7

File tree

1 file changed

+14
-33
lines changed

1 file changed

+14
-33
lines changed

t/stream/xrpc/downstream.t

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,7 @@ timeout
5555

5656

5757

58-
=== TEST 3: read with peek
59-
--- stream_server_config
60-
preread_by_lua_block {
61-
local ffi = require("ffi")
62-
local sk = require("resty.apisix.stream.xrpc.socket").downstream.socket()
63-
sk:settimeout(5)
64-
sk:peek(4)
65-
local p = assert(sk:read(9))
66-
ngx.say(ffi.string(p, 9))
67-
ngx.exit(200)
68-
}
69-
proxy_pass 127.0.0.1:1990;
70-
--- stream_request
71-
hello world
72-
--- stream_response
73-
hello wor
74-
75-
76-
77-
=== TEST 4: read with peek (peeked data > read)
58+
=== TEST 3: read with peek (peeked data > read)
7859
--- stream_server_config
7960
preread_by_lua_block {
8061
local ffi = require("ffi")
@@ -93,7 +74,7 @@ hello wor
9374

9475

9576

96-
=== TEST 5: read over buffer
77+
=== TEST 4: read over buffer
9778
--- stream_server_config
9879
content_by_lua_block {
9980
local ffi = require("ffi")
@@ -110,7 +91,7 @@ hello wor
11091

11192

11293

113-
=== TEST 6: read over buffer in the middle
94+
=== TEST 5: read over buffer in the middle
11495
--- stream_server_config
11596
content_by_lua_block {
11697
local ffi = require("ffi")
@@ -143,7 +124,7 @@ stream lua tcp socket allocate new new buf of size 4608
143124

144125

145126

146-
=== TEST 7: read & move
127+
=== TEST 6: read & move
147128
--- stream_config
148129
server {
149130
listen 1995;
@@ -186,7 +167,7 @@ hello world
186167

187168

188169

189-
=== TEST 8: multiple moves
170+
=== TEST 7: multiple moves
190171
--- stream_config
191172
server {
192173
listen 1995;
@@ -219,7 +200,7 @@ hello world
219200

220201

221202

222-
=== TEST 9: multiple moves + read over buffer in the middle
203+
=== TEST 8: multiple moves + read over buffer in the middle
223204
--- stream_config
224205
server {
225206
listen 1995;
@@ -259,7 +240,7 @@ stream lua tcp socket allocate new new buf of size 144
259240

260241

261242

262-
=== TEST 10: drain & move
243+
=== TEST 9: drain & move
263244
--- stream_config
264245
server {
265246
listen 1995;
@@ -302,7 +283,7 @@ hello world
302283

303284

304285

305-
=== TEST 11: read & drain & move & reset_read_buf
286+
=== TEST 10: read & drain & move & reset_read_buf
306287
--- stream_config
307288
server {
308289
listen 1995;
@@ -337,7 +318,7 @@ hello world
337318

338319

339320

340-
=== TEST 12: move & reset_read_buf + read over buffer in the middle
321+
=== TEST 11: move & reset_read_buf + read over buffer in the middle
341322
--- stream_config
342323
server {
343324
listen 1995;
@@ -375,7 +356,7 @@ hello world
375356

376357

377358

378-
=== TEST 13: read_line
359+
=== TEST 12: read_line
379360
--- stream_server_config
380361
content_by_lua_block {
381362
local ffi = require("ffi")
@@ -398,7 +379,7 @@ hello world
398379

399380

400381

401-
=== TEST 14: read_line, bad `\r\n`
382+
=== TEST 13: read_line, bad `\r\n`
402383
--- stream_server_config
403384
content_by_lua_block {
404385
local ffi = require("ffi")
@@ -421,7 +402,7 @@ hello world
421402

422403

423404

424-
=== TEST 15: read_line, no `\r\n`
405+
=== TEST 14: read_line, no `\r\n`
425406
--- stream_server_config
426407
content_by_lua_block {
427408
local ffi = require("ffi")
@@ -446,7 +427,7 @@ socket read timed out
446427

447428

448429

449-
=== TEST 16: read_line within len
430+
=== TEST 15: read_line within len
450431
--- stream_server_config
451432
content_by_lua_block {
452433
local ffi = require("ffi")
@@ -469,7 +450,7 @@ socket read timed out
469450

470451

471452

472-
=== TEST 17: read_line within len, no `\r\n`
453+
=== TEST 16: read_line within len, no `\r\n`
473454
--- stream_server_config
474455
content_by_lua_block {
475456
local ffi = require("ffi")

0 commit comments

Comments
 (0)